use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class DurableClientCommandsDUnitTest method testCloseDurableClients.
@Test
public void testCloseDurableClients() throws Exception {
setupSystem();
setupCqs();
closeDurableClient();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CLIENTS);
csb.addOption(CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID, clientName);
String commandString = csb.toString();
long giveUpTime = System.currentTimeMillis() + 20000;
CommandResult commandResult = null;
String resultAsString = null;
do {
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
} while (resultAsString.contains("Cannot close a running durable client") && giveUpTime > System.currentTimeMillis());
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
// Execute again to see the error condition
writeToLog("Command String : ", commandString);
commandResult = executeCommand(commandString);
resultAsString = commandResultToString(commandResult);
writeToLog("Command Result :\n", resultAsString);
assertTrue(Status.ERROR.equals(commandResult.getStatus()));
String errorMessage = CliStrings.format(CliStrings.NO_CLIENT_FOUND_WITH_CLIENT_ID, clientName);
assertTrue(resultAsString.contains(errorMessage));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method getCreateIndexCommand.
private String getCreateIndexCommand() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1");
return csb.toString();
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method getDestroyIndexCommand.
private String getDestroyIndexCommand() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
return csb.toString();
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneIndexCommandsDUnitTest method createIndexWithoutRegionShouldReturnCorrectResults.
@Test
public void createIndexWithoutRegionShouldReturnCorrectResults() throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
vm1.invoke(() -> {
getCache();
});
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
String resultAsString = executeCommandAndLogResult(csb);
vm1.invoke(() -> {
LuceneServiceImpl luceneService = (LuceneServiceImpl) LuceneServiceProvider.get(getCache());
final ArrayList<LuceneIndexCreationProfile> profiles = new ArrayList<>(luceneService.getAllDefinedIndexes());
assertEquals(1, profiles.size());
assertEquals(INDEX_NAME, profiles.get(0).getIndexName());
});
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneIndexCommandsDUnitTest method createIndexShouldNotAcceptBadIndexOrRegionNames.
@Test
public void createIndexShouldNotAcceptBadIndexOrRegionNames() {
final VM vm1 = Host.getHost(0).getVM(-1);
vm1.invoke(() -> {
getCache();
});
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, "\'__\'");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
String resultAsString = executeCommandAndLogResult(csb);
assertTrue(resultAsString.contains("Region names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens, underscores, or forward slashes:"));
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, "\' @@@*%\'");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
resultAsString = executeCommandAndLogResult(csb);
assertTrue(resultAsString.contains("Region names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens, underscores, or forward slashes:"));
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "\'__\'");
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
resultAsString = executeCommandAndLogResult(csb);
assertTrue(resultAsString.contains("Index names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens or underscores:"));
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "\' @@@*%\'");
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
resultAsString = executeCommandAndLogResult(csb);
assertTrue(resultAsString.contains("Index names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens or underscores:"));
}
Aggregations