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

Comparing jsr166/src/test/tck/DelayQueueTest.java (file contents):
Revision 1.19 by jsr166, Sat Nov 21 02:33:20 2009 UTC vs.
Revision 1.23 by jsr166, Sat Nov 21 21:00:34 2009 UTC

# Line 144 | Line 144 | public class DelayQueueTest extends JSR1
144          try {
145              DelayQueue q = new DelayQueue(null);
146              shouldThrow();
147 <        }
148 <        catch (NullPointerException success) {}
147 >        } catch (NullPointerException success) {}
148      }
149  
150      /**
# Line 156 | Line 155 | public class DelayQueueTest extends JSR1
155              PDelay[] ints = new PDelay[SIZE];
156              DelayQueue q = new DelayQueue(Arrays.asList(ints));
157              shouldThrow();
158 <        }
160 <        catch (NullPointerException success) {}
158 >        } catch (NullPointerException success) {}
159      }
160  
161      /**
# Line 170 | Line 168 | public class DelayQueueTest extends JSR1
168                  ints[i] = new PDelay(i);
169              DelayQueue q = new DelayQueue(Arrays.asList(ints));
170              shouldThrow();
171 <        }
174 <        catch (NullPointerException success) {}
171 >        } catch (NullPointerException success) {}
172      }
173  
174      /**
175       * Queue contains all elements of collection used to initialize
176       */
177      public void testConstructor6() {
178 <        try {
179 <            PDelay[] ints = new PDelay[SIZE];
180 <            for (int i = 0; i < SIZE; ++i)
181 <                ints[i] = new PDelay(i);
182 <            DelayQueue q = new DelayQueue(Arrays.asList(ints));
183 <            for (int i = 0; i < SIZE; ++i)
187 <                assertEquals(ints[i], q.poll());
188 <        }
189 <        finally {}
178 >        PDelay[] ints = new PDelay[SIZE];
179 >        for (int i = 0; i < SIZE; ++i)
180 >            ints[i] = new PDelay(i);
181 >        DelayQueue q = new DelayQueue(Arrays.asList(ints));
182 >        for (int i = 0; i < SIZE; ++i)
183 >            assertEquals(ints[i], q.poll());
184      }
185  
186      /**
# Line 230 | Line 224 | public class DelayQueueTest extends JSR1
224              DelayQueue q = new DelayQueue();
225              q.offer(null);
226              shouldThrow();
227 <        } catch (NullPointerException success) { }
227 >        } catch (NullPointerException success) {}
228      }
229  
230      /**
# Line 241 | Line 235 | public class DelayQueueTest extends JSR1
235              DelayQueue q = new DelayQueue();
236              q.add(null);
237              shouldThrow();
238 <        } catch (NullPointerException success) { }
238 >        } catch (NullPointerException success) {}
239      }
240  
241      /**
# Line 272 | Line 266 | public class DelayQueueTest extends JSR1
266              DelayQueue q = new DelayQueue();
267              q.addAll(null);
268              shouldThrow();
269 <        }
276 <        catch (NullPointerException success) {}
269 >        } catch (NullPointerException success) {}
270      }
271  
272  
# Line 285 | Line 278 | public class DelayQueueTest extends JSR1
278              DelayQueue q = populatedQueue(SIZE);
279              q.addAll(q);
280              shouldThrow();
281 <        }
289 <        catch (IllegalArgumentException success) {}
281 >        } catch (IllegalArgumentException success) {}
282      }
283  
284      /**
# Line 298 | Line 290 | public class DelayQueueTest extends JSR1
290              PDelay[] ints = new PDelay[SIZE];
291              q.addAll(Arrays.asList(ints));
292              shouldThrow();
293 <        }
302 <        catch (NullPointerException success) {}
293 >        } catch (NullPointerException success) {}
294      }
295      /**
296       * addAll of a collection with any null elements throws NPE after
# Line 313 | Line 304 | public class DelayQueueTest extends JSR1
304                  ints[i] = new PDelay(i);
305              q.addAll(Arrays.asList(ints));
306              shouldThrow();
307 <        }
317 <        catch (NullPointerException success) {}
307 >        } catch (NullPointerException success) {}
308      }
309  
310      /**
311       * Queue contains all elements of successful addAll
312       */
313      public void testAddAll5() {
314 <        try {
315 <            PDelay[] empty = new PDelay[0];
316 <            PDelay[] ints = new PDelay[SIZE];
317 <            for (int i = SIZE-1; i >= 0; --i)
318 <                ints[i] = new PDelay(i);
319 <            DelayQueue q = new DelayQueue();
320 <            assertFalse(q.addAll(Arrays.asList(empty)));
321 <            assertTrue(q.addAll(Arrays.asList(ints)));
322 <            for (int i = 0; i < SIZE; ++i)
333 <                assertEquals(ints[i], q.poll());
334 <        }
335 <        finally {}
314 >        PDelay[] empty = new PDelay[0];
315 >        PDelay[] ints = new PDelay[SIZE];
316 >        for (int i = SIZE-1; i >= 0; --i)
317 >            ints[i] = new PDelay(i);
318 >        DelayQueue q = new DelayQueue();
319 >        assertFalse(q.addAll(Arrays.asList(empty)));
320 >        assertTrue(q.addAll(Arrays.asList(ints)));
321 >        for (int i = 0; i < SIZE; ++i)
322 >            assertEquals(ints[i], q.poll());
323      }
324  
325      /**
# Line 343 | Line 330 | public class DelayQueueTest extends JSR1
330              DelayQueue q = new DelayQueue();
331              q.put(null);
332              shouldThrow();
333 <        }
347 <        catch (NullPointerException success) {
348 <        }
333 >        } catch (NullPointerException success) {}
334       }
335  
336      /**
337       * all elements successfully put are contained
338       */
339       public void testPut() {
340 <         try {
341 <             DelayQueue q = new DelayQueue();
342 <             for (int i = 0; i < SIZE; ++i) {
343 <                 PDelay I = new PDelay(i);
344 <                 q.put(I);
360 <                 assertTrue(q.contains(I));
361 <             }
362 <             assertEquals(SIZE, q.size());
340 >         DelayQueue q = new DelayQueue();
341 >         for (int i = 0; i < SIZE; ++i) {
342 >             PDelay I = new PDelay(i);
343 >             q.put(I);
344 >             assertTrue(q.contains(I));
345           }
346 <         finally {
365 <        }
346 >         assertEquals(SIZE, q.size());
347      }
348  
349      /**
350       * put doesn't block waiting for take
351       */
352 <    public void testPutWithTake() {
352 >    public void testPutWithTake() throws InterruptedException {
353          final DelayQueue q = new DelayQueue();
354 <        Thread t = new Thread(new Runnable() {
355 <                public void run() {
356 <                    int added = 0;
357 <                    try {
358 <                        q.put(new PDelay(0));
359 <                        ++added;
360 <                        q.put(new PDelay(0));
361 <                        ++added;
362 <                        q.put(new PDelay(0));
363 <                        ++added;
364 <                        q.put(new PDelay(0));
365 <                        ++added;
366 <                        threadAssertTrue(added == 4);
386 <                    } finally {
387 <                    }
388 <                }
389 <            });
390 <        try {
391 <            t.start();
392 <            Thread.sleep(SHORT_DELAY_MS);
393 <            q.take();
394 <            t.interrupt();
395 <            t.join();
396 <        } catch (Exception e) {
397 <            unexpectedException();
398 <        }
354 >        Thread t = new Thread(new CheckedRunnable() {
355 >            public void realRun() {
356 >                q.put(new PDelay(0));
357 >                q.put(new PDelay(0));
358 >                q.put(new PDelay(0));
359 >                q.put(new PDelay(0));
360 >            }});
361 >
362 >        t.start();
363 >        Thread.sleep(SHORT_DELAY_MS);
364 >        q.take();
365 >        t.interrupt();
366 >        t.join();
367      }
368  
369      /**
370       * timed offer does not time out
371       */
372 <    public void testTimedOffer() {
372 >    public void testTimedOffer() throws InterruptedException {
373          final DelayQueue q = new DelayQueue();
374 <        Thread t = new Thread(new Runnable() {
375 <                public void run() {
376 <                    try {
377 <                        q.put(new PDelay(0));
378 <                        q.put(new PDelay(0));
379 <                        threadAssertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, MILLISECONDS));
380 <                        threadAssertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, MILLISECONDS));
413 <                    } finally { }
414 <                }
415 <            });
374 >        Thread t = new Thread(new CheckedRunnable() {
375 >            public void realRun() throws InterruptedException {
376 >                q.put(new PDelay(0));
377 >                q.put(new PDelay(0));
378 >                threadAssertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, MILLISECONDS));
379 >                threadAssertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, MILLISECONDS));
380 >            }});
381  
382 <        try {
383 <            t.start();
384 <            Thread.sleep(SMALL_DELAY_MS);
385 <            t.interrupt();
421 <            t.join();
422 <        } catch (Exception e) {
423 <            unexpectedException();
424 <        }
382 >        t.start();
383 >        Thread.sleep(SMALL_DELAY_MS);
384 >        t.interrupt();
385 >        t.join();
386      }
387  
388      /**
389       * take retrieves elements in priority order
390       */
391 <    public void testTake() {
392 <        try {
393 <            DelayQueue q = populatedQueue(SIZE);
394 <            for (int i = 0; i < SIZE; ++i) {
434 <                assertEquals(new PDelay(i), ((PDelay)q.take()));
435 <            }
436 <        } catch (InterruptedException e) {
437 <            unexpectedException();
391 >    public void testTake() throws InterruptedException {
392 >        DelayQueue q = populatedQueue(SIZE);
393 >        for (int i = 0; i < SIZE; ++i) {
394 >            assertEquals(new PDelay(i), ((PDelay)q.take()));
395          }
396      }
397  
398      /**
399       * take blocks interruptibly when empty
400       */
401 <    public void testTakeFromEmpty() {
401 >    public void testTakeFromEmpty() throws InterruptedException {
402          final DelayQueue q = new DelayQueue();
403 <        Thread t = new Thread(new Runnable() {
404 <                public void run() {
405 <                    try {
406 <                        q.take();
407 <                        threadShouldThrow();
408 <                    } catch (InterruptedException success) { }
409 <                }
410 <            });
411 <        try {
455 <            t.start();
456 <            Thread.sleep(SHORT_DELAY_MS);
457 <            t.interrupt();
458 <            t.join();
459 <        } catch (Exception e) {
460 <            unexpectedException();
461 <        }
403 >        Thread t = new ThreadShouldThrow(InterruptedException.class) {
404 >            public void realRun() throws InterruptedException {
405 >                q.take();
406 >            }};
407 >
408 >        t.start();
409 >        Thread.sleep(SHORT_DELAY_MS);
410 >        t.interrupt();
411 >        t.join();
412      }
413  
414      /**
415       * Take removes existing elements until empty, then blocks interruptibly
416       */
417 <    public void testBlockingTake() {
418 <        Thread t = new Thread(new Runnable() {
419 <                public void run() {
420 <                    try {
421 <                        DelayQueue q = populatedQueue(SIZE);
422 <                        for (int i = 0; i < SIZE; ++i) {
423 <                            threadAssertEquals(new PDelay(i), ((PDelay)q.take()));
424 <                        }
425 <                        q.take();
426 <                        threadShouldThrow();
477 <                    } catch (InterruptedException success) {
478 <                    }
479 <                }});
417 >    public void testBlockingTake() throws InterruptedException {
418 >        Thread t = new ThreadShouldThrow(InterruptedException.class) {
419 >            public void realRun() throws InterruptedException {
420 >                DelayQueue q = populatedQueue(SIZE);
421 >                for (int i = 0; i < SIZE; ++i) {
422 >                    threadAssertEquals(new PDelay(i), ((PDelay)q.take()));
423 >                }
424 >                q.take();
425 >            }};
426 >
427          t.start();
428 <        try {
429 <           Thread.sleep(SHORT_DELAY_MS);
430 <           t.interrupt();
484 <           t.join();
485 <        }
486 <        catch (InterruptedException ie) {
487 <            unexpectedException();
488 <        }
428 >        Thread.sleep(SHORT_DELAY_MS);
429 >        t.interrupt();
430 >        t.join();
431      }
432  
433  
# Line 503 | Line 445 | public class DelayQueueTest extends JSR1
445      /**
446       * timed pool with zero timeout succeeds when non-empty, else times out
447       */
448 <    public void testTimedPoll0() {
449 <        try {
450 <            DelayQueue q = populatedQueue(SIZE);
451 <            for (int i = 0; i < SIZE; ++i) {
510 <                assertEquals(new PDelay(i), ((PDelay)q.poll(0, MILLISECONDS)));
511 <            }
512 <            assertNull(q.poll(0, MILLISECONDS));
513 <        } catch (InterruptedException e) {
514 <            unexpectedException();
448 >    public void testTimedPoll0() throws InterruptedException {
449 >        DelayQueue q = populatedQueue(SIZE);
450 >        for (int i = 0; i < SIZE; ++i) {
451 >            assertEquals(new PDelay(i), ((PDelay)q.poll(0, MILLISECONDS)));
452          }
453 +        assertNull(q.poll(0, MILLISECONDS));
454      }
455  
456      /**
457       * timed pool with nonzero timeout succeeds when non-empty, else times out
458       */
459 <    public void testTimedPoll() {
460 <        try {
461 <            DelayQueue q = populatedQueue(SIZE);
462 <            for (int i = 0; i < SIZE; ++i) {
525 <                assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
526 <            }
527 <            assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
528 <        } catch (InterruptedException e) {
529 <            unexpectedException();
459 >    public void testTimedPoll() throws InterruptedException {
460 >        DelayQueue q = populatedQueue(SIZE);
461 >        for (int i = 0; i < SIZE; ++i) {
462 >            assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
463          }
464 +        assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
465      }
466  
467      /**
468       * Interrupted timed poll throws InterruptedException instead of
469       * returning timeout status
470       */
471 <    public void testInterruptedTimedPoll() {
472 <        Thread t = new Thread(new Runnable() {
473 <                public void run() {
474 <                    try {
475 <                        DelayQueue q = populatedQueue(SIZE);
476 <                        for (int i = 0; i < SIZE; ++i) {
477 <                            threadAssertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
478 <                        }
479 <                        threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
480 <                    } catch (InterruptedException success) {
481 <                    }
482 <                }});
471 >    public void testInterruptedTimedPoll() throws InterruptedException {
472 >        Thread t = new Thread(new CheckedRunnable() {
473 >            public void realRun() throws InterruptedException {
474 >                DelayQueue q = populatedQueue(SIZE);
475 >                for (int i = 0; i < SIZE; ++i) {
476 >                    assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
477 >                }
478 >                try {
479 >                    q.poll(SMALL_DELAY_MS, MILLISECONDS);
480 >                    shouldThrow();
481 >                } catch (InterruptedException success) {}
482 >            }});
483 >
484          t.start();
485 <        try {
486 <           Thread.sleep(SHORT_DELAY_MS);
487 <           t.interrupt();
553 <           t.join();
554 <        }
555 <        catch (InterruptedException ie) {
556 <            unexpectedException();
557 <        }
485 >        Thread.sleep(SHORT_DELAY_MS);
486 >        t.interrupt();
487 >        t.join();
488      }
489  
490      /**
491       *  timed poll before a delayed offer fails; after offer succeeds;
492       *  on interruption throws
493       */
494 <    public void testTimedPollWithOffer() {
494 >    public void testTimedPollWithOffer() throws InterruptedException {
495          final DelayQueue q = new DelayQueue();
496 <        Thread t = new Thread(new Runnable() {
497 <                public void run() {
498 <                    try {
499 <                        threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
500 <                        q.poll(LONG_DELAY_MS, MILLISECONDS);
501 <                        q.poll(LONG_DELAY_MS, MILLISECONDS);
502 <                        threadFail("Should block");
503 <                    } catch (InterruptedException success) { }
504 <                }
505 <            });
506 <        try {
507 <            t.start();
508 <            Thread.sleep(SMALL_DELAY_MS);
509 <            assertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, MILLISECONDS));
510 <            t.interrupt();
511 <            t.join();
582 <        } catch (Exception e) {
583 <            unexpectedException();
584 <        }
496 >        final PDelay pdelay = new PDelay(0);
497 >        Thread t = new Thread(new CheckedRunnable() {
498 >            public void realRun() throws InterruptedException {
499 >                assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
500 >                assertSame(pdelay, q.poll(LONG_DELAY_MS, MILLISECONDS));
501 >                try {
502 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
503 >                    shouldThrow();
504 >                } catch (InterruptedException success) {}
505 >            }});
506 >
507 >        t.start();
508 >        Thread.sleep(SMALL_DELAY_MS);
509 >        assertTrue(q.offer(pdelay, SHORT_DELAY_MS, MILLISECONDS));
510 >        t.interrupt();
511 >        t.join();
512      }
513  
514  
# Line 613 | Line 540 | public class DelayQueueTest extends JSR1
540          try {
541              q.element();
542              shouldThrow();
543 <        }
617 <        catch (NoSuchElementException success) {}
543 >        } catch (NoSuchElementException success) {}
544      }
545  
546      /**
# Line 628 | Line 554 | public class DelayQueueTest extends JSR1
554          try {
555              q.remove();
556              shouldThrow();
557 <        } catch (NoSuchElementException success) {
632 <        }
557 >        } catch (NoSuchElementException success) {}
558      }
559  
560      /**
# Line 728 | Line 653 | public class DelayQueueTest extends JSR1
653      /**
654       * toArray contains all elements
655       */
656 <    public void testToArray() {
656 >    public void testToArray() throws InterruptedException {
657          DelayQueue q = populatedQueue(SIZE);
658          Object[] o = q.toArray();
659          Arrays.sort(o);
735        try {
660          for (int i = 0; i < o.length; i++)
661              assertEquals(o[i], q.take());
738        } catch (InterruptedException e) {
739            unexpectedException();
740        }
662      }
663  
664      /**
665       * toArray(a) contains all elements
666       */
667 <    public void testToArray2() {
667 >    public void testToArray2() throws InterruptedException {
668          DelayQueue q = populatedQueue(SIZE);
669          PDelay[] ints = new PDelay[SIZE];
670          ints = (PDelay[])q.toArray(ints);
671          Arrays.sort(ints);
672 <        try {
673 <            for (int i = 0; i < ints.length; i++)
753 <                assertEquals(ints[i], q.take());
754 <        } catch (InterruptedException e) {
755 <            unexpectedException();
756 <        }
672 >        for (int i = 0; i < ints.length; i++)
673 >            assertEquals(ints[i], q.take());
674      }
675  
676  
# Line 776 | Line 693 | public class DelayQueueTest extends JSR1
693              DelayQueue q = populatedQueue(SIZE);
694              Object o[] = q.toArray(new String[10] );
695              shouldThrow();
696 <        } catch (ArrayStoreException  success) {}
696 >        } catch (ArrayStoreException success) {}
697      }
698  
699      /**
# Line 828 | Line 745 | public class DelayQueueTest extends JSR1
745      public void testPollInExecutor() {
746          final DelayQueue q = new DelayQueue();
747          ExecutorService executor = Executors.newFixedThreadPool(2);
748 <        executor.execute(new Runnable() {
749 <            public void run() {
748 >        executor.execute(new CheckedRunnable() {
749 >            public void realRun() throws InterruptedException {
750                  threadAssertNull(q.poll());
751 <                try {
752 <                    threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
753 <                    threadAssertTrue(q.isEmpty());
754 <                }
755 <                catch (InterruptedException e) {
756 <                    threadUnexpectedException();
757 <                }
758 <            }
759 <        });
751 >                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
752 >                threadAssertTrue(q.isEmpty());
753 >            }});
754 >
755 >        executor.execute(new CheckedRunnable() {
756 >            public void realRun() throws InterruptedException {
757 >                Thread.sleep(SHORT_DELAY_MS);
758 >                q.put(new PDelay(1));
759 >            }});
760  
844        executor.execute(new Runnable() {
845            public void run() {
846                try {
847                    Thread.sleep(SHORT_DELAY_MS);
848                    q.put(new PDelay(1));
849                }
850                catch (InterruptedException e) {
851                    threadUnexpectedException();
852                }
853            }
854        });
761          joinPool(executor);
762  
763      }
# Line 860 | Line 766 | public class DelayQueueTest extends JSR1
766      /**
767       * Delayed actions do not occur until their delay elapses
768       */
769 <    public void testDelay() {
769 >    public void testDelay() throws InterruptedException {
770          DelayQueue q = new DelayQueue();
771          NanoDelay[] elements = new NanoDelay[SIZE];
772          for (int i = 0; i < SIZE; ++i) {
# Line 870 | Line 776 | public class DelayQueueTest extends JSR1
776              q.add(elements[i]);
777          }
778  
779 <        try {
780 <            long last = 0;
781 <            for (int i = 0; i < SIZE; ++i) {
782 <                NanoDelay e = (NanoDelay)(q.take());
783 <                long tt = e.getTriggerTime();
784 <                assertTrue(tt <= System.nanoTime());
785 <                if (i != 0)
786 <                    assertTrue(tt >= last);
881 <                last = tt;
882 <            }
883 <        }
884 <        catch (InterruptedException ie) {
885 <            unexpectedException();
779 >        long last = 0;
780 >        for (int i = 0; i < SIZE; ++i) {
781 >            NanoDelay e = (NanoDelay)(q.take());
782 >            long tt = e.getTriggerTime();
783 >            assertTrue(tt <= System.nanoTime());
784 >            if (i != 0)
785 >                assertTrue(tt >= last);
786 >            last = tt;
787          }
788      }
789  
# Line 908 | Line 809 | public class DelayQueueTest extends JSR1
809      /**
810       * timed poll of a non-empty queue returns null if no expired elements.
811       */
812 <    public void testTimedPollDelayed() {
812 >    public void testTimedPollDelayed() throws InterruptedException {
813          DelayQueue q = new DelayQueue();
814          q.add(new NanoDelay(LONG_DELAY_MS * 1000000L));
815 <        try {
915 <            assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
916 <        } catch (Exception ex) {
917 <            unexpectedException();
918 <        }
815 >        assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
816      }
817  
818      /**
# Line 926 | Line 823 | public class DelayQueueTest extends JSR1
823          try {
824              q.drainTo(null);
825              shouldThrow();
826 <        } catch (NullPointerException success) {
930 <        }
826 >        } catch (NullPointerException success) {}
827      }
828  
829      /**
# Line 938 | Line 834 | public class DelayQueueTest extends JSR1
834          try {
835              q.drainTo(q);
836              shouldThrow();
837 <        } catch (IllegalArgumentException success) {
942 <        }
837 >        } catch (IllegalArgumentException success) {}
838      }
839  
840      /**
# Line 973 | Line 868 | public class DelayQueueTest extends JSR1
868      /**
869       * drainTo empties queue
870       */
871 <    public void testDrainToWithActivePut() {
871 >    public void testDrainToWithActivePut() throws InterruptedException {
872          final DelayQueue q = populatedQueue(SIZE);
873 <        Thread t = new Thread(new Runnable() {
874 <                public void run() {
875 <                    q.put(new PDelay(SIZE+1));
876 <                }
877 <            });
878 <        try {
879 <            t.start();
880 <            ArrayList l = new ArrayList();
881 <            q.drainTo(l);
882 <            assertTrue(l.size() >= SIZE);
883 <            t.join();
989 <            assertTrue(q.size() + l.size() >= SIZE);
990 <        } catch (Exception e) {
991 <            unexpectedException();
992 <        }
873 >        Thread t = new Thread(new CheckedRunnable() {
874 >            public void realRun() {
875 >                q.put(new PDelay(SIZE+1));
876 >            }});
877 >
878 >        t.start();
879 >        ArrayList l = new ArrayList();
880 >        q.drainTo(l);
881 >        assertTrue(l.size() >= SIZE);
882 >        t.join();
883 >        assertTrue(q.size() + l.size() >= SIZE);
884      }
885  
886      /**
# Line 1000 | Line 891 | public class DelayQueueTest extends JSR1
891          try {
892              q.drainTo(null, 0);
893              shouldThrow();
894 <        } catch (NullPointerException success) {
1004 <        }
894 >        } catch (NullPointerException success) {}
895      }
896  
897      /**
# Line 1012 | Line 902 | public class DelayQueueTest extends JSR1
902          try {
903              q.drainTo(q, 0);
904              shouldThrow();
905 <        } catch (IllegalArgumentException success) {
1016 <        }
905 >        } catch (IllegalArgumentException success) {}
906      }
907  
908      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines