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.26 by jsr166, Sun Nov 22 18:57:17 2009 UTC vs.
Revision 1.56 by jsr166, Fri Jul 15 18:49:31 2011 UTC

# Line 1 | Line 1
1   /*
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/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
10 < import java.util.*;
10 > import java.util.Arrays;
11 > import java.util.ArrayList;
12 > import java.util.Iterator;
13 > import java.util.NoSuchElementException;
14 > import java.util.concurrent.BlockingQueue;
15 > import java.util.concurrent.CountDownLatch;
16 > import java.util.concurrent.Delayed;
17 > import java.util.concurrent.DelayQueue;
18 > import java.util.concurrent.Executors;
19 > import java.util.concurrent.ExecutorService;
20 > import java.util.concurrent.TimeUnit;
21   import static java.util.concurrent.TimeUnit.MILLISECONDS;
12 import java.util.concurrent.*;
22  
23   public class DelayQueueTest extends JSR166TestCase {
24 +
25 +    public static class Generic extends BlockingQueueTest {
26 +        protected BlockingQueue emptyCollection() {
27 +            return new DelayQueue();
28 +        }
29 +        protected PDelay makeElement(int i) {
30 +            return new PDelay(i);
31 +        }
32 +    }
33 +
34      public static void main(String[] args) {
35 <        junit.textui.TestRunner.run (suite());
35 >        junit.textui.TestRunner.run(suite());
36      }
37  
38      public static Test suite() {
39 <        return new TestSuite(DelayQueueTest.class);
39 >        return newTestSuite(DelayQueueTest.class,
40 >                            new Generic().testSuite());
41      }
42  
43      private static final int NOCAP = Integer.MAX_VALUE;
44  
45      /**
46       * A delayed implementation for testing.
47 <     * Most  tests use Pseudodelays, where delays are all elapsed
47 >     * Most tests use Pseudodelays, where delays are all elapsed
48       * (so, no blocking solely for delays) but are still ordered
49       */
50      static class PDelay implements Delayed {
51          int pseudodelay;
52 <        PDelay(int i) { pseudodelay = Integer.MIN_VALUE + i; }
53 <        public int compareTo(PDelay y) {
54 <            int i = pseudodelay;
55 <            int j = ((PDelay)y).pseudodelay;
56 <            if (i < j) return -1;
37 <            if (i > j) return 1;
38 <            return 0;
52 >        PDelay(int i) { pseudodelay = i; }
53 >        public int compareTo(PDelay other) {
54 >            int a = this.pseudodelay;
55 >            int b = other.pseudodelay;
56 >            return (a < b) ? -1 : (a > b) ? 1 : 0;
57          }
40
58          public int compareTo(Delayed y) {
59 <            int i = pseudodelay;
43 <            int j = ((PDelay)y).pseudodelay;
44 <            if (i < j) return -1;
45 <            if (i > j) return 1;
46 <            return 0;
59 >            return compareTo((PDelay)y);
60          }
48
61          public boolean equals(Object other) {
62 <            return ((PDelay)other).pseudodelay == pseudodelay;
63 <        }
52 <        public boolean equals(PDelay other) {
53 <            return ((PDelay)other).pseudodelay == pseudodelay;
62 >            return (other instanceof PDelay) &&
63 >                this.pseudodelay == ((PDelay)other).pseudodelay;
64          }
55
56
65          public long getDelay(TimeUnit ignore) {
66 <            return pseudodelay;
59 <        }
60 <        public int intValue() {
61 <            return pseudodelay;
66 >            return Integer.MIN_VALUE + pseudodelay;
67          }
63
68          public String toString() {
69              return String.valueOf(pseudodelay);
70          }
71      }
72  
69
73      /**
74       * Delayed implementation that actually delays
75       */
# Line 77 | Line 80 | public class DelayQueueTest extends JSR1
80          }
81          public int compareTo(NanoDelay y) {
82              long i = trigger;
83 <            long j = ((NanoDelay)y).trigger;
83 >            long j = y.trigger;
84              if (i < j) return -1;
85              if (i > j) return 1;
86              return 0;
87          }
88  
89          public int compareTo(Delayed y) {
90 <            long i = trigger;
88 <            long j = ((NanoDelay)y).trigger;
89 <            if (i < j) return -1;
90 <            if (i > j) return 1;
91 <            return 0;
90 >            return compareTo((NanoDelay)y);
91          }
92  
93          public boolean equals(Object other) {
94 <            return ((NanoDelay)other).trigger == trigger;
94 >            return equals((NanoDelay)other);
95          }
96          public boolean equals(NanoDelay other) {
97 <            return ((NanoDelay)other).trigger == trigger;
97 >            return other.trigger == trigger;
98          }
99  
100          public long getDelay(TimeUnit unit) {
# Line 112 | Line 111 | public class DelayQueueTest extends JSR1
111          }
112      }
113  
115
114      /**
115       * Create a queue of given size containing consecutive
116       * PDelays 0 ... n.
117       */
118 <    private DelayQueue populatedQueue(int n) {
119 <        DelayQueue q = new DelayQueue();
118 >    private DelayQueue<PDelay> populatedQueue(int n) {
119 >        DelayQueue<PDelay> q = new DelayQueue<PDelay>();
120          assertTrue(q.isEmpty());
121          for (int i = n-1; i >= 0; i-=2)
122              assertTrue(q.offer(new PDelay(i)));
# Line 199 | Line 197 | public class DelayQueueTest extends JSR1
197      }
198  
199      /**
200 <     * remainingCapacity does not change when elementa added or removed,
200 >     * remainingCapacity does not change when elements added or removed,
201       * but size does
202       */
203      public void testRemainingCapacity() {
# Line 217 | Line 215 | public class DelayQueueTest extends JSR1
215      }
216  
217      /**
220     * offer(null) throws NPE
221     */
222    public void testOfferNull() {
223        try {
224            DelayQueue q = new DelayQueue();
225            q.offer(null);
226            shouldThrow();
227        } catch (NullPointerException success) {}
228    }
229
230    /**
231     * add(null) throws NPE
232     */
233    public void testAddNull() {
234        try {
235            DelayQueue q = new DelayQueue();
236            q.add(null);
237            shouldThrow();
238        } catch (NullPointerException success) {}
239    }
240
241    /**
218       * offer non-null succeeds
219       */
220      public void testOffer() {
# Line 259 | Line 235 | public class DelayQueueTest extends JSR1
235      }
236  
237      /**
262     * addAll(null) throws NPE
263     */
264    public void testAddAll1() {
265        try {
266            DelayQueue q = new DelayQueue();
267            q.addAll(null);
268            shouldThrow();
269        } catch (NullPointerException success) {}
270    }
271
272
273    /**
238       * addAll(this) throws IAE
239       */
240      public void testAddAllSelf() {
# Line 282 | Line 246 | public class DelayQueueTest extends JSR1
246      }
247  
248      /**
285     * addAll of a collection with null elements throws NPE
286     */
287    public void testAddAll2() {
288        try {
289            DelayQueue q = new DelayQueue();
290            PDelay[] ints = new PDelay[SIZE];
291            q.addAll(Arrays.asList(ints));
292            shouldThrow();
293        } catch (NullPointerException success) {}
294    }
295    /**
249       * addAll of a collection with any null elements throws NPE after
250       * possibly adding some elements
251       */
# Line 323 | Line 276 | public class DelayQueueTest extends JSR1
276      }
277  
278      /**
326     * put(null) throws NPE
327     */
328     public void testPutNull() {
329        try {
330            DelayQueue q = new DelayQueue();
331            q.put(null);
332            shouldThrow();
333        } catch (NullPointerException success) {}
334     }
335
336    /**
279       * all elements successfully put are contained
280       */
281 <     public void testPut() {
282 <         DelayQueue q = new DelayQueue();
283 <         for (int i = 0; i < SIZE; ++i) {
284 <             PDelay I = new PDelay(i);
285 <             q.put(I);
286 <             assertTrue(q.contains(I));
287 <         }
288 <         assertEquals(SIZE, q.size());
281 >    public void testPut() {
282 >        DelayQueue q = new DelayQueue();
283 >        for (int i = 0; i < SIZE; ++i) {
284 >            PDelay I = new PDelay(i);
285 >            q.put(I);
286 >            assertTrue(q.contains(I));
287 >        }
288 >        assertEquals(SIZE, q.size());
289      }
290  
291      /**
# Line 351 | Line 293 | public class DelayQueueTest extends JSR1
293       */
294      public void testPutWithTake() throws InterruptedException {
295          final DelayQueue q = new DelayQueue();
296 <        Thread t = new Thread(new CheckedRunnable() {
296 >        Thread t = newStartedThread(new CheckedRunnable() {
297              public void realRun() {
298                  q.put(new PDelay(0));
299                  q.put(new PDelay(0));
# Line 359 | Line 301 | public class DelayQueueTest extends JSR1
301                  q.put(new PDelay(0));
302              }});
303  
304 <        t.start();
305 <        Thread.sleep(SHORT_DELAY_MS);
364 <        q.take();
365 <        t.interrupt();
366 <        t.join();
304 >        awaitTermination(t);
305 >        assertEquals(4, q.size());
306      }
307  
308      /**
# Line 371 | Line 310 | public class DelayQueueTest extends JSR1
310       */
311      public void testTimedOffer() throws InterruptedException {
312          final DelayQueue q = new DelayQueue();
313 <        Thread t = new Thread(new CheckedRunnable() {
313 >        Thread t = newStartedThread(new CheckedRunnable() {
314              public void realRun() throws InterruptedException {
315                  q.put(new PDelay(0));
316                  q.put(new PDelay(0));
# Line 379 | Line 318 | public class DelayQueueTest extends JSR1
318                  assertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, MILLISECONDS));
319              }});
320  
321 <        t.start();
383 <        Thread.sleep(SMALL_DELAY_MS);
384 <        t.interrupt();
385 <        t.join();
321 >        awaitTermination(t);
322      }
323  
324      /**
# Line 396 | Line 332 | public class DelayQueueTest extends JSR1
332      }
333  
334      /**
399     * take blocks interruptibly when empty
400     */
401    public void testTakeFromEmpty() throws InterruptedException {
402        final DelayQueue q = new DelayQueue();
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    /**
335       * Take removes existing elements until empty, then blocks interruptibly
336       */
337      public void testBlockingTake() throws InterruptedException {
338          final DelayQueue q = populatedQueue(SIZE);
339 <        Thread t = new Thread(new CheckedRunnable() {
339 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
340 >        Thread t = newStartedThread(new CheckedRunnable() {
341              public void realRun() throws InterruptedException {
342                  for (int i = 0; i < SIZE; ++i) {
343                      assertEquals(new PDelay(i), ((PDelay)q.take()));
344                  }
345 +
346 +                Thread.currentThread().interrupt();
347                  try {
348                      q.take();
349                      shouldThrow();
350                  } catch (InterruptedException success) {}
351 +                assertFalse(Thread.interrupted());
352 +
353 +                pleaseInterrupt.countDown();
354 +                try {
355 +                    q.take();
356 +                    shouldThrow();
357 +                } catch (InterruptedException success) {}
358 +                assertFalse(Thread.interrupted());
359              }});
360  
361 <        t.start();
362 <        Thread.sleep(SHORT_DELAY_MS);
361 >        await(pleaseInterrupt);
362 >        assertThreadStaysAlive(t);
363          t.interrupt();
364 <        t.join();
364 >        awaitTermination(t);
365      }
366  
436
367      /**
368       * poll succeeds unless empty
369       */
# Line 446 | Line 376 | public class DelayQueueTest extends JSR1
376      }
377  
378      /**
379 <     * timed pool with zero timeout succeeds when non-empty, else times out
379 >     * timed poll with zero timeout succeeds when non-empty, else times out
380       */
381      public void testTimedPoll0() throws InterruptedException {
382          DelayQueue q = populatedQueue(SIZE);
# Line 457 | Line 387 | public class DelayQueueTest extends JSR1
387      }
388  
389      /**
390 <     * timed pool with nonzero timeout succeeds when non-empty, else times out
390 >     * timed poll with nonzero timeout succeeds when non-empty, else times out
391       */
392      public void testTimedPoll() throws InterruptedException {
393          DelayQueue q = populatedQueue(SIZE);
394          for (int i = 0; i < SIZE; ++i) {
395 <            assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
396 <        }
397 <        assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
395 >            long startTime = System.nanoTime();
396 >            assertEquals(new PDelay(i), ((PDelay)q.poll(LONG_DELAY_MS, MILLISECONDS)));
397 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
398 >        }
399 >        long startTime = System.nanoTime();
400 >        assertNull(q.poll(timeoutMillis(), MILLISECONDS));
401 >        assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
402 >        checkEmpty(q);
403      }
404  
405      /**
# Line 472 | Line 407 | public class DelayQueueTest extends JSR1
407       * returning timeout status
408       */
409      public void testInterruptedTimedPoll() throws InterruptedException {
410 <        Thread t = new Thread(new CheckedRunnable() {
410 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
411 >        Thread t = newStartedThread(new CheckedRunnable() {
412              public void realRun() throws InterruptedException {
413                  DelayQueue q = populatedQueue(SIZE);
414                  for (int i = 0; i < SIZE; ++i) {
415                      assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS)));
416                  }
417 +
418 +                Thread.currentThread().interrupt();
419                  try {
420 <                    q.poll(SMALL_DELAY_MS, MILLISECONDS);
420 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
421                      shouldThrow();
422                  } catch (InterruptedException success) {}
423 <            }});
423 >                assertFalse(Thread.interrupted());
424  
425 <        t.start();
488 <        Thread.sleep(SHORT_DELAY_MS);
489 <        t.interrupt();
490 <        t.join();
491 <    }
492 <
493 <    /**
494 <     *  timed poll before a delayed offer fails; after offer succeeds;
495 <     *  on interruption throws
496 <     */
497 <    public void testTimedPollWithOffer() throws InterruptedException {
498 <        final DelayQueue q = new DelayQueue();
499 <        final PDelay pdelay = new PDelay(0);
500 <        Thread t = new Thread(new CheckedRunnable() {
501 <            public void realRun() throws InterruptedException {
502 <                assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
503 <                assertSame(pdelay, q.poll(LONG_DELAY_MS, MILLISECONDS));
425 >                pleaseInterrupt.countDown();
426                  try {
427                      q.poll(LONG_DELAY_MS, MILLISECONDS);
428                      shouldThrow();
429                  } catch (InterruptedException success) {}
430 +                assertFalse(Thread.interrupted());
431              }});
432  
433 <        t.start();
434 <        Thread.sleep(SMALL_DELAY_MS);
512 <        assertTrue(q.offer(pdelay, SHORT_DELAY_MS, MILLISECONDS));
433 >        await(pleaseInterrupt);
434 >        assertThreadStaysAlive(t);
435          t.interrupt();
436 <        t.join();
436 >        awaitTermination(t);
437      }
438  
517
439      /**
440       * peek returns next element, or null if empty
441       */
# Line 561 | Line 482 | public class DelayQueueTest extends JSR1
482      }
483  
484      /**
564     * remove(x) removes x and returns true if present
565     */
566    public void testRemoveElement() {
567        DelayQueue q = populatedQueue(SIZE);
568        for (int i = 1; i < SIZE; i+=2) {
569            assertTrue(q.remove(new PDelay(i)));
570        }
571        for (int i = 0; i < SIZE; i+=2) {
572            assertTrue(q.remove(new PDelay(i)));
573            assertFalse(q.remove(new PDelay(i+1)));
574        }
575        assertTrue(q.isEmpty());
576    }
577
578    /**
485       * contains(x) reports true when elements added but not yet removed
486       */
487      public void testContains() {
# Line 661 | Line 567 | public class DelayQueueTest extends JSR1
567          Object[] o = q.toArray();
568          Arrays.sort(o);
569          for (int i = 0; i < o.length; i++)
570 <            assertEquals(o[i], q.take());
570 >            assertSame(o[i], q.take());
571      }
572  
573      /**
574       * toArray(a) contains all elements
575       */
576 <    public void testToArray2() throws InterruptedException {
577 <        DelayQueue q = populatedQueue(SIZE);
576 >    public void testToArray2() {
577 >        DelayQueue<PDelay> q = populatedQueue(SIZE);
578          PDelay[] ints = new PDelay[SIZE];
579 <        ints = (PDelay[])q.toArray(ints);
579 >        PDelay[] array = q.toArray(ints);
580 >        assertSame(ints, array);
581          Arrays.sort(ints);
582          for (int i = 0; i < ints.length; i++)
583 <            assertEquals(ints[i], q.take());
583 >            assertSame(ints[i], q.remove());
584      }
585  
679
586      /**
587 <     * toArray(null) throws NPE
682 <     */
683 <    public void testToArray_BadArg() {
684 <        DelayQueue q = populatedQueue(SIZE);
685 <        try {
686 <            Object o[] = q.toArray(null);
687 <            shouldThrow();
688 <        } catch (NullPointerException success) {}
689 <    }
690 <
691 <    /**
692 <     * toArray with incompatible array type throws CCE
587 >     * toArray(incompatible array type) throws ArrayStoreException
588       */
589      public void testToArray1_BadArg() {
590          DelayQueue q = populatedQueue(SIZE);
591          try {
592 <            Object o[] = q.toArray(new String[10]);
592 >            q.toArray(new String[10]);
593              shouldThrow();
594          } catch (ArrayStoreException success) {}
595      }
# Line 716 | Line 611 | public class DelayQueueTest extends JSR1
611      /**
612       * iterator.remove removes current element
613       */
614 <    public void testIteratorRemove () {
614 >    public void testIteratorRemove() {
615          final DelayQueue q = new DelayQueue();
616          q.add(new PDelay(2));
617          q.add(new PDelay(1));
# Line 730 | Line 625 | public class DelayQueueTest extends JSR1
625          assertFalse(it.hasNext());
626      }
627  
733
628      /**
629       * toString contains toStrings of elements
630       */
631      public void testToString() {
632          DelayQueue q = populatedQueue(SIZE);
633          String s = q.toString();
634 <        for (int i = 0; i < SIZE; ++i) {
635 <            assertTrue(s.indexOf(String.valueOf(Integer.MIN_VALUE+i)) >= 0);
742 <        }
634 >        for (Object e : q)
635 >            assertTrue(s.contains(e.toString()));
636      }
637  
638      /**
639 <     * offer transfers elements across Executor tasks
639 >     * timed poll transfers elements across Executor tasks
640       */
641      public void testPollInExecutor() {
642          final DelayQueue q = new DelayQueue();
643 +        final CheckedBarrier threadsStarted = new CheckedBarrier(2);
644          ExecutorService executor = Executors.newFixedThreadPool(2);
645          executor.execute(new CheckedRunnable() {
646              public void realRun() throws InterruptedException {
647 <                threadAssertNull(q.poll());
648 <                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
649 <                threadAssertTrue(q.isEmpty());
647 >                assertNull(q.poll());
648 >                threadsStarted.await();
649 >                assertTrue(null != q.poll(LONG_DELAY_MS, MILLISECONDS));
650 >                checkEmpty(q);
651              }});
652  
653          executor.execute(new CheckedRunnable() {
654              public void realRun() throws InterruptedException {
655 <                Thread.sleep(SHORT_DELAY_MS);
655 >                threadsStarted.await();
656                  q.put(new PDelay(1));
657              }});
658  
659          joinPool(executor);
765
660      }
661  
768
662      /**
663       * Delayed actions do not occur until their delay elapses
664       */
665      public void testDelay() throws InterruptedException {
666 <        DelayQueue q = new DelayQueue();
667 <        NanoDelay[] elements = new NanoDelay[SIZE];
668 <        for (int i = 0; i < SIZE; ++i) {
776 <            elements[i] = new NanoDelay(1000000000L + 1000000L * (SIZE - i));
777 <        }
778 <        for (int i = 0; i < SIZE; ++i) {
779 <            q.add(elements[i]);
780 <        }
666 >        DelayQueue<NanoDelay> q = new DelayQueue<NanoDelay>();
667 >        for (int i = 0; i < SIZE; ++i)
668 >            q.add(new NanoDelay(1000000L * (SIZE - i)));
669  
670          long last = 0;
671          for (int i = 0; i < SIZE; ++i) {
672 <            NanoDelay e = (NanoDelay)(q.take());
672 >            NanoDelay e = q.take();
673              long tt = e.getTriggerTime();
674 <            assertTrue(tt <= System.nanoTime());
674 >            assertTrue(System.nanoTime() - tt >= 0);
675              if (i != 0)
676                  assertTrue(tt >= last);
677              last = tt;
678          }
679 +        assertTrue(q.isEmpty());
680      }
681  
682      /**
# Line 796 | Line 685 | public class DelayQueueTest extends JSR1
685      public void testPeekDelayed() {
686          DelayQueue q = new DelayQueue();
687          q.add(new NanoDelay(Long.MAX_VALUE));
688 <        assert(q.peek() != null);
688 >        assertNotNull(q.peek());
689      }
690  
802
691      /**
692       * poll of a non-empty queue returns null if no expired elements.
693       */
# Line 815 | Line 703 | public class DelayQueueTest extends JSR1
703      public void testTimedPollDelayed() throws InterruptedException {
704          DelayQueue q = new DelayQueue();
705          q.add(new NanoDelay(LONG_DELAY_MS * 1000000L));
706 <        assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
819 <    }
820 <
821 <    /**
822 <     * drainTo(null) throws NPE
823 <     */
824 <    public void testDrainToNull() {
825 <        DelayQueue q = populatedQueue(SIZE);
826 <        try {
827 <            q.drainTo(null);
828 <            shouldThrow();
829 <        } catch (NullPointerException success) {}
830 <    }
831 <
832 <    /**
833 <     * drainTo(this) throws IAE
834 <     */
835 <    public void testDrainToSelf() {
836 <        DelayQueue q = populatedQueue(SIZE);
837 <        try {
838 <            q.drainTo(q);
839 <            shouldThrow();
840 <        } catch (IllegalArgumentException success) {}
706 >        assertNull(q.poll(timeoutMillis(), MILLISECONDS));
707      }
708  
709      /**
# Line 887 | Line 753 | public class DelayQueueTest extends JSR1
753      }
754  
755      /**
756 <     * drainTo(null, n) throws NPE
891 <     */
892 <    public void testDrainToNullN() {
893 <        DelayQueue q = populatedQueue(SIZE);
894 <        try {
895 <            q.drainTo(null, 0);
896 <            shouldThrow();
897 <        } catch (NullPointerException success) {}
898 <    }
899 <
900 <    /**
901 <     * drainTo(this, n) throws IAE
902 <     */
903 <    public void testDrainToSelfN() {
904 <        DelayQueue q = populatedQueue(SIZE);
905 <        try {
906 <            q.drainTo(q, 0);
907 <            shouldThrow();
908 <        } catch (IllegalArgumentException success) {}
909 <    }
910 <
911 <    /**
912 <     * drainTo(c, n) empties first max {n, size} elements of queue into c
756 >     * drainTo(c, n) empties first min(n, size) elements of queue into c
757       */
758      public void testDrainToN() {
759          for (int i = 0; i < SIZE + 2; ++i) {
760              DelayQueue q = populatedQueue(SIZE);
761              ArrayList l = new ArrayList();
762              q.drainTo(l, i);
763 <            int k = (i < SIZE)? i : SIZE;
763 >            int k = (i < SIZE) ? i : SIZE;
764              assertEquals(q.size(), SIZE-k);
765              assertEquals(l.size(), k);
766          }
767      }
768  
925
769   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines