void () { checkCanceledCalled = false; ProgressIndicator indicator = new ProgressIndicatorStub() { @Override public void checkCanceled() throws ProcessCanceledException { checkCanceledCalled = true; if (myFlag) throw new ProcessCanceledException(); } }; ensureCheckCanceledCalled(indicator); }