use of org.apache.karaf.shell.impl.console.HeadlessSessionImpl 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.HeadlessSessionImpl 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.HeadlessSessionImpl in project karaf by apache.
the class ActionMaskingCallbackTest method setUp.
@Before
public void setUp() {
ThreadIO tio = new ThreadIOImpl();
CommandProcessor cp = new CommandProcessorImpl(tio);
SessionFactory sf = new SessionFactoryImpl(tio);
InputStream is = new ByteArrayInputStream(new byte[0]);
PrintStream os = new PrintStream(new ByteArrayOutputStream());
Session session = new HeadlessSessionImpl(sf, cp, is, os, os);
parser = new KarafParser(session);
ActionCommand cmd = new ActionCommand(null, UserAddCommand.class);
cb = ActionMaskingCallback.build(cmd);
}
Aggregations