Search in sources :

Example 1 with CommandShellOutputFormatter

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

the class AMQ3411Test 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("--passwordFactory");
    tokens.add("org.apache.activemq.console.command.TestAMQ3411.DoesntExistFactory");
    tokens.add("--password");
    tokens.add(origPassword);
    tokens.addAll(DEFAULT_TOKENS);
    try {
        command.execute(tokens);
    } catch (Throwable e) {
        Throwable cause = e;
        while (null != cause) {
            if (cause instanceof java.lang.ClassNotFoundException)
                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 2 with CommandShellOutputFormatter

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

the class AMQ3411Test 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.getPasswordFactory());
    assertTrue(command.getPasswordFactory() instanceof DefaultPasswordFactory);
    assertNull(command.getPassword());
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList)

Example 3 with CommandShellOutputFormatter

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

the class AMQ3411Test 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("--passwordFactory");
    tokens.add("java.lang.Object");
    tokens.add("--password");
    tokens.add(origPassword);
    tokens.addAll(DEFAULT_TOKENS);
    try {
        command.execute(tokens);
    } catch (Throwable e) {
        Throwable cause = e;
        while (null != cause) {
            if (cause instanceof java.lang.ClassCastException)
                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 4 with CommandShellOutputFormatter

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

the class AMQ3411Test method testUsernamePasswordSet.

public void testUsernamePasswordSet() throws Exception {
    AmqBrowseCommand command = new AmqBrowseCommand();
    CommandContext context = new CommandContext();
    String username = "user";
    String password = "password";
    context.setFormatter(new CommandShellOutputFormatter(System.out));
    command.setCommandContext(context);
    List<String> tokens = new ArrayList<>();
    tokens.addAll(DEFAULT_OPTIONS);
    tokens.add("--password");
    tokens.add(password);
    tokens.add("--user");
    tokens.add(username);
    tokens.addAll(DEFAULT_TOKENS);
    command.execute(tokens);
    assertNotNull(command.getPasswordFactory());
    assertTrue(command.getPasswordFactory() instanceof DefaultPasswordFactory);
    assertEquals(password, command.getPassword());
    assertEquals(username, command.getUsername());
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList)

Example 5 with CommandShellOutputFormatter

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

the class AMQ3411Test 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("--passwordFactory");
    tokens.add(LowercasingPasswordFactory.class.getCanonicalName());
    tokens.add("--password");
    tokens.add(origPassword);
    tokens.addAll(DEFAULT_TOKENS);
    command.execute(tokens);
    assertNotNull(command.getPasswordFactory());
    assertTrue(command.getPasswordFactory() instanceof LowercasingPasswordFactory);
    // validate that the factory is indeed being used for the password.
    assertEquals(origPassword.toLowerCase(), command.getPassword());
}
Also used : CommandContext(org.apache.activemq.console.CommandContext) CommandShellOutputFormatter(org.apache.activemq.console.formatter.CommandShellOutputFormatter) ArrayList(java.util.ArrayList)

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