public void testCancellation() throws Exception {
final CyclicBarrier syncA = new CyclicBarrier(2);
final CyclicBarrier syncB = new CyclicBarrier(getBarrierSize());
term.publish(TermEvent.readLine("foo"));
shell.addProcess(new SyncProcess() {
@Override
public void run(String request, ShellProcessContext context) throws Exception {
try {
syncA.await();
syncB.await();
}
catch (Exception e) {
e.printStackTrace();
}
}
public void cancel() {
try {
syncB.await();
}
catch (Exception e) {
e.printStackTrace();
}
}
});
syncA.await();
term.publish(TermEvent.brk());
term.publish(TermEvent.readLine("bar"));
shell.addProcess(new SyncProcess() {
public void run(String request, ShellProcessContext context) throws Exception {
context.append("bar");
context.end(ShellResponse.ok());
}
});