use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method test000StartLocatorCapturesOutputOnError.
@Test
public void test000StartLocatorCapturesOutputOnError() throws IOException {
final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
File pidFile = new File(workingDirectory, ProcessType.LOCATOR.getPidFileName());
assertTrue(pidFile.createNewFile());
writePid(pidFile, getPidOrOne());
pidFile.deleteOnExit();
assertTrue(pidFile.isFile());
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
String resultString = toString(result);
assertTrue(resultString, resultString.contains("Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
assertTrue(resultString, resultString.contains("Caused by: org.apache.geode.internal.process.FileAlreadyExistsException: Pid file already exists: " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(pidFile)));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ClusterConfigurationServiceEndToEndDUnitTest method createAndDeployJar.
private void createAndDeployJar(final String jarName) throws IOException {
File newDeployableJarFile = new File(jarName);
this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
csb.addOption(CliStrings.DEPLOY__JAR, jarName);
executeAndVerifyCommand(csb.getCommandString());
jarFileNames.add(jarName);
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ClusterConfigurationServiceEndToEndDUnitTest method createRegion.
private void createRegion(final String regionName, final RegionShortcut regionShortCut, final String group) {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name());
executeAndVerifyCommand(csb.getCommandString());
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ClusterConfigurationServiceEndToEndDUnitTest method destroyIndex.
private void destroyIndex(final String indexName, final String regionName, final String group) {
if (isBlank(indexName) && isBlank(regionName) && isBlank(group)) {
return;
}
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
if (!isBlank(indexName)) {
csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
}
if (!isBlank(regionName)) {
csb.addOption(CliStrings.DESTROY_INDEX__REGION, regionName);
}
if (!isBlank(group)) {
csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group);
}
executeAndVerifyCommand(csb.getCommandString());
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method test006StartLocatorInRelativeDirectory.
@Test
public void test006StartLocatorInRelativeDirectory() {
final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
File workingDirectory = new File(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
try {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__DIR, pathname);
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
String locatorOutput = toString(result);
assertNotNull(locatorOutput);
assertTrue("Locator output was: " + locatorOutput, locatorOutput.contains("Locator in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
} finally {
stopLocator(workingDirectory);
}
}
Aggregations