Package org.apache.karaf.shell.commands.basic

Examples of org.apache.karaf.shell.commands.basic.SimpleCommand


    public void testSubShellScope() throws Exception {
        Context c = new Context();
        c.set("SCOPE", "*");
        c.addCommand("*", new SimpleSubShell("foo"), "foo");
        c.addCommand("*", new SimpleCommand(ExitAction.class), "exit");

        String scope = (String) c.get("SCOPE");
        c.execute("foo");
        assertEquals("foo:" + scope, c.get("SCOPE"));
        c.execute("exit");
View Full Code Here


    }

    public void testCommand() throws Exception {
        Context c = new Context();
        c.addCommand("*", this, "capture");
        c.addCommand("*", new SimpleCommand(MyAction.class), "my-action");

        // Test help
        Object help = c.execute("my-action --help | capture");
        assertTrue(help instanceof String);
        assertTrue(((String) help).indexOf("My Action") >= 0);
View Full Code Here

        assertEquals(Arrays.asList(4), c.execute("my-action --increment 3"));
    }

    public void testCommandTwoArguments() throws Exception {
        Context c = new Context();
        c.addCommand("*", new SimpleCommand(MyActionTwoArguments.class), "my-action-two-arguments");

        // test required arguments
        try {
            c.execute("my-action-two-arguments");
            fail("Action should have thrown an exception because of a missing argument");
View Full Code Here

        context.set("SCOPE", "*");
        context.set(SessionProperties.COMPLETION_MODE, "subshell");
        CommandSessionHolder.setSession(context.getSession());

        context.addCommand("*", new SimpleSubShell("foo"), "foo");
        context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
        context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
        context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
        context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
        context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");

        Completer comp = new CommandsCompleter(context.getSession());

        context.execute("foo");
        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
View Full Code Here

        context.set("SCOPE", "*");
        context.set(SessionProperties.COMPLETION_MODE, "first");
        CommandSessionHolder.setSession(context.getSession());

        context.addCommand("*", new SimpleSubShell("foo"), "foo");
        context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
        context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
        context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
        context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
        context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");

        Completer comp = new CommandsCompleter(context.getSession());

        context.execute("foo");
        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
View Full Code Here

        context.set("SCOPE", "*");
        context.set(SessionProperties.COMPLETION_MODE, "global");
        CommandSessionHolder.setSession(context.getSession());

        context.addCommand("*", new SimpleSubShell("foo"), "foo");
        context.addCommand("*", new SimpleCommand(ExitAction.class), "exit");
        context.addCommand("foo", new SimpleCommand(MyAction.class), "my-action");
        context.addCommand("foo", new SimpleCommand(MyActionTwoArguments.class), "one-action");
        context.addCommand("bar", new SimpleCommand(MyAction.class), "one-action");
        context.addCommand("bar", new SimpleCommand(MyActionTwoArguments.class), "another");

        Completer comp = new CommandsCompleter(context.getSession());

        context.execute("foo");
        assertEquals(Arrays.asList("my-action "), complete(comp, "my"));
View Full Code Here

TOP

Related Classes of org.apache.karaf.shell.commands.basic.SimpleCommand

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.