use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherIntegrationTest method testBuilderParseArgumentsWithValuesSeparatedWithEquals.
@Test
public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
// given: a new builder and a directory
String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
Builder builder = new Builder();
// when: parsing arguments with values separated by equals
builder.parseArguments("start", "--dir=" + expectedWorkingDirectory, "--port=" + "12345", "memberOne");
// then: the getters should return properly parsed values
assertThat(builder.getCommand()).isEqualTo(Command.START);
assertThat(builder.getDebug()).isFalse();
assertThat(builder.getForce()).isFalse();
assertThat(builder.getHelp()).isFalse();
assertThat(builder.getBindAddress()).isNull();
assertThat(builder.getHostnameForClients()).isNull();
assertThat(builder.getMemberName()).isEqualTo("memberOne");
assertThat(builder.getPid()).isNull();
assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
assertThat(builder.getPort().intValue()).isEqualTo(12345);
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherIntegrationTest method testBuilderSetAndGetWorkingDirectory.
@Test
public void testBuilderSetAndGetWorkingDirectory() throws Exception {
// given: a new builder and a directory
String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
Builder builder = new Builder();
// when: not setting WorkingDirectory
// then: getWorkingDirectory returns default
assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
// when: setting WorkingDirectory to null
assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
// then: getWorkingDirectory returns default
assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
// when: setting WorkingDirectory to empty string
assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
// then: getWorkingDirectory returns default
assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
// when: setting WorkingDirectory to white space
assertThat(builder.setWorkingDirectory(" ")).isSameAs(builder);
// then: getWorkingDirectory returns default
assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
// when: setting WorkingDirectory to a directory
assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
// then: getWorkingDirectory returns that directory
assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
// when: setting WorkingDirectory to null (again)
assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
// then: getWorkingDirectory returns default
assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherIntegrationTest method testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart.
@Test
public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
// given: using LocatorLauncher in-process
// when: setting WorkingDirectory to non-current directory
when(new Builder().setCommand(Command.START).setMemberName("memberOne").setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())).build();
// then: throw IllegalStateException
then(caughtException()).isExactlyInstanceOf(IllegalStateException.class).hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Locator"));
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class FileProcessControllerIntegrationJUnitTest method generateStatusJson.
private static String generateStatusJson() {
Builder builder = new Builder();
LocatorLauncher defaultLauncher = builder.build();
Status status = Status.ONLINE;
LocatorState locatorState = new LocatorState(defaultLauncher, status);
return locatorState.toJson();
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherTest method testSetAndGetPid.
@Test
public void testSetAndGetPid() {
Builder builder = new Builder();
assertNull(builder.getPid());
assertSame(builder, builder.setPid(0));
assertEquals(0, builder.getPid().intValue());
assertSame(builder, builder.setPid(1));
assertEquals(1, builder.getPid().intValue());
assertSame(builder, builder.setPid(1024));
assertEquals(1024, builder.getPid().intValue());
assertSame(builder, builder.setPid(12345));
assertEquals(12345, builder.getPid().intValue());
assertSame(builder, builder.setPid(null));
assertNull(builder.getPid());
}
Aggregations