/** * Validates the arguments passed to the Builder when the 'start' command has been issued. * * @see org.apache.geode.distributed.LocatorLauncher.Command#START */ protected void validateOnStart() { if (Command.START == getCommand()) { if (isBlank(getMemberName()) && !isSet(System.getProperties(), DistributionConfig.GEMFIRE_PREFIX + NAME) && !isSet(getDistributedSystemProperties(), NAME) && !isSet(loadGemFireProperties(DistributedSystem.getPropertyFileURL()), NAME)) { throw new IllegalStateException( String.format( AbstractLauncher.MEMBER_NAME_ERROR_MESSAGE, "Locator", "Locator")); } if (!CURRENT_DIRECTORY.equalsIgnoreCase(getWorkingDirectory())) { throw new IllegalStateException( String.format( AbstractLauncher.WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE, "Locator", "Locator")); } } }
@Test public void getCommandReturnsUnspecifiedByDefault() throws Exception { assertThat(new Builder().getCommand()).isEqualTo(Builder.DEFAULT_COMMAND); }
@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(); }
this.command = builder.getCommand(); this.help = Boolean.TRUE.equals(builder.getHelp()); this.bindAddressSpecified = builder.isBindAddressSpecified();
@Test public void parseCommandWithTwoCommandsWithoutSwitchesUsesFirstCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand("START", Command.STATUS.getName()); assertThat(builder.getCommand()).isEqualTo(Command.START); }
@Test public void parseCommandWithStatusResultsInStatusCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand("Status"); assertThat(builder.getCommand()).isEqualTo(Command.STATUS); }
@Test public void setCommandWithNullResultsInDefaultCommand() throws Exception { Builder builder = new Builder(); new Builder().setCommand(null); assertThat(builder.getCommand()).isEqualTo(Builder.DEFAULT_COMMAND); }
@Test public void parseCommandWithNullStringArrayResultsInDefaultCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand((String[]) null); assertThat(builder.getCommand()).isEqualTo(Builder.DEFAULT_COMMAND); }
/** * Validates the arguments passed to the Builder when the 'status' command has been issued. * * @see org.apache.geode.distributed.LocatorLauncher.Command#STATUS */ protected void validateOnStatus() { if (Command.STATUS == getCommand()) { } }
@Test public void parseCommandWithStartResultsInStartCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand(Command.START.getName()); assertThat(builder.getCommand()).isEqualTo(Command.START); }
@Test public void parseCommandWithEmptyStringArrayResultsInDefaultCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand(); // empty String array assertThat(builder.getCommand()).isEqualTo(Builder.DEFAULT_COMMAND); }
@Test public void setCommandToStatusResultsInStatus() throws Exception { Builder builder = new Builder(); builder.setCommand(Command.STATUS); assertThat(builder.getCommand()).isEqualTo(Command.STATUS); }
@Test public void parseCommandWithTwoCommandsWithSwitchesUsesFirstCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand("--opt", "START", "-o", Command.STATUS.getName()); assertThat(builder.getCommand()).isEqualTo(Command.START); }
@Test public void parseCommandWithMixedCaseResultsInCorrectCase() throws Exception { Builder builder = new Builder(); builder.parseCommand("sToP"); assertThat(builder.getCommand()).isEqualTo(Command.STOP); }
/** * Validates the arguments passed to the Builder when the 'stop' command has been issued. * * @see org.apache.geode.distributed.LocatorLauncher.Command#STOP */ protected void validateOnStop() { if (Command.STOP == getCommand()) { } }
@Test public void parseCommandWithBadInputResultsInDefaultCommand() throws Exception { Builder builder = new Builder(); builder.parseCommand("badCommandName", "--start", "stat"); assertThat(builder.getCommand()).isEqualTo(Builder.DEFAULT_COMMAND); }