void () { DefaultLogger.disableStderrDumping(getTestRootDisposable()); CancellationCheck cancellation = new CancellationCheck(1000); try { cancellation.withCancellationCheck(() -> { Clock.setTime(1L); myProgressIndicator.checkCanceled(); Clock.setTime(10L); myProgressIndicator.checkCanceled(); Clock.setTime(1000L); myProgressIndicator.checkCanceled(); Clock.setTime(10000L); myProgressIndicator.checkCanceled(); return null; }); fail("This code should not be executed"); } catch (AssertionError e) { Throwable cancellationFailure = e.getCause(); if(cancellationFailure == null) throw e; assertTrue(cancellationFailure.getMessage().startsWith("AWT-EventQueue-0 last checkCanceled was 9000 ms ago")); Throwable lastRecordedCheck = cancellationFailure.getCause(); assertEquals("previous check cancellation call", lastRecordedCheck.getMessage()); } }