use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.
the class AMQ3410Test method testNoFactorySet.
public void testNoFactorySet() throws Exception {
AmqBrowseCommand command = new AmqBrowseCommand();
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
command.setCommandContext(context);
List<String> tokens = new ArrayList<>();
tokens.addAll(DEFAULT_OPTIONS);
tokens.addAll(DEFAULT_TOKENS);
command.execute(tokens);
assertNotNull(command.getConnectionFactory());
assertTrue(command.getConnectionFactory() instanceof ActiveMQConnectionFactory);
}
use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.
the class AMQ3410Test method testFactorySet.
public void testFactorySet() throws Exception {
AmqBrowseCommand command = new AmqBrowseCommand();
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
command.setCommandContext(context);
List<String> tokens = new ArrayList<>();
tokens.addAll(DEFAULT_OPTIONS);
tokens.add("--factory");
tokens.add(DummyConnectionFactory.class.getCanonicalName());
tokens.addAll(DEFAULT_TOKENS);
command.execute(tokens);
assertNotNull(command.getConnectionFactory());
assertTrue("wrong instance returned: " + command.getConnectionFactory().getClass().getName(), command.getConnectionFactory() instanceof DummyConnectionFactory);
}
use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.
the class PurgeCommandTest method testPurgeCommandComplexSQLSelector_OR.
public void testPurgeCommandComplexSQLSelector_OR() throws Exception {
try {
PurgeCommand purgeCommand = new PurgeCommand();
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
purgeCommand.setCommandContext(context);
purgeCommand.setJmxUseLocal(true);
List<String> tokens = new ArrayList<>();
tokens.add("--msgsel");
tokens.add(MSG_SEL_COMPLEX_SQL_OR);
addMessages();
validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);
purgeCommand.execute(tokens);
QueueBrowser withPropertyBrowser = requestServerSession.createBrowser(theQueue, MSG_SEL_COMPLEX_SQL_OR);
QueueBrowser allBrowser = requestServerSession.createBrowser(theQueue);
int withCount = getMessageCount(withPropertyBrowser, "withProperty ");
int allCount = getMessageCount(allBrowser, "allMessages ");
withPropertyBrowser.close();
allBrowser.close();
assertEquals("Expected withCount to be 0 but was " + withCount, 0, withCount);
assertEquals("Expected allCount to be 0 but was " + allCount, 0, allCount);
LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n");
} finally {
purgeAllMessages();
}
}
use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.
the class PurgeCommandTest method testPurgeCommandComplexSQLSelector_AND.
public void testPurgeCommandComplexSQLSelector_AND() throws Exception {
try {
String one = "ID:mac.fritz.box:1213242.3231.1:1:1:100";
String two = "\\*:100";
try {
if (one.matches(two))
LOG.info("String matches.");
else
LOG.info("string does not match.");
} catch (Exception ex) {
LOG.error(ex.getMessage());
}
PurgeCommand purgeCommand = new PurgeCommand();
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
purgeCommand.setCommandContext(context);
purgeCommand.setJmxUseLocal(true);
List<String> tokens = new ArrayList<>();
tokens.add("--msgsel");
tokens.add(MSG_SEL_COMPLEX_SQL_AND);
addMessages();
validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);
purgeCommand.execute(tokens);
QueueBrowser withPropertyBrowser = requestServerSession.createBrowser(theQueue, MSG_SEL_COMPLEX_SQL_AND);
QueueBrowser allBrowser = requestServerSession.createBrowser(theQueue);
int withCount = getMessageCount(withPropertyBrowser, "withProperty ");
int allCount = getMessageCount(allBrowser, "allMessages ");
withPropertyBrowser.close();
allBrowser.close();
assertEquals("Expected withCount to be " + "0" + " was " + withCount, 0, withCount);
assertEquals("Expected allCount to be " + MESSAGE_COUNT + " was " + allCount, MESSAGE_COUNT, allCount);
LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n");
} finally {
purgeAllMessages();
}
}
use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.
the class PurgeCommandTest method testPurgeCommandSimpleSelector.
public void testPurgeCommandSimpleSelector() throws Exception {
try {
PurgeCommand purgeCommand = new PurgeCommand();
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
purgeCommand.setCommandContext(context);
purgeCommand.setJmxUseLocal(true);
List<String> tokens = new ArrayList<>();
tokens.add("--msgsel");
tokens.add(MSG_SEL_WITH_PROPERTY);
addMessages();
validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);
purgeCommand.execute(tokens);
validateCounts(0, MESSAGE_COUNT, MESSAGE_COUNT);
} finally {
purgeAllMessages();
}
}
Aggregations