Search in sources :

Example 11 with CommandContext

use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.

the class AMQ3410Test method testFactorySetWrong1.

public void testFactorySetWrong1() 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("org.apache.activemq.console.command.TestAMQ3410.DoesntExistFactory");
    tokens.addAll(DEFAULT_TOKENS);
    try {
        command.execute(tokens);
    } catch (Throwable cause) {
        while (null != cause) {
            if (cause instanceof java.lang.ClassNotFoundException)
                return;
            cause = cause.getCause();
        }
    }
    assertFalse("No exception caught", true);
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList)

Example 12 with CommandContext

use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.

the class AMQ3410Test method testFactorySetWrong2.

public void testFactorySetWrong2() 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(InvalidConnectionFactory.class.getCanonicalName());
    tokens.addAll(DEFAULT_TOKENS);
    try {
        command.execute(tokens);
    } catch (Throwable e) {
        Throwable cause = e;
        while (null != cause) {
            if (cause instanceof java.lang.NoSuchMethodException)
                return;
            cause = cause.getCause();
        }
        assertFalse(e.toString(), true);
    }
    assertFalse("No exception caught", true);
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList)

Example 13 with CommandContext

use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.

the class AMQ3410Test method testFactorySetWrong3.

public void testFactorySetWrong3() 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("java.lang.Object");
    tokens.addAll(DEFAULT_TOKENS);
    try {
        command.execute(tokens);
    } catch (Throwable cause) {
        while (null != cause) {
            if (cause instanceof java.lang.NoSuchMethodException)
                return;
            cause = cause.getCause();
        }
    }
    assertFalse(true);
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList)

Example 14 with CommandContext

use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.

the class PurgeCommandTest method testDummy.

public void testDummy() throws Exception {
    try {
        String one = "ID:mac.fritz.box:1213242.3231.1:1:1:100";
        String two = "ID*: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("(XTestProperty LIKE '1:*') AND (JMSPriority>3)");
        addMessages();
        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();
    }
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) JMSException(javax.jms.JMSException)

Example 15 with CommandContext

use of org.apache.activemq.console.CommandContext in project activemq-artemis by apache.

the class PurgeCommandTest method testPurgeCommandComplexSelector.

public void testPurgeCommandComplexSelector() 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);
        addMessages();
        validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);
        purgeCommand.execute(tokens);
        QueueBrowser withPropertyBrowser = requestServerSession.createBrowser(theQueue, MSG_SEL_COMPLEX);
        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();
    }
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList) QueueBrowser(javax.jms.QueueBrowser)

Aggregations

ArrayList (java.util.ArrayList)15 CommandContext (org.apache.activemq.console.CommandContext)15 CommandShellOutputFormatter (org.apache.activemq.console.formatter.CommandShellOutputFormatter)15 QueueBrowser (javax.jms.QueueBrowser)3 IOException (java.io.IOException)2 JMSException (javax.jms.JMSException)2 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1