void () { DefaultLogger.disableStderrDumping(myRoot); Disposable parent = Disposer.newDisposable(); Disposable first = Disposer.newDisposable(); Disposable last = Disposer.newDisposable(); Disposer.register(parent, first); Disposer.register(parent, () -> { throw new AssertionError("Expected"); }); Disposer.register(parent, () -> { throw new ProcessCanceledException() { @Override public String getMessage() { return "Expected"; } }; }); Disposer.register(parent, last); UsefulTestCase.assertThrows(AssertionError.class, "Expected", () -> Disposer.dispose(parent)); assertTrue(Disposer.isDisposed(parent)); assertTrue(Disposer.isDisposed(first)); assertTrue(Disposer.isDisposed(last)); }