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);
final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1);
Thread t = new Thread() {
@Override
public void run() {
try {
context.readLine("", true);
}
catch (InterruptedException e) {
interrupteds.add(true);
}
catch (Exception e) {
interrupteds.add(false);
}
}
};
t.start();
while (t.getState() != Thread.State.WAITING) {
// Wait until the other thread is waiting
}
context.end(ShellResponse.ok());
boolean interrupted = interrupteds.poll(3, TimeUnit.SECONDS);
assertTrue(interrupted);
}