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

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


public class BooleanCompleterTest extends CompleterTestSupport {

    @Test
    public void testCompleteArgumnets() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class), "my:action");

        // arg 0
        assertEquals(Arrays.asList("true "), complete(comp, "action t"));
        assertEquals(Arrays.asList("false "), complete(comp, "action f"));
View Full Code Here


public class FileCompleterTest extends CompleterTestSupport {

    @Test
    public void testCompleteArgumnets() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class), "my:action");

        // arg 0
        assertEquals(Arrays.asList("src"+File.separator), complete(comp, "action s"));
        assertEquals(Arrays.asList("main"+File.separator), complete(comp, "action src/m"));
        assertEquals(Arrays.asList("java"+File.separator), complete(comp, "action src/main/j"));
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

public class CompleterValuesTest extends CompleterTestSupport {

    @Test
    public void testCompleteArgumnets() throws Exception {
        CommandSession session = new DummyCommandSession();
        Completer comp = new ArgumentCompleter(session, new SimpleCommand(MyAction.class), "my:action");

        // arg 0
        assertEquals(Arrays.asList("a1", "a2", "a3"), complete(comp, "action a"));
        assertEquals(Arrays.asList("b4", "b5"), complete(comp, "action b"));
View Full Code Here

    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

    }

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

        // 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

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.