use of org.apache.ignite.internal.commandline.cache.CacheSubcommands in project ignite by apache.
the class GridCommandHandlerClusterByClassTest method testCacheHelp.
/**
*/
@Test
public void testCacheHelp() throws Exception {
injectTestSystemOut();
assertEquals(EXIT_CODE_OK, execute("--cache", "help"));
String output = testOut.toString();
for (CacheSubcommands cmd : CacheSubcommands.values()) {
if (cmd != HELP) {
assertContains(log, output, cmd.toString());
Class<? extends Enum<? extends CommandArg>> args = cmd.getCommandArgs();
if (args != null)
for (Enum<? extends CommandArg> arg : args.getEnumConstants()) assertTrue(cmd + " " + arg, output.contains(arg.toString()));
} else
assertContains(log, output, CommandHandler.UTILITY_NAME);
}
checkHelp(output, "org.apache.ignite.util/" + getClass().getSimpleName() + "_cache_help.output");
}
use of org.apache.ignite.internal.commandline.cache.CacheSubcommands in project ignite by apache.
the class CommandHandlerParsingTest method testFindAndDeleteGarbage.
/**
*/
@Test
public void testFindAndDeleteGarbage() {
String nodeId = UUID.randomUUID().toString();
String delete = FindAndDeleteGarbageArg.DELETE.toString();
String groups = "group1,grpoup2,group3";
List<List<String>> lists = generateArgumentList(FIND_AND_DELETE_GARBAGE.text(), new T2<>(nodeId, false), new T2<>(delete, false), new T2<>(groups, false));
for (List<String> list : lists) {
ConnectionAndSslParameters args = parseArgs(list);
assertTrue(args.command() instanceof CacheCommands);
CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
FindAndDeleteGarbage.Arguments arg = (FindAndDeleteGarbage.Arguments) subcommand.subcommand().arg();
if (list.contains(nodeId))
assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId().toString());
else
assertNull(arg.nodeId());
assertEquals(list.contains(delete), arg.delete());
if (list.contains(groups))
assertEquals(3, arg.groups().size());
else
assertNull(arg.groups());
}
}
use of org.apache.ignite.internal.commandline.cache.CacheSubcommands in project ignite by apache.
the class CommandHandlerParsingTest method testValidateIndexArguments.
/**
* validate_indexes command arguments parsing and validation
*/
@Test
public void testValidateIndexArguments() {
// happy case for all parameters
try {
int expectedCheckFirst = 10;
int expectedCheckThrough = 11;
UUID nodeId = UUID.randomUUID();
ConnectionAndSslParameters args = parseArgs(asList(CACHE.text(), VALIDATE_INDEXES.text(), "cache1, cache2", nodeId.toString(), CHECK_FIRST.toString(), Integer.toString(expectedCheckFirst), CHECK_THROUGH.toString(), Integer.toString(expectedCheckThrough)));
assertTrue(args.command() instanceof CacheCommands);
CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
CacheValidateIndexes.Arguments arg = (CacheValidateIndexes.Arguments) subcommand.subcommand().arg();
assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId());
assertEquals("checkFirst parameter unexpected value", expectedCheckFirst, arg.checkFirst());
assertEquals("checkThrough parameter unexpected value", expectedCheckThrough, arg.checkThrough());
} catch (IllegalArgumentException e) {
fail("Unexpected exception: " + e);
}
try {
int expectedParam = 11;
UUID nodeId = UUID.randomUUID();
ConnectionAndSslParameters args = parseArgs(asList(CACHE.text(), VALIDATE_INDEXES.text(), nodeId.toString(), CHECK_THROUGH.toString(), Integer.toString(expectedParam)));
assertTrue(args.command() instanceof CacheCommands);
CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
CacheValidateIndexes.Arguments arg = (CacheValidateIndexes.Arguments) subcommand.subcommand().arg();
assertNull("caches weren't specified, null value expected", arg.caches());
assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId());
assertEquals("checkFirst parameter unexpected value", -1, arg.checkFirst());
assertEquals("checkThrough parameter unexpected value", expectedParam, arg.checkThrough());
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
assertParseArgsThrows("Value for '--check-first' property should be positive.", CACHE.text(), VALIDATE_INDEXES.text(), CHECK_FIRST.toString(), "0");
assertParseArgsThrows("Numeric value for '--check-through' parameter expected.", CACHE.text(), VALIDATE_INDEXES.text(), CHECK_THROUGH.toString());
}
Aggregations