@Test public void setBindAddressToCanonicalLocalHostUsesValue() throws Exception { Builder builder = new Builder().setBindAddress(InetAddress.getLocalHost().getHostName()); assertThat(builder.getBindAddress()).isEqualTo(localHost); }
@Test public void setBindAddressToLocalHostNameUsesValue() throws Exception { String host = InetAddress.getLocalHost().getHostName(); Builder builder = new Builder().setBindAddress(host); assertThat(builder.getBindAddress()).isEqualTo(localHost); }
@Test public void setBindAddressToNonLocalHostThrowsIllegalArgumentException() { assertThatThrownBy(() -> new Builder().setBindAddress("yahoo.com")) .isInstanceOf(IllegalArgumentException.class); }
new LocatorLauncher.Builder().setBindAddress(bindAddress).setForce(force).setPort(port) .setRedirectOutput(redirectOutput).setWorkingDirectory(workingDirectory); if (hostnameForClients != null) {
setBindAddress(ObjectUtils.toString(options.valueOf("bind-address")));
final LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS) .setBindAddress(locatorHost).setDebug(isDebugging()).setPid(pid).setPort(locatorPort) .setWorkingDirectory(workingDirectory).build();
@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()); }
@Test public void setBindAddressToUnknownHostThrowsIllegalArgumentException() { assertThatThrownBy(() -> new Builder().setBindAddress("badhostname.badcompany.bad")) .isInstanceOf(IllegalArgumentException.class) .hasCauseInstanceOf(UnknownHostException.class); }
@Test public void setBindAddressToEmptyStringResultsInNull() throws Exception { Builder builder = new Builder(); builder.setBindAddress(""); assertThat(builder.getBindAddress()).isNull(); }
@Test public void setBindAddressToBlankStringResultsInNull() throws Exception { Builder builder = new Builder(); builder.setBindAddress(" "); assertThat(builder.getBindAddress()).isNull(); }
@Test public void setBindAddressReturnsBuilderInstance() throws Exception { Builder builder = new Builder(); assertThat(builder.setBindAddress(null)).isSameAs(builder); }
@Test public void setBindAddressToNullResultsInNull() throws Exception { Builder builder = new Builder(); builder.setBindAddress(null); assertThat(builder.getBindAddress()).isNull(); }