1097 |
|
public void testTimedInvokeAny4() throws Exception { |
1098 |
|
final ExecutorService e = new CustomExecutor(2); |
1099 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1100 |
+ |
long startTime = System.nanoTime(); |
1101 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1102 |
|
l.add(new NPETask()); |
1103 |
|
try { |
1104 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1104 |
> |
e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1105 |
|
shouldThrow(); |
1106 |
|
} catch (ExecutionException success) { |
1107 |
|
assertTrue(success.getCause() instanceof NullPointerException); |
1108 |
|
} |
1109 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1110 |
|
} |
1111 |
|
} |
1112 |
|
|
1116 |
|
public void testTimedInvokeAny5() throws Exception { |
1117 |
|
final ExecutorService e = new CustomExecutor(2); |
1118 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1119 |
+ |
long startTime = System.nanoTime(); |
1120 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1121 |
|
l.add(new StringTask()); |
1122 |
|
l.add(new StringTask()); |
1123 |
< |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1123 |
> |
String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1124 |
|
assertSame(TEST_STRING, result); |
1125 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1126 |
|
} |
1127 |
|
} |
1128 |
|
|