Search in sources :

Example 1 with SessionFactoryImpl

use of org.apache.karaf.shell.impl.console.SessionFactoryImpl in project karaf by apache.

the class ParsingTest method testCommandLineParserMultiLine.

@Test
public void testCommandLineParserMultiLine() {
    SessionFactoryImpl sessionFactory = new SessionFactoryImpl(new ThreadIOImpl());
    ManagerImpl manager = new ManagerImpl(sessionFactory, sessionFactory);
    sessionFactory.getRegistry().register(new ActionCommand(manager, FooCommand.class));
    sessionFactory.getRegistry().register(new ActionCommand(manager, AnotherCommand.class));
    sessionFactory.getRegistry().register(new CustomParser());
    Session session = new HeadlessSessionImpl(sessionFactory, sessionFactory.getCommandProcessor(), new ByteArrayInputStream(new byte[0]), new PrintStream(new ByteArrayOutputStream()), new PrintStream(new ByteArrayOutputStream()));
    String parsed = CommandLineParser.parse(session, "echo a\necho b");
    assertEquals("echo a\necho b", parsed);
}
Also used : PrintStream(java.io.PrintStream) HeadlessSessionImpl(org.apache.karaf.shell.impl.console.HeadlessSessionImpl) ThreadIOImpl(org.apache.felix.gogo.runtime.threadio.ThreadIOImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ManagerImpl(org.apache.karaf.shell.impl.action.command.ManagerImpl) ActionCommand(org.apache.karaf.shell.impl.action.command.ActionCommand) SessionFactoryImpl(org.apache.karaf.shell.impl.console.SessionFactoryImpl) Session(org.apache.karaf.shell.api.console.Session) Test(org.junit.Test)

Example 2 with SessionFactoryImpl

use of org.apache.karaf.shell.impl.console.SessionFactoryImpl in project karaf by apache.

the class ParsingTest method testCommandLineParser.

@Test
public void testCommandLineParser() {
    SessionFactoryImpl sessionFactory = new SessionFactoryImpl(new ThreadIOImpl());
    ManagerImpl manager = new ManagerImpl(sessionFactory, sessionFactory);
    sessionFactory.getRegistry().register(new ActionCommand(manager, FooCommand.class));
    sessionFactory.getRegistry().register(new ActionCommand(manager, AnotherCommand.class));
    sessionFactory.getRegistry().register(new CustomParser());
    Session session = new HeadlessSessionImpl(sessionFactory, sessionFactory.getCommandProcessor(), new ByteArrayInputStream(new byte[0]), new PrintStream(new ByteArrayOutputStream()), new PrintStream(new ByteArrayOutputStream()));
    String parsed = CommandLineParser.parse(session, " foo bar (a + b); another   command with spaces ");
    assertEquals("foo bar (a + b) ; another \"command with spaces\"", parsed);
}
Also used : PrintStream(java.io.PrintStream) HeadlessSessionImpl(org.apache.karaf.shell.impl.console.HeadlessSessionImpl) ThreadIOImpl(org.apache.felix.gogo.runtime.threadio.ThreadIOImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ManagerImpl(org.apache.karaf.shell.impl.action.command.ManagerImpl) ActionCommand(org.apache.karaf.shell.impl.action.command.ActionCommand) SessionFactoryImpl(org.apache.karaf.shell.impl.console.SessionFactoryImpl) Session(org.apache.karaf.shell.api.console.Session) Test(org.junit.Test)

Example 3 with SessionFactoryImpl

use of org.apache.karaf.shell.impl.console.SessionFactoryImpl in project karaf by apache.

the class Main method createSessionFactory.

protected SessionFactory createSessionFactory(ThreadIO threadio) {
    SessionFactoryImpl sessionFactory = new SessionFactoryImpl(threadio);
    sessionFactory.register(new ManagerImpl(sessionFactory, sessionFactory));
    return sessionFactory;
}
Also used : ManagerImpl(org.apache.karaf.shell.impl.action.command.ManagerImpl) SessionFactoryImpl(org.apache.karaf.shell.impl.console.SessionFactoryImpl)

Aggregations

ManagerImpl (org.apache.karaf.shell.impl.action.command.ManagerImpl)3 SessionFactoryImpl (org.apache.karaf.shell.impl.console.SessionFactoryImpl)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 ThreadIOImpl (org.apache.felix.gogo.runtime.threadio.ThreadIOImpl)2 Session (org.apache.karaf.shell.api.console.Session)2 ActionCommand (org.apache.karaf.shell.impl.action.command.ActionCommand)2 HeadlessSessionImpl (org.apache.karaf.shell.impl.console.HeadlessSessionImpl)2 Test (org.junit.Test)2