final int count = 10000; @Cleanup val proc = new SequentialProcessor(executorService()); val running = new AtomicBoolean(false); val previousRun = new AtomicReference<CompletableFuture<Integer>>();
/** * Tests the ability to cancel ongoing tasks when the processor is closed. */ @Test public void testClose() { @Cleanup val proc = new SequentialProcessor(executorService()); val toRun = new CompletableFuture<Integer>(); val result = proc.add(() -> toRun); proc.close(); AssertExtensions.assertThrows( "Task not cancelled.", result::join, ex -> ex instanceof ObjectClosedException); Assert.assertFalse("Not expecting inner blocker task to be done.", toRun.isDone()); } }