< prev index next >

test/jdk/java/util/concurrent/tck/FutureTaskTest.java

Print this page
8207003: Miscellaneous changes imported from jsr166 CVS 2018-09
Reviewed-by: martin, chegar

*** 85,103 **** // Check that run and runAndReset have no effect. int savedRunCount = pf.runCount(); pf.run(); pf.runAndReset(); assertEquals(savedRunCount, pf.runCount()); try { ! assertSame(r, f.get()); } catch (CancellationException t) { assertSame(exInfo, CancellationException.class); } catch (ExecutionException t) { assertSame(exInfo, t.getCause()); } catch (Throwable t) { threadUnexpectedException(t); } assertTrue(f.isDone()); } } void checkNotDone(Future<?> f) { --- 85,106 ---- // Check that run and runAndReset have no effect. int savedRunCount = pf.runCount(); pf.run(); pf.runAndReset(); assertEquals(savedRunCount, pf.runCount()); + Object r2 = null; try { ! r2 = f.get(); } catch (CancellationException t) { assertSame(exInfo, CancellationException.class); } catch (ExecutionException t) { assertSame(exInfo, t.getCause()); } catch (Throwable t) { threadUnexpectedException(t); } + if (exInfo == null) + assertSame(r, r2); assertTrue(f.isDone()); } } void checkNotDone(Future<?> f) {
*** 126,143 **** } checkNotDone(f); } } ! <T> void checkCompletedNormally(Future<T> f, T expected) { checkIsDone(f); assertFalse(f.isCancelled()); try { ! assertSame(expected, f.get()); ! assertSame(expected, f.get(randomTimeout(), randomTimeUnit())); } catch (Throwable fail) { threadUnexpectedException(fail); } } void checkCancelled(Future<?> f) { checkIsDone(f); assertTrue(f.isCancelled()); --- 129,149 ---- } checkNotDone(f); } } ! <T> void checkCompletedNormally(Future<T> f, T expectedValue) { checkIsDone(f); assertFalse(f.isCancelled()); + T v1 = null, v2 = null; try { ! v1 = f.get(); ! v2 = f.get(randomTimeout(), randomTimeUnit()); } catch (Throwable fail) { threadUnexpectedException(fail); } + assertSame(expectedValue, v1); + assertSame(expectedValue, v2); } void checkCancelled(Future<?> f) { checkIsDone(f); assertTrue(f.isCancelled());
*** 483,493 **** await(pleaseCancel); try { task.cancel(true); shouldThrow(); ! } catch (SecurityException expected) {} // We failed to deliver the interrupt, but the world retains // its sanity, as if we had done task.cancel(false) assertTrue(task.isCancelled()); assertTrue(task.isDone()); --- 489,499 ---- await(pleaseCancel); try { task.cancel(true); shouldThrow(); ! } catch (SecurityException success) {} // We failed to deliver the interrupt, but the world retains // its sanity, as if we had done task.cancel(false) assertTrue(task.isCancelled()); assertTrue(task.isDone());
< prev index next >