public void testProcess() { final ArrayBlockingQueue<String> requests = new ArrayBlockingQueue<String>(1); final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1); shell.addProcess(new SyncProcess() { @Override public void run(String request, ShellProcessContext context) throws Exception { requests.add(request); contexts.add(context); } }); console.init(); console.on(KeyStrokes.a); console.on(KeyStrokes.ENTER); console.on(KeyStrokes.b); console.on(KeyStrokes.ENTER); assertEquals("a", requests.poll()); ShellProcessContext context = contexts.poll(); assertNotNull(context); shell.addProcess(new SyncProcess() { @Override public void run(String request, ShellProcessContext context) throws Exception { contexts.add(context); } }); context.end(ShellResponse.ok()); context = contexts.poll(); assertNotNull(context); context.end(ShellResponse.ok()); }
driver.assertEmpty(); final ShellProcessContext context = contexts.poll(); assertNotNull(context); final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1); Thread t = new Thread() {
driver.assertEmpty(); final ShellProcessContext context = contexts.poll(); assertNotNull(context); final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1); Thread t = new Thread() {
driver.assertEmpty(); final ShellProcessContext context = contexts.poll(); assertNotNull(context); final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1); Thread t = new Thread() {
driver.assertEmpty(); final ShellProcessContext context = contexts.poll(); assertNotNull(context); final ArrayBlockingQueue<String> lines = new ArrayBlockingQueue<String>(1); Thread t = new Thread() {
public void testPrompt() { driver.assertEmpty(); prompt = "% "; console.init(); driver.assertChar('%').assertChar(' ').assertFlush().assertEmpty(); final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1); shell.addProcess(new SyncProcess() { @Override public void run(String request, ShellProcessContext context) throws Exception { contexts.add(context); } }); console.on(KeyStrokes.a); console.on(KeyStrokes.ENTER); driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty(); driver.assertEmpty(); ShellProcessContext context = contexts.poll(); assertNotNull(context); context.end(ShellResponse.ok()); driver.assertCRLF().assertFlush().assertChar('%').assertChar(' ').assertFlush().assertEmpty(); }
/** * Same than {@link #testReadLine1()} but we provide input before the thread read lines effectively * which leads to a simpler test since we need only one thread */ public void testReadLine2() throws Exception { final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1); shell.addProcess(new SyncProcess() { @Override public void run(String request, ShellProcessContext context) throws Exception { contexts.add(context); } }); console.init(); console.on(KeyStrokes.a); console.on(KeyStrokes.ENTER); driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty(); driver.assertEmpty(); final ShellProcessContext context = contexts.poll(); assertNotNull(context); console.on(KeyStrokes.b); console.on(KeyStrokes.ENTER); driver.assertEmpty(); String line = context.readLine("m", true); driver.assertChar('m').assertFlush().assertChar('b').assertFlush().assertCRLF().assertFlush().assertEmpty(); assertEquals("b", line); }