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);
}
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);
}
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;
}
Aggregations