1 |
|
/* |
2 |
< |
* Written by members of JCP JSR-166 Expert Group and released to the |
3 |
< |
* public domain. Use, modify, and redistribute this code in any way |
4 |
< |
* without acknowledgement. Other contributors include Andrew Wright, |
5 |
< |
* Jeffrey Hayes, Pat Fischer, Mike Judd. |
2 |
> |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
> |
* Expert Group and released to the public domain, as explained at |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
> |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
> |
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
8 |
– |
|
9 |
|
import junit.framework.*; |
10 |
|
import java.util.*; |
11 |
|
import java.util.concurrent.*; |
12 |
+ |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
13 |
|
import java.math.BigInteger; |
14 |
|
import java.security.*; |
15 |
|
|
16 |
< |
public class AbstractExecutorServiceTest extends JSR166TestCase{ |
16 |
> |
public class AbstractExecutorServiceTest extends JSR166TestCase { |
17 |
|
public static void main(String[] args) { |
18 |
< |
junit.textui.TestRunner.run (suite()); |
18 |
> |
junit.textui.TestRunner.run(suite()); |
19 |
|
} |
20 |
|
public static Test suite() { |
21 |
|
return new TestSuite(AbstractExecutorServiceTest.class); |
22 |
|
} |
23 |
|
|
24 |
< |
/** |
24 |
> |
/** |
25 |
|
* A no-frills implementation of AbstractExecutorService, designed |
26 |
|
* to test the submit methods only. |
27 |
|
*/ |
28 |
|
static class DirectExecutorService extends AbstractExecutorService { |
29 |
|
public void execute(Runnable r) { r.run(); } |
30 |
|
public void shutdown() { shutdown = true; } |
31 |
< |
public List<Runnable> shutdownNow() { shutdown = true; return Collections.EMPTY_LIST; } |
31 |
> |
public List<Runnable> shutdownNow() { |
32 |
> |
shutdown = true; |
33 |
> |
return Collections.EMPTY_LIST; |
34 |
> |
} |
35 |
|
public boolean isShutdown() { return shutdown; } |
36 |
|
public boolean isTerminated() { return isShutdown(); } |
37 |
< |
public boolean awaitTermination(long timeout, TimeUnit unit) { return isShutdown(); } |
37 |
> |
public boolean awaitTermination(long timeout, TimeUnit unit) { |
38 |
> |
return isShutdown(); |
39 |
> |
} |
40 |
|
private volatile boolean shutdown = false; |
41 |
|
} |
42 |
|
|
43 |
|
/** |
44 |
< |
* execute of runnable runs it to completion |
44 |
> |
* execute(runnable) runs it to completion |
45 |
|
*/ |
46 |
< |
public void testExecuteRunnable() { |
47 |
< |
try { |
48 |
< |
ExecutorService e = new DirectExecutorService(); |
49 |
< |
TrackedShortRunnable task = new TrackedShortRunnable(); |
50 |
< |
assertFalse(task.done); |
51 |
< |
Future<?> future = e.submit(task); |
52 |
< |
future.get(); |
47 |
< |
assertTrue(task.done); |
48 |
< |
} |
49 |
< |
catch (ExecutionException ex) { |
50 |
< |
unexpectedException(); |
51 |
< |
} |
52 |
< |
catch (InterruptedException ex) { |
53 |
< |
unexpectedException(); |
54 |
< |
} |
46 |
> |
public void testExecuteRunnable() throws Exception { |
47 |
> |
ExecutorService e = new DirectExecutorService(); |
48 |
> |
TrackedShortRunnable task = new TrackedShortRunnable(); |
49 |
> |
assertFalse(task.done); |
50 |
> |
Future<?> future = e.submit(task); |
51 |
> |
future.get(); |
52 |
> |
assertTrue(task.done); |
53 |
|
} |
54 |
|
|
57 |
– |
|
55 |
|
/** |
56 |
< |
* completed submit of callable returns result |
56 |
> |
* Completed submit(callable) returns result |
57 |
|
*/ |
58 |
< |
public void testSubmitCallable() { |
59 |
< |
try { |
60 |
< |
ExecutorService e = new DirectExecutorService(); |
61 |
< |
Future<String> future = e.submit(new StringTask()); |
62 |
< |
String result = future.get(); |
66 |
< |
assertSame(TEST_STRING, result); |
67 |
< |
} |
68 |
< |
catch (ExecutionException ex) { |
69 |
< |
unexpectedException(); |
70 |
< |
} |
71 |
< |
catch (InterruptedException ex) { |
72 |
< |
unexpectedException(); |
73 |
< |
} |
58 |
> |
public void testSubmitCallable() throws Exception { |
59 |
> |
ExecutorService e = new DirectExecutorService(); |
60 |
> |
Future<String> future = e.submit(new StringTask()); |
61 |
> |
String result = future.get(); |
62 |
> |
assertSame(TEST_STRING, result); |
63 |
|
} |
64 |
|
|
65 |
|
/** |
66 |
< |
* completed submit of runnable returns successfully |
66 |
> |
* Completed submit(runnable) returns successfully |
67 |
|
*/ |
68 |
< |
public void testSubmitRunnable() { |
69 |
< |
try { |
70 |
< |
ExecutorService e = new DirectExecutorService(); |
71 |
< |
Future<?> future = e.submit(new NoOpRunnable()); |
72 |
< |
future.get(); |
84 |
< |
assertTrue(future.isDone()); |
85 |
< |
} |
86 |
< |
catch (ExecutionException ex) { |
87 |
< |
unexpectedException(); |
88 |
< |
} |
89 |
< |
catch (InterruptedException ex) { |
90 |
< |
unexpectedException(); |
91 |
< |
} |
68 |
> |
public void testSubmitRunnable() throws Exception { |
69 |
> |
ExecutorService e = new DirectExecutorService(); |
70 |
> |
Future<?> future = e.submit(new NoOpRunnable()); |
71 |
> |
future.get(); |
72 |
> |
assertTrue(future.isDone()); |
73 |
|
} |
74 |
|
|
75 |
|
/** |
76 |
< |
* completed submit of (runnable, result) returns result |
76 |
> |
* Completed submit(runnable, result) returns result |
77 |
|
*/ |
78 |
< |
public void testSubmitRunnable2() { |
79 |
< |
try { |
80 |
< |
ExecutorService e = new DirectExecutorService(); |
81 |
< |
Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING); |
82 |
< |
String result = future.get(); |
102 |
< |
assertSame(TEST_STRING, result); |
103 |
< |
} |
104 |
< |
catch (ExecutionException ex) { |
105 |
< |
unexpectedException(); |
106 |
< |
} |
107 |
< |
catch (InterruptedException ex) { |
108 |
< |
unexpectedException(); |
109 |
< |
} |
78 |
> |
public void testSubmitRunnable2() throws Exception { |
79 |
> |
ExecutorService e = new DirectExecutorService(); |
80 |
> |
Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING); |
81 |
> |
String result = future.get(); |
82 |
> |
assertSame(TEST_STRING, result); |
83 |
|
} |
84 |
|
|
112 |
– |
|
85 |
|
/** |
86 |
< |
* submit of a privileged action runs it to completion |
86 |
> |
* A submitted privileged action runs to completion |
87 |
|
*/ |
88 |
< |
public void testSubmitPrivilegedAction() { |
89 |
< |
Policy savedPolicy = Policy.getPolicy(); |
90 |
< |
AdjustablePolicy policy = new AdjustablePolicy(); |
91 |
< |
policy.addPermission(new RuntimePermission("getContextClassLoader")); |
92 |
< |
policy.addPermission(new RuntimePermission("setContextClassLoader")); |
121 |
< |
Policy.setPolicy(policy); |
122 |
< |
try { |
123 |
< |
ExecutorService e = new DirectExecutorService(); |
124 |
< |
Future future = e.submit(Executors.callable(new PrivilegedAction() { |
88 |
> |
public void testSubmitPrivilegedAction() throws Exception { |
89 |
> |
Runnable r = new CheckedRunnable() { |
90 |
> |
public void realRun() throws Exception { |
91 |
> |
ExecutorService e = new DirectExecutorService(); |
92 |
> |
Future future = e.submit(Executors.callable(new PrivilegedAction() { |
93 |
|
public Object run() { |
94 |
|
return TEST_STRING; |
95 |
|
}})); |
96 |
|
|
97 |
< |
Object result = future.get(); |
98 |
< |
assertSame(TEST_STRING, result); |
99 |
< |
} |
100 |
< |
catch (ExecutionException ex) { |
101 |
< |
unexpectedException(); |
102 |
< |
} |
103 |
< |
catch (InterruptedException ex) { |
136 |
< |
unexpectedException(); |
137 |
< |
} |
138 |
< |
finally { |
139 |
< |
Policy.setPolicy(savedPolicy); |
140 |
< |
} |
97 |
> |
assertSame(TEST_STRING, future.get()); |
98 |
> |
}}; |
99 |
> |
|
100 |
> |
runWithPermissions(r, |
101 |
> |
new RuntimePermission("getClassLoader"), |
102 |
> |
new RuntimePermission("setContextClassLoader"), |
103 |
> |
new RuntimePermission("modifyThread")); |
104 |
|
} |
105 |
|
|
106 |
|
/** |
107 |
< |
* submit of a privileged exception action runs it to completion |
107 |
> |
* A submitted privileged exception action runs to completion |
108 |
|
*/ |
109 |
< |
public void testSubmitPrivilegedExceptionAction() { |
110 |
< |
Policy savedPolicy = Policy.getPolicy(); |
111 |
< |
AdjustablePolicy policy = new AdjustablePolicy(); |
112 |
< |
policy.addPermission(new RuntimePermission("getContextClassLoader")); |
113 |
< |
policy.addPermission(new RuntimePermission("setContextClassLoader")); |
151 |
< |
Policy.setPolicy(policy); |
152 |
< |
try { |
153 |
< |
ExecutorService e = new DirectExecutorService(); |
154 |
< |
Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { |
109 |
> |
public void testSubmitPrivilegedExceptionAction() throws Exception { |
110 |
> |
Runnable r = new CheckedRunnable() { |
111 |
> |
public void realRun() throws Exception { |
112 |
> |
ExecutorService e = new DirectExecutorService(); |
113 |
> |
Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { |
114 |
|
public Object run() { |
115 |
|
return TEST_STRING; |
116 |
|
}})); |
117 |
|
|
118 |
< |
Object result = future.get(); |
119 |
< |
assertSame(TEST_STRING, result); |
120 |
< |
} |
121 |
< |
catch (ExecutionException ex) { |
163 |
< |
unexpectedException(); |
164 |
< |
} |
165 |
< |
catch (InterruptedException ex) { |
166 |
< |
unexpectedException(); |
167 |
< |
} |
168 |
< |
finally { |
169 |
< |
Policy.setPolicy(savedPolicy); |
170 |
< |
} |
118 |
> |
assertSame(TEST_STRING, future.get()); |
119 |
> |
}}; |
120 |
> |
|
121 |
> |
runWithPermissions(r); |
122 |
|
} |
123 |
|
|
124 |
|
/** |
125 |
< |
* submit of a failed privileged exception action reports exception |
125 |
> |
* A submitted failed privileged exception action reports exception |
126 |
|
*/ |
127 |
< |
public void testSubmitFailedPrivilegedExceptionAction() { |
128 |
< |
Policy savedPolicy = Policy.getPolicy(); |
129 |
< |
AdjustablePolicy policy = new AdjustablePolicy(); |
130 |
< |
policy.addPermission(new RuntimePermission("getContextClassLoader")); |
131 |
< |
policy.addPermission(new RuntimePermission("setContextClassLoader")); |
181 |
< |
Policy.setPolicy(policy); |
182 |
< |
try { |
183 |
< |
ExecutorService e = new DirectExecutorService(); |
184 |
< |
Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { |
127 |
> |
public void testSubmitFailedPrivilegedExceptionAction() throws Exception { |
128 |
> |
Runnable r = new CheckedRunnable() { |
129 |
> |
public void realRun() throws Exception { |
130 |
> |
ExecutorService e = new DirectExecutorService(); |
131 |
> |
Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() { |
132 |
|
public Object run() throws Exception { |
133 |
|
throw new IndexOutOfBoundsException(); |
134 |
|
}})); |
135 |
|
|
136 |
< |
Object result = future.get(); |
137 |
< |
shouldThrow(); |
138 |
< |
} |
139 |
< |
catch (ExecutionException success) { |
140 |
< |
} |
141 |
< |
catch (InterruptedException ex) { |
142 |
< |
unexpectedException(); |
143 |
< |
} |
197 |
< |
finally { |
198 |
< |
Policy.setPolicy(savedPolicy); |
199 |
< |
} |
136 |
> |
try { |
137 |
> |
future.get(); |
138 |
> |
shouldThrow(); |
139 |
> |
} catch (ExecutionException success) { |
140 |
> |
assertTrue(success.getCause() instanceof IndexOutOfBoundsException); |
141 |
> |
}}}; |
142 |
> |
|
143 |
> |
runWithPermissions(r); |
144 |
|
} |
145 |
|
|
146 |
|
/** |
147 |
< |
* execute with a null runnable throws NPE |
147 |
> |
* execute(null runnable) throws NPE |
148 |
|
*/ |
149 |
|
public void testExecuteNullRunnable() { |
150 |
|
try { |
151 |
|
ExecutorService e = new DirectExecutorService(); |
152 |
< |
TrackedShortRunnable task = null; |
209 |
< |
Future<?> future = e.submit(task); |
152 |
> |
e.submit((Runnable) null); |
153 |
|
shouldThrow(); |
154 |
< |
} |
212 |
< |
catch (NullPointerException success) { |
213 |
< |
} |
214 |
< |
catch (Exception ex) { |
215 |
< |
unexpectedException(); |
216 |
< |
} |
154 |
> |
} catch (NullPointerException success) {} |
155 |
|
} |
156 |
|
|
219 |
– |
|
157 |
|
/** |
158 |
< |
* submit of a null callable throws NPE |
158 |
> |
* submit(null callable) throws NPE |
159 |
|
*/ |
160 |
|
public void testSubmitNullCallable() { |
161 |
|
try { |
162 |
|
ExecutorService e = new DirectExecutorService(); |
163 |
< |
StringTask t = null; |
227 |
< |
Future<String> future = e.submit(t); |
228 |
< |
shouldThrow(); |
229 |
< |
} |
230 |
< |
catch (NullPointerException success) { |
231 |
< |
} |
232 |
< |
catch (Exception ex) { |
233 |
< |
unexpectedException(); |
234 |
< |
} |
235 |
< |
} |
236 |
< |
|
237 |
< |
/** |
238 |
< |
* submit of Runnable throws RejectedExecutionException if |
239 |
< |
* saturated. |
240 |
< |
*/ |
241 |
< |
public void testExecute1() { |
242 |
< |
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); |
243 |
< |
try { |
244 |
< |
|
245 |
< |
for(int i = 0; i < 5; ++i){ |
246 |
< |
p.submit(new MediumRunnable()); |
247 |
< |
} |
248 |
< |
shouldThrow(); |
249 |
< |
} catch(RejectedExecutionException success){} |
250 |
< |
joinPool(p); |
251 |
< |
} |
252 |
< |
|
253 |
< |
/** |
254 |
< |
* Completed submit of Callable throws RejectedExecutionException |
255 |
< |
* if saturated. |
256 |
< |
*/ |
257 |
< |
public void testExecute2() { |
258 |
< |
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); |
259 |
< |
try { |
260 |
< |
for(int i = 0; i < 5; ++i) { |
261 |
< |
p.submit(new SmallCallable()); |
262 |
< |
} |
163 |
> |
e.submit((Callable) null); |
164 |
|
shouldThrow(); |
165 |
< |
} catch(RejectedExecutionException e){} |
265 |
< |
joinPool(p); |
165 |
> |
} catch (NullPointerException success) {} |
166 |
|
} |
167 |
|
|
268 |
– |
|
168 |
|
/** |
169 |
< |
* blocking on submit of Callable throws InterruptedException if |
271 |
< |
* caller interrupted. |
169 |
> |
* submit(callable).get() throws InterruptedException if interrupted |
170 |
|
*/ |
171 |
< |
public void testInterruptedSubmit() { |
172 |
< |
final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
173 |
< |
Thread t = new Thread(new Runnable() { |
174 |
< |
public void run() { |
175 |
< |
try { |
176 |
< |
p.submit(new Callable<Object>() { |
177 |
< |
public Object call() { |
178 |
< |
try { |
179 |
< |
Thread.sleep(MEDIUM_DELAY_MS); |
180 |
< |
shouldThrow(); |
181 |
< |
} catch(InterruptedException e){ |
182 |
< |
} |
183 |
< |
return null; |
184 |
< |
} |
185 |
< |
}).get(); |
186 |
< |
} catch(InterruptedException success){ |
187 |
< |
} catch(Exception e) { |
188 |
< |
unexpectedException(); |
291 |
< |
} |
292 |
< |
|
293 |
< |
} |
294 |
< |
}); |
295 |
< |
try { |
171 |
> |
public void testInterruptedSubmit() throws InterruptedException { |
172 |
> |
final CountDownLatch submitted = new CountDownLatch(1); |
173 |
> |
final CountDownLatch quittingTime = new CountDownLatch(1); |
174 |
> |
final ExecutorService p |
175 |
> |
= new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, |
176 |
> |
new ArrayBlockingQueue<Runnable>(10)); |
177 |
> |
final Callable<Void> awaiter = new CheckedCallable<Void>() { |
178 |
> |
public Void realCall() throws InterruptedException { |
179 |
> |
quittingTime.await(); |
180 |
> |
return null; |
181 |
> |
}}; |
182 |
> |
try { |
183 |
> |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
184 |
> |
public void realRun() throws Exception { |
185 |
> |
Future<Void> future = p.submit(awaiter); |
186 |
> |
submitted.countDown(); |
187 |
> |
future.get(); |
188 |
> |
}}); |
189 |
|
t.start(); |
190 |
< |
Thread.sleep(SHORT_DELAY_MS); |
298 |
< |
t.interrupt(); |
299 |
< |
} catch(Exception e){ |
300 |
< |
unexpectedException(); |
301 |
< |
} |
302 |
< |
joinPool(p); |
303 |
< |
} |
304 |
< |
|
305 |
< |
/** |
306 |
< |
* get of submit of Callable throws Exception if callable |
307 |
< |
* interrupted |
308 |
< |
*/ |
309 |
< |
public void testSubmitIE() { |
310 |
< |
final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
311 |
< |
|
312 |
< |
final Callable c = new Callable() { |
313 |
< |
public Object call() { |
314 |
< |
try { |
315 |
< |
p.submit(new SmallCallable()).get(); |
316 |
< |
shouldThrow(); |
317 |
< |
} catch(InterruptedException e){} |
318 |
< |
catch(RejectedExecutionException e2){} |
319 |
< |
catch(ExecutionException e3){} |
320 |
< |
return Boolean.TRUE; |
321 |
< |
} |
322 |
< |
}; |
323 |
< |
|
324 |
< |
|
325 |
< |
|
326 |
< |
Thread t = new Thread(new Runnable() { |
327 |
< |
public void run() { |
328 |
< |
try { |
329 |
< |
c.call(); |
330 |
< |
} catch(Exception e){} |
331 |
< |
} |
332 |
< |
}); |
333 |
< |
try { |
334 |
< |
t.start(); |
335 |
< |
Thread.sleep(SHORT_DELAY_MS); |
190 |
> |
submitted.await(); |
191 |
|
t.interrupt(); |
192 |
|
t.join(); |
193 |
< |
} catch(InterruptedException e){ |
194 |
< |
unexpectedException(); |
193 |
> |
} finally { |
194 |
> |
quittingTime.countDown(); |
195 |
> |
joinPool(p); |
196 |
|
} |
341 |
– |
|
342 |
– |
joinPool(p); |
197 |
|
} |
198 |
|
|
199 |
|
/** |
200 |
< |
* completed submit of Callable throws ExecutionException if |
201 |
< |
* callable throws exception |
200 |
> |
* get of submit(callable) throws ExecutionException if callable |
201 |
> |
* throws exception |
202 |
|
*/ |
203 |
< |
public void testSubmitEE() { |
204 |
< |
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
205 |
< |
|
206 |
< |
try { |
207 |
< |
Callable c = new Callable() { |
354 |
< |
public Object call() { |
355 |
< |
int i = 5/0; |
356 |
< |
return Boolean.TRUE; |
357 |
< |
} |
358 |
< |
}; |
203 |
> |
public void testSubmitEE() throws InterruptedException { |
204 |
> |
ThreadPoolExecutor p = |
205 |
> |
new ThreadPoolExecutor(1, 1, |
206 |
> |
60, TimeUnit.SECONDS, |
207 |
> |
new ArrayBlockingQueue<Runnable>(10)); |
208 |
|
|
209 |
< |
for(int i =0; i < 5; i++){ |
210 |
< |
p.submit(c).get(); |
362 |
< |
} |
209 |
> |
Callable c = new Callable() { |
210 |
> |
public Object call() { return 5/0; }}; |
211 |
|
|
212 |
+ |
try { |
213 |
+ |
p.submit(c).get(); |
214 |
|
shouldThrow(); |
215 |
< |
} |
216 |
< |
catch(ExecutionException success){ |
367 |
< |
} catch(Exception e) { |
368 |
< |
unexpectedException(); |
215 |
> |
} catch (ExecutionException success) { |
216 |
> |
assertTrue(success.getCause() instanceof ArithmeticException); |
217 |
|
} |
218 |
|
joinPool(p); |
219 |
|
} |
221 |
|
/** |
222 |
|
* invokeAny(null) throws NPE |
223 |
|
*/ |
224 |
< |
public void testInvokeAny1() { |
224 |
> |
public void testInvokeAny1() throws Exception { |
225 |
|
ExecutorService e = new DirectExecutorService(); |
226 |
|
try { |
227 |
|
e.invokeAny(null); |
228 |
+ |
shouldThrow(); |
229 |
|
} catch (NullPointerException success) { |
381 |
– |
} catch(Exception ex) { |
382 |
– |
unexpectedException(); |
230 |
|
} finally { |
231 |
|
joinPool(e); |
232 |
|
} |
235 |
|
/** |
236 |
|
* invokeAny(empty collection) throws IAE |
237 |
|
*/ |
238 |
< |
public void testInvokeAny2() { |
238 |
> |
public void testInvokeAny2() throws Exception { |
239 |
|
ExecutorService e = new DirectExecutorService(); |
240 |
|
try { |
241 |
|
e.invokeAny(new ArrayList<Callable<String>>()); |
242 |
+ |
shouldThrow(); |
243 |
|
} catch (IllegalArgumentException success) { |
396 |
– |
} catch(Exception ex) { |
397 |
– |
unexpectedException(); |
244 |
|
} finally { |
245 |
|
joinPool(e); |
246 |
|
} |
249 |
|
/** |
250 |
|
* invokeAny(c) throws NPE if c has null elements |
251 |
|
*/ |
252 |
< |
public void testInvokeAny3() { |
252 |
> |
public void testInvokeAny3() throws Exception { |
253 |
|
ExecutorService e = new DirectExecutorService(); |
254 |
+ |
List<Callable<Integer>> l = new ArrayList<Callable<Integer>>(); |
255 |
+ |
l.add(new Callable<Integer>() { |
256 |
+ |
public Integer call() { return 5/0; }}); |
257 |
+ |
l.add(null); |
258 |
|
try { |
409 |
– |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
410 |
– |
l.add(new StringTask()); |
411 |
– |
l.add(null); |
259 |
|
e.invokeAny(l); |
260 |
+ |
shouldThrow(); |
261 |
|
} catch (NullPointerException success) { |
414 |
– |
} catch(Exception ex) { |
415 |
– |
ex.printStackTrace(); |
416 |
– |
unexpectedException(); |
262 |
|
} finally { |
263 |
|
joinPool(e); |
264 |
|
} |
265 |
|
} |
266 |
|
|
267 |
|
/** |
268 |
< |
* invokeAny(c) throws ExecutionException if no task completes |
268 |
> |
* invokeAny(c) throws ExecutionException if no task in c completes |
269 |
|
*/ |
270 |
< |
public void testInvokeAny4() { |
270 |
> |
public void testInvokeAny4() throws InterruptedException { |
271 |
|
ExecutorService e = new DirectExecutorService(); |
272 |
+ |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
273 |
+ |
l.add(new NPETask()); |
274 |
|
try { |
428 |
– |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
429 |
– |
l.add(new NPETask()); |
275 |
|
e.invokeAny(l); |
276 |
< |
} catch(ExecutionException success) { |
277 |
< |
} catch(Exception ex) { |
278 |
< |
unexpectedException(); |
276 |
> |
shouldThrow(); |
277 |
> |
} catch (ExecutionException success) { |
278 |
> |
assertTrue(success.getCause() instanceof NullPointerException); |
279 |
|
} finally { |
280 |
|
joinPool(e); |
281 |
|
} |
282 |
|
} |
283 |
|
|
284 |
|
/** |
285 |
< |
* invokeAny(c) returns result of some task |
285 |
> |
* invokeAny(c) returns result of some task in c if at least one completes |
286 |
|
*/ |
287 |
< |
public void testInvokeAny5() { |
287 |
> |
public void testInvokeAny5() throws Exception { |
288 |
|
ExecutorService e = new DirectExecutorService(); |
289 |
|
try { |
290 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
290 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
291 |
|
l.add(new StringTask()); |
292 |
|
l.add(new StringTask()); |
293 |
|
String result = e.invokeAny(l); |
294 |
|
assertSame(TEST_STRING, result); |
450 |
– |
} catch (ExecutionException success) { |
451 |
– |
} catch(Exception ex) { |
452 |
– |
unexpectedException(); |
295 |
|
} finally { |
296 |
|
joinPool(e); |
297 |
|
} |
300 |
|
/** |
301 |
|
* invokeAll(null) throws NPE |
302 |
|
*/ |
303 |
< |
public void testInvokeAll1() { |
303 |
> |
public void testInvokeAll1() throws InterruptedException { |
304 |
|
ExecutorService e = new DirectExecutorService(); |
305 |
|
try { |
306 |
|
e.invokeAll(null); |
307 |
+ |
shouldThrow(); |
308 |
|
} catch (NullPointerException success) { |
466 |
– |
} catch(Exception ex) { |
467 |
– |
unexpectedException(); |
309 |
|
} finally { |
310 |
|
joinPool(e); |
311 |
|
} |
314 |
|
/** |
315 |
|
* invokeAll(empty collection) returns empty collection |
316 |
|
*/ |
317 |
< |
public void testInvokeAll2() { |
317 |
> |
public void testInvokeAll2() throws InterruptedException { |
318 |
|
ExecutorService e = new DirectExecutorService(); |
319 |
|
try { |
320 |
|
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>()); |
321 |
|
assertTrue(r.isEmpty()); |
481 |
– |
} catch(Exception ex) { |
482 |
– |
unexpectedException(); |
322 |
|
} finally { |
323 |
|
joinPool(e); |
324 |
|
} |
327 |
|
/** |
328 |
|
* invokeAll(c) throws NPE if c has null elements |
329 |
|
*/ |
330 |
< |
public void testInvokeAll3() { |
330 |
> |
public void testInvokeAll3() throws InterruptedException { |
331 |
|
ExecutorService e = new DirectExecutorService(); |
332 |
+ |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
333 |
+ |
l.add(new StringTask()); |
334 |
+ |
l.add(null); |
335 |
|
try { |
494 |
– |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
495 |
– |
l.add(new StringTask()); |
496 |
– |
l.add(null); |
336 |
|
e.invokeAll(l); |
337 |
+ |
shouldThrow(); |
338 |
|
} catch (NullPointerException success) { |
499 |
– |
} catch(Exception ex) { |
500 |
– |
unexpectedException(); |
339 |
|
} finally { |
340 |
|
joinPool(e); |
341 |
|
} |
342 |
|
} |
343 |
|
|
344 |
|
/** |
345 |
< |
* get of element of invokeAll(c) throws exception on failed task |
345 |
> |
* get of returned element of invokeAll(c) throws exception on failed task |
346 |
|
*/ |
347 |
< |
public void testInvokeAll4() { |
347 |
> |
public void testInvokeAll4() throws Exception { |
348 |
|
ExecutorService e = new DirectExecutorService(); |
349 |
|
try { |
350 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
350 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
351 |
|
l.add(new NPETask()); |
352 |
< |
List<Future<String>> result = e.invokeAll(l); |
353 |
< |
assertEquals(1, result.size()); |
354 |
< |
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
355 |
< |
it.next().get(); |
356 |
< |
} catch(ExecutionException success) { |
357 |
< |
} catch(Exception ex) { |
358 |
< |
unexpectedException(); |
352 |
> |
List<Future<String>> futures = e.invokeAll(l); |
353 |
> |
assertEquals(1, futures.size()); |
354 |
> |
try { |
355 |
> |
futures.get(0).get(); |
356 |
> |
shouldThrow(); |
357 |
> |
} catch (ExecutionException success) { |
358 |
> |
assertTrue(success.getCause() instanceof NullPointerException); |
359 |
> |
} |
360 |
|
} finally { |
361 |
|
joinPool(e); |
362 |
|
} |
363 |
|
} |
364 |
|
|
365 |
|
/** |
366 |
< |
* invokeAll(c) returns results of all completed tasks |
366 |
> |
* invokeAll(c) returns results of all completed tasks in c |
367 |
|
*/ |
368 |
< |
public void testInvokeAll5() { |
368 |
> |
public void testInvokeAll5() throws Exception { |
369 |
|
ExecutorService e = new DirectExecutorService(); |
370 |
|
try { |
371 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
371 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
372 |
|
l.add(new StringTask()); |
373 |
|
l.add(new StringTask()); |
374 |
< |
List<Future<String>> result = e.invokeAll(l); |
375 |
< |
assertEquals(2, result.size()); |
376 |
< |
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
377 |
< |
assertSame(TEST_STRING, it.next().get()); |
539 |
< |
} catch (ExecutionException success) { |
540 |
< |
} catch(Exception ex) { |
541 |
< |
unexpectedException(); |
374 |
> |
List<Future<String>> futures = e.invokeAll(l); |
375 |
> |
assertEquals(2, futures.size()); |
376 |
> |
for (Future<String> future : futures) |
377 |
> |
assertSame(TEST_STRING, future.get()); |
378 |
|
} finally { |
379 |
|
joinPool(e); |
380 |
|
} |
381 |
|
} |
382 |
|
|
547 |
– |
|
383 |
|
/** |
384 |
|
* timed invokeAny(null) throws NPE |
385 |
|
*/ |
386 |
< |
public void testTimedInvokeAny1() { |
386 |
> |
public void testTimedInvokeAny1() throws Exception { |
387 |
|
ExecutorService e = new DirectExecutorService(); |
388 |
|
try { |
389 |
< |
e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
389 |
> |
e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS); |
390 |
> |
shouldThrow(); |
391 |
|
} catch (NullPointerException success) { |
556 |
– |
} catch(Exception ex) { |
557 |
– |
unexpectedException(); |
392 |
|
} finally { |
393 |
|
joinPool(e); |
394 |
|
} |
395 |
|
} |
396 |
|
|
397 |
|
/** |
398 |
< |
* timed invokeAny(,,null) throws NPE |
398 |
> |
* timed invokeAny(null time unit) throws NPE |
399 |
|
*/ |
400 |
< |
public void testTimedInvokeAnyNullTimeUnit() { |
400 |
> |
public void testTimedInvokeAnyNullTimeUnit() throws Exception { |
401 |
|
ExecutorService e = new DirectExecutorService(); |
402 |
+ |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
403 |
+ |
l.add(new StringTask()); |
404 |
|
try { |
569 |
– |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
570 |
– |
l.add(new StringTask()); |
405 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, null); |
406 |
+ |
shouldThrow(); |
407 |
|
} catch (NullPointerException success) { |
573 |
– |
} catch(Exception ex) { |
574 |
– |
unexpectedException(); |
408 |
|
} finally { |
409 |
|
joinPool(e); |
410 |
|
} |
413 |
|
/** |
414 |
|
* timed invokeAny(empty collection) throws IAE |
415 |
|
*/ |
416 |
< |
public void testTimedInvokeAny2() { |
416 |
> |
public void testTimedInvokeAny2() throws Exception { |
417 |
|
ExecutorService e = new DirectExecutorService(); |
418 |
|
try { |
419 |
< |
e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
419 |
> |
e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS); |
420 |
> |
shouldThrow(); |
421 |
|
} catch (IllegalArgumentException success) { |
588 |
– |
} catch(Exception ex) { |
589 |
– |
unexpectedException(); |
422 |
|
} finally { |
423 |
|
joinPool(e); |
424 |
|
} |
427 |
|
/** |
428 |
|
* timed invokeAny(c) throws NPE if c has null elements |
429 |
|
*/ |
430 |
< |
public void testTimedInvokeAny3() { |
430 |
> |
public void testTimedInvokeAny3() throws Exception { |
431 |
|
ExecutorService e = new DirectExecutorService(); |
432 |
+ |
List<Callable<Integer>> l = new ArrayList<Callable<Integer>>(); |
433 |
+ |
l.add(new Callable<Integer>() { |
434 |
+ |
public Integer call() { return 5/0; }}); |
435 |
+ |
l.add(null); |
436 |
|
try { |
437 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
438 |
< |
l.add(new StringTask()); |
603 |
< |
l.add(null); |
604 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
437 |
> |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
438 |
> |
shouldThrow(); |
439 |
|
} catch (NullPointerException success) { |
606 |
– |
} catch(Exception ex) { |
607 |
– |
ex.printStackTrace(); |
608 |
– |
unexpectedException(); |
440 |
|
} finally { |
441 |
|
joinPool(e); |
442 |
|
} |
445 |
|
/** |
446 |
|
* timed invokeAny(c) throws ExecutionException if no task completes |
447 |
|
*/ |
448 |
< |
public void testTimedInvokeAny4() { |
448 |
> |
public void testTimedInvokeAny4() throws Exception { |
449 |
|
ExecutorService e = new DirectExecutorService(); |
450 |
+ |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
451 |
+ |
l.add(new NPETask()); |
452 |
|
try { |
453 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
454 |
< |
l.add(new NPETask()); |
455 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
456 |
< |
} catch(ExecutionException success) { |
624 |
< |
} catch(Exception ex) { |
625 |
< |
unexpectedException(); |
453 |
> |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
454 |
> |
shouldThrow(); |
455 |
> |
} catch (ExecutionException success) { |
456 |
> |
assertTrue(success.getCause() instanceof NullPointerException); |
457 |
|
} finally { |
458 |
|
joinPool(e); |
459 |
|
} |
460 |
|
} |
461 |
|
|
462 |
|
/** |
463 |
< |
* timed invokeAny(c) returns result of some task |
463 |
> |
* timed invokeAny(c) returns result of some task in c |
464 |
|
*/ |
465 |
< |
public void testTimedInvokeAny5() { |
465 |
> |
public void testTimedInvokeAny5() throws Exception { |
466 |
|
ExecutorService e = new DirectExecutorService(); |
467 |
|
try { |
468 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
468 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
469 |
|
l.add(new StringTask()); |
470 |
|
l.add(new StringTask()); |
471 |
< |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
471 |
> |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
472 |
|
assertSame(TEST_STRING, result); |
642 |
– |
} catch (ExecutionException success) { |
643 |
– |
} catch(Exception ex) { |
644 |
– |
unexpectedException(); |
473 |
|
} finally { |
474 |
|
joinPool(e); |
475 |
|
} |
478 |
|
/** |
479 |
|
* timed invokeAll(null) throws NPE |
480 |
|
*/ |
481 |
< |
public void testTimedInvokeAll1() { |
481 |
> |
public void testTimedInvokeAll1() throws InterruptedException { |
482 |
|
ExecutorService e = new DirectExecutorService(); |
483 |
|
try { |
484 |
< |
e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
484 |
> |
e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS); |
485 |
> |
shouldThrow(); |
486 |
|
} catch (NullPointerException success) { |
658 |
– |
} catch(Exception ex) { |
659 |
– |
unexpectedException(); |
487 |
|
} finally { |
488 |
|
joinPool(e); |
489 |
|
} |
490 |
|
} |
491 |
|
|
492 |
|
/** |
493 |
< |
* timed invokeAll(,,null) throws NPE |
493 |
> |
* timed invokeAll(null time unit) throws NPE |
494 |
|
*/ |
495 |
< |
public void testTimedInvokeAllNullTimeUnit() { |
495 |
> |
public void testTimedInvokeAllNullTimeUnit() throws InterruptedException { |
496 |
|
ExecutorService e = new DirectExecutorService(); |
497 |
+ |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
498 |
+ |
l.add(new StringTask()); |
499 |
|
try { |
671 |
– |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
672 |
– |
l.add(new StringTask()); |
500 |
|
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
501 |
+ |
shouldThrow(); |
502 |
|
} catch (NullPointerException success) { |
675 |
– |
} catch(Exception ex) { |
676 |
– |
unexpectedException(); |
503 |
|
} finally { |
504 |
|
joinPool(e); |
505 |
|
} |
508 |
|
/** |
509 |
|
* timed invokeAll(empty collection) returns empty collection |
510 |
|
*/ |
511 |
< |
public void testTimedInvokeAll2() { |
511 |
> |
public void testTimedInvokeAll2() throws InterruptedException { |
512 |
|
ExecutorService e = new DirectExecutorService(); |
513 |
|
try { |
514 |
< |
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
514 |
> |
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS); |
515 |
|
assertTrue(r.isEmpty()); |
690 |
– |
} catch(Exception ex) { |
691 |
– |
unexpectedException(); |
516 |
|
} finally { |
517 |
|
joinPool(e); |
518 |
|
} |
521 |
|
/** |
522 |
|
* timed invokeAll(c) throws NPE if c has null elements |
523 |
|
*/ |
524 |
< |
public void testTimedInvokeAll3() { |
524 |
> |
public void testTimedInvokeAll3() throws InterruptedException { |
525 |
|
ExecutorService e = new DirectExecutorService(); |
526 |
+ |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
527 |
+ |
l.add(new StringTask()); |
528 |
+ |
l.add(null); |
529 |
|
try { |
530 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
531 |
< |
l.add(new StringTask()); |
705 |
< |
l.add(null); |
706 |
< |
e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
530 |
> |
e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
531 |
> |
shouldThrow(); |
532 |
|
} catch (NullPointerException success) { |
708 |
– |
} catch(Exception ex) { |
709 |
– |
unexpectedException(); |
533 |
|
} finally { |
534 |
|
joinPool(e); |
535 |
|
} |
536 |
|
} |
537 |
|
|
538 |
|
/** |
539 |
< |
* get of element of invokeAll(c) throws exception on failed task |
539 |
> |
* get of returned element of invokeAll(c) throws exception on failed task |
540 |
|
*/ |
541 |
< |
public void testTimedInvokeAll4() { |
541 |
> |
public void testTimedInvokeAll4() throws Exception { |
542 |
|
ExecutorService e = new DirectExecutorService(); |
543 |
|
try { |
544 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
544 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
545 |
|
l.add(new NPETask()); |
546 |
< |
List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
547 |
< |
assertEquals(1, result.size()); |
548 |
< |
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
549 |
< |
it.next().get(); |
550 |
< |
} catch(ExecutionException success) { |
551 |
< |
} catch(Exception ex) { |
552 |
< |
unexpectedException(); |
546 |
> |
List<Future<String>> futures = |
547 |
> |
e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
548 |
> |
assertEquals(1, futures.size()); |
549 |
> |
try { |
550 |
> |
futures.get(0).get(); |
551 |
> |
shouldThrow(); |
552 |
> |
} catch (ExecutionException success) { |
553 |
> |
assertTrue(success.getCause() instanceof NullPointerException); |
554 |
> |
} |
555 |
|
} finally { |
556 |
|
joinPool(e); |
557 |
|
} |
558 |
|
} |
559 |
|
|
560 |
|
/** |
561 |
< |
* timed invokeAll(c) returns results of all completed tasks |
561 |
> |
* timed invokeAll(c) returns results of all completed tasks in c |
562 |
|
*/ |
563 |
< |
public void testTimedInvokeAll5() { |
563 |
> |
public void testTimedInvokeAll5() throws Exception { |
564 |
|
ExecutorService e = new DirectExecutorService(); |
565 |
|
try { |
566 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
566 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
567 |
|
l.add(new StringTask()); |
568 |
|
l.add(new StringTask()); |
569 |
< |
List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
570 |
< |
assertEquals(2, result.size()); |
571 |
< |
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
572 |
< |
assertSame(TEST_STRING, it.next().get()); |
573 |
< |
} catch (ExecutionException success) { |
749 |
< |
} catch(Exception ex) { |
750 |
< |
unexpectedException(); |
569 |
> |
List<Future<String>> futures = |
570 |
> |
e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
571 |
> |
assertEquals(2, futures.size()); |
572 |
> |
for (Future<String> future : futures) |
573 |
> |
assertSame(TEST_STRING, future.get()); |
574 |
|
} finally { |
575 |
|
joinPool(e); |
576 |
|
} |
577 |
|
} |
578 |
|
|
579 |
|
/** |
580 |
< |
* timed invokeAll(c) cancels tasks not completed by timeout |
580 |
> |
* timed invokeAll cancels tasks not completed by timeout |
581 |
|
*/ |
582 |
< |
public void testTimedInvokeAll6() { |
583 |
< |
ExecutorService e = Executors.newCachedThreadPool(); |
582 |
> |
public void testTimedInvokeAll6() throws InterruptedException { |
583 |
> |
ExecutorService e = new DirectExecutorService(); |
584 |
|
try { |
585 |
< |
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
585 |
> |
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
586 |
> |
l.add(new StringTask()); |
587 |
> |
l.add(Executors.callable(possiblyInterruptedRunnable(2 * SHORT_DELAY_MS), TEST_STRING)); |
588 |
|
l.add(new StringTask()); |
589 |
< |
l.add(Executors.callable(new MediumInterruptedRunnable(), TEST_STRING)); |
590 |
< |
List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
591 |
< |
assertEquals(2, result.size()); |
592 |
< |
Iterator<Future<String>> it = result.iterator(); |
589 |
> |
List<Future<String>> futures = |
590 |
> |
e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS); |
591 |
> |
assertEquals(3, futures.size()); |
592 |
> |
Iterator<Future<String>> it = futures.iterator(); |
593 |
|
Future<String> f1 = it.next(); |
594 |
|
Future<String> f2 = it.next(); |
595 |
+ |
Future<String> f3 = it.next(); |
596 |
|
assertTrue(f1.isDone()); |
597 |
|
assertFalse(f1.isCancelled()); |
598 |
|
assertTrue(f2.isDone()); |
599 |
< |
assertTrue(f2.isCancelled()); |
600 |
< |
} catch(Exception ex) { |
601 |
< |
unexpectedException(); |
599 |
> |
assertFalse(f2.isCancelled()); |
600 |
> |
assertTrue(f3.isDone()); |
601 |
> |
assertTrue(f3.isCancelled()); |
602 |
|
} finally { |
603 |
|
joinPool(e); |
604 |
|
} |