ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AbstractExecutorServiceTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.27 by jsr166, Sat Oct 9 19:30:34 2010 UTC vs.
Revision 1.28 by jsr166, Mon Oct 11 07:21:32 2010 UTC

# Line 170 | Line 170 | public class AbstractExecutorServiceTest
170      }
171  
172      /**
173     * submit(runnable) throws RejectedExecutionException if
174     * executor is saturated.
175     */
176    public void testExecute1() {
177        ThreadPoolExecutor p =
178            new ThreadPoolExecutor(1, 1,
179                                   60, TimeUnit.SECONDS,
180                                   new ArrayBlockingQueue<Runnable>(1));
181        try {
182            for (int i = 0; i < 2; ++i)
183                p.submit(new MediumRunnable());
184            for (int i = 0; i < 2; ++i) {
185                try {
186                    p.submit(new MediumRunnable());
187                    shouldThrow();
188                } catch (RejectedExecutionException success) {}
189            }
190        } finally {
191            joinPool(p);
192        }
193    }
194
195    /**
196     * submit(callable) throws RejectedExecutionException
197     * if executor is saturated.
198     */
199    public void testExecute2() {
200        ThreadPoolExecutor p =
201            new ThreadPoolExecutor(1, 1,
202                                   60, TimeUnit.SECONDS,
203                                   new ArrayBlockingQueue<Runnable>(1));
204        try {
205            for (int i = 0; i < 2; ++i)
206                p.submit(new MediumRunnable());
207            for (int i = 0; i < 2; ++i) {
208                try {
209                    p.submit(new SmallCallable());
210                    shouldThrow();
211                } catch (RejectedExecutionException success) {}
212            }
213        } finally {
214            joinPool(p);
215        }
216    }
217
218
219    /**
173       * submit(callable).get() throws InterruptedException if interrupted
174       */
175      public void testInterruptedSubmit() throws InterruptedException {
# Line 248 | Line 201 | public class AbstractExecutorServiceTest
201      }
202  
203      /**
251     * get of submitted callable throws InterruptedException if callable
252     * interrupted
253     */
254    public void testSubmitIE() throws InterruptedException {
255        final ThreadPoolExecutor p =
256            new ThreadPoolExecutor(1, 1,
257                                   60, TimeUnit.SECONDS,
258                                   new ArrayBlockingQueue<Runnable>(10));
259
260        Thread t = new Thread(new CheckedInterruptedRunnable() {
261            public void realRun() throws Exception {
262                p.submit(new SmallCallable()).get();
263            }});
264
265        t.start();
266        Thread.sleep(SHORT_DELAY_MS);
267        t.interrupt();
268        t.join();
269        joinPool(p);
270    }
271
272    /**
204       * get of submit(callable) throws ExecutionException if callable
205       * throws exception
206       */
# Line 294 | Line 225 | public class AbstractExecutorServiceTest
225      /**
226       * invokeAny(null) throws NPE
227       */
228 <    public void testInvokeAny1()
298 <        throws InterruptedException, ExecutionException {
228 >    public void testInvokeAny1() throws Exception {
229          ExecutorService e = new DirectExecutorService();
230          try {
231              e.invokeAny(null);
# Line 309 | Line 239 | public class AbstractExecutorServiceTest
239      /**
240       * invokeAny(empty collection) throws IAE
241       */
242 <    public void testInvokeAny2()
313 <        throws InterruptedException, ExecutionException {
242 >    public void testInvokeAny2() throws Exception {
243          ExecutorService e = new DirectExecutorService();
244          try {
245              e.invokeAny(new ArrayList<Callable<String>>());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines