@Test public void buildUsesMemberNameSetInSystemPropertiesOnStart() { System.setProperty(DistributionConfig.GEMFIRE_PREFIX + NAME, "locatorXYZ"); LocatorLauncher launcher = new Builder().setCommand(LocatorLauncher.Command.START).build(); assertThat(launcher.getCommand()).isEqualTo(LocatorLauncher.Command.START); assertThat(launcher.getMemberName()).isNull(); } }
@Test public void buildCreatesLocatorLauncherWithBuilderValues() throws Exception { Builder builder = new Builder(); LocatorLauncher launcher = builder.setCommand(Command.START).setDebug(true) .setHostnameForClients("beanstock.vmware.com").setMemberName("Beanstock").setPort(8192) .setRedirectOutput(Boolean.TRUE).build(); assertThat(launcher.getCommand()).isEqualTo(builder.getCommand()); assertThat(launcher.isDebugging()).isTrue(); assertThat(launcher.getHostnameForClients()).isEqualTo(builder.getHostnameForClients()); assertThat(launcher.getMemberName()).isEqualTo(builder.getMemberName()); assertThat(launcher.getPort()).isEqualTo(builder.getPort()); assertThat(launcher.getWorkingDirectory()).isEqualTo(builder.getWorkingDirectory()); assertThat(launcher.isRedirectingOutput()).isTrue(); assertThat(launcher.isHelping()).isFalse(); assertThat(launcher.isRunning()).isFalse(); }
@Test public void testLocatorCommandLineWithRestAPI() throws Exception { LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.START) .setMemberName("testLocatorCommandLineWithRestAPI").setBindAddress("localhost") .setPort(11111).build(); Properties gemfireProperties = new Properties(); gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8089"); gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost"); String[] commandLineElements = startLocatorCommand.createStartLocatorCommandLine(locatorLauncher, null, null, gemfireProperties, null, false, new String[0], null, null); assertNotNull(commandLineElements); assertTrue(commandLineElements.length > 0); Set<String> expectedCommandLineElements = new HashSet<>(6); expectedCommandLineElements.add(locatorLauncher.getCommand().getName()); expectedCommandLineElements.add(locatorLauncher.getMemberName().toLowerCase()); expectedCommandLineElements.add(String.format("--port=%1$d", locatorLauncher.getPort())); expectedCommandLineElements .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_PORT + "=" + "8089"); expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_BIND_ADDRESS + "=" + "localhost"); for (String commandLineElement : commandLineElements) { expectedCommandLineElements.remove(commandLineElement.toLowerCase()); } assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements), expectedCommandLineElements.isEmpty()); }
public void run() { if (!isHelping()) { switch (getCommand()) { case START: info(start()); help(getCommand());