// Plain callable (no special handling) public void testBasicScheduledCallable() throws Exception { TestCallable<String> tc = new TestCallable<String>("X"); assertEquals(0, tc.runs); Future<String> f = schedInline.schedule(tc, 10, TimeUnit.MILLISECONDS); assertEquals("X", f.get()); assertEquals(1, tc.runs); }
public void testShutdownNow() throws Exception { TestRtryCallable<String> tc = new TestRtryCallable<String>("X", 2, 3); schedPooled.schedule(tc, 1, TimeUnit.SECONDS); schedPooled.schedule(tc, 2, TimeUnit.SECONDS); List<Runnable> l = schedPooled.shutdownNow(); assertEquals(2, l.size()); Thread.sleep(100); assertTrue(schedPooled.isTerminated()); }
public void testScheduledFutureSorting() throws Exception { TestRtryCallable<String> tc = new TestRtryCallable<String>("X", 2, 3); ScheduledFuture<String> f1 = schedPooled.schedule(tc, 10, TimeUnit.MILLISECONDS); ScheduledFuture<String> f2 = schedPooled.schedule(tc, 100, TimeUnit.MILLISECONDS); assertTrue(f1.compareTo(f2) < 0); }