private void doTest(String command) {
interruptDoCancel = false;
interruptInterrupted = false;
//
final BaseProcessContext ctx = create(command);
final AtomicReference<Boolean> interrupted = new AtomicReference<Boolean>();
Thread t = new Thread() {
@Override
public void run() {
try {
ctx.execute();
}
finally {
interrupted.set(isInterrupted());
}
}
};
t.start();
//
synchronized (interrupLock) {
if (!interruptDoCancel) {
try {
interrupLock.wait(10 * 1000);
}
catch (InterruptedException e) {
throw AbstractTestCase.failure(e);
}
}
}
// We should have been interrupted
assertTrue(interruptDoCancel);
//
ctx.cancel();
ShellResponse resp = ctx.getResponse();
assertEquals(ShellResponse.Cancelled.class, resp.getClass());
assertTrue(interruptInterrupted);
while (true) {
Boolean b = interrupted.get();
if (b != null) {