Package org.apache.activemq.console

Examples of org.apache.activemq.console.CommandContext


        .getConnectionFactory() instanceof DummyConnectionFactory);
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here


    assertFalse("No exception caught", true);
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    assertFalse("No exception caught", true);
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    super.tearDown();
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    assertNull(command.getPassword());
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    assertEquals(username, command.getUsername());
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    assertEquals(origPassword.toLowerCase(), command.getPassword());
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    assertFalse("No exception caught", true);
  }

  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<String>();
    tokens.addAll(DEFAULT_OPTIONS);
View Full Code Here

    @Argument(index=0, multiValued=true, required=true)
    private Collection<String> arguments;

    protected Object doExecute() throws Exception {
        CommandContext context2 = new CommandContext();
        context2.setFormatter(new CommandShellOutputFormatter(System.out));
        Command currentCommand = command.getClass().newInstance();

        try {
            currentCommand.setCommandContext(context2);
            currentCommand.execute(arguments != null ? new ArrayList<String>(arguments) : new ArrayList<String>());
            return null;
        } catch (Throwable e) {
            Throwable cur = e;
            while (cur.getCause() != null) {
                cur = cur.getCause();
            }
            if (cur instanceof java.net.ConnectException) {
                context2
                    .print("\n"
                        + "Could not connect to JMX server.  This command requires that the remote JMX server be enabled.\n"
                        + "This is typically done by adding the following JVM arguments: \n"
                        + "   -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false \n"
                        + "   -Dcom.sun.management.jmxremote.ssl=false \n" + "\n"
View Full Code Here

     * @param out - output stream to use
     * @return 0 for a successful run, -1 if there are any exception
     */
    public static int main(String[] args, InputStream in, PrintStream out) {
       
        CommandContext context = new CommandContext();
        context.setFormatter(new CommandShellOutputFormatter(out));

        // Convert arguments to list for easier management
        List<String> tokens = new ArrayList<String>(Arrays.asList(args));

        ShellCommand main = new ShellCommand();
        try {
            main.setCommandContext(context);
            main.execute(tokens);
            return 0;
        } catch (Exception e) {
            context.printException(e);
            return -1;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.console.CommandContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.