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

Comparing jsr166/src/test/tck/LinkedTransferQueueTest.java (file contents):
Revision 1.12 by jsr166, Sat Aug 15 00:35:01 2009 UTC vs.
Revision 1.27 by jsr166, Thu Oct 28 17:22:13 2010 UTC

# Line 13 | Line 13 | import java.io.ObjectInputStream;
13   import java.io.ObjectOutputStream;
14   import java.util.ArrayList;
15   import java.util.Arrays;
16 import java.util.ConcurrentModificationException;
16   import java.util.Iterator;
17   import java.util.List;
18   import java.util.NoSuchElementException;
19   import java.util.concurrent.*;
20   import static java.util.concurrent.TimeUnit.MILLISECONDS;
21 + import static java.util.concurrent.TimeUnit.NANOSECONDS;
22   import junit.framework.Test;
23   import junit.framework.TestSuite;
24  
25   @SuppressWarnings({"unchecked", "rawtypes"})
26   public class LinkedTransferQueueTest extends JSR166TestCase {
27  
28 +    public static class Generic extends BlockingQueueTest {
29 +        protected BlockingQueue emptyCollection() {
30 +            return new LinkedTransferQueue();
31 +        }
32 +    }
33 +
34      public static void main(String[] args) {
35          junit.textui.TestRunner.run(suite());
36      }
37  
38      public static Test suite() {
39 <        return new TestSuite(LinkedTransferQueueTest.class);
39 >        return newTestSuite(LinkedTransferQueueTest.class,
40 >                            new Generic().testSuite());
41      }
42  
43      void checkEmpty(LinkedTransferQueue q) throws InterruptedException {
# Line 45 | Line 52 | public class LinkedTransferQueueTest ext
52          try {
53              q.element();
54              shouldThrow();
55 <        } catch (NoSuchElementException success) {
49 <        }
55 >        } catch (NoSuchElementException success) {}
56          try {
57              q.iterator().next();
58              shouldThrow();
59 <        } catch (NoSuchElementException success) {
54 <        }
59 >        } catch (NoSuchElementException success) {}
60          try {
61              q.remove();
62              shouldThrow();
63 <        } catch (NoSuchElementException success) {
59 <        }
63 >        } catch (NoSuchElementException success) {}
64      }
65  
66      /**
# Line 76 | Line 80 | public class LinkedTransferQueueTest ext
80          try {
81              new LinkedTransferQueue(null);
82              shouldThrow();
83 <        } catch (NullPointerException success) {
80 <        }
83 >        } catch (NullPointerException success) {}
84      }
85  
86      /**
# Line 89 | Line 92 | public class LinkedTransferQueueTest ext
92              Integer[] ints = new Integer[SIZE];
93              new LinkedTransferQueue(Arrays.asList(ints));
94              shouldThrow();
95 <        } catch (NullPointerException success) {
93 <        }
95 >        } catch (NullPointerException success) {}
96      }
97  
98      /**
# Line 105 | Line 107 | public class LinkedTransferQueueTest ext
107              }
108              new LinkedTransferQueue(Arrays.asList(ints));
109              shouldThrow();
110 <        } catch (NullPointerException success) {
109 <        }
110 >        } catch (NullPointerException success) {}
111      }
112  
113      /**
# Line 158 | Line 159 | public class LinkedTransferQueueTest ext
159              LinkedTransferQueue q = new LinkedTransferQueue();
160              q.offer(null);
161              shouldThrow();
162 <        } catch (NullPointerException success) {
162 <        }
162 >        } catch (NullPointerException success) {}
163      }
164  
165      /**
# Line 170 | Line 170 | public class LinkedTransferQueueTest ext
170              LinkedTransferQueue q = new LinkedTransferQueue();
171              q.add(null);
172              shouldThrow();
173 <        } catch (NullPointerException success) {
174 <        }
173 >        } catch (NullPointerException success) {}
174      }
175  
176      /**
# Line 182 | Line 181 | public class LinkedTransferQueueTest ext
181              LinkedTransferQueue q = new LinkedTransferQueue();
182              q.addAll(null);
183              shouldThrow();
184 <        } catch (NullPointerException success) {
186 <        }
184 >        } catch (NullPointerException success) {}
185      }
186  
187      /**
# Line 194 | Line 192 | public class LinkedTransferQueueTest ext
192              LinkedTransferQueue q = populatedQueue(SIZE);
193              q.addAll(q);
194              shouldThrow();
195 <        } catch (IllegalArgumentException success) {
198 <        }
195 >        } catch (IllegalArgumentException success) {}
196      }
197  
198      /**
# Line 207 | Line 204 | public class LinkedTransferQueueTest ext
204              Integer[] ints = new Integer[SIZE];
205              q.addAll(Arrays.asList(ints));
206              shouldThrow();
207 <        } catch (NullPointerException success) {
211 <        }
207 >        } catch (NullPointerException success) {}
208      }
209  
210      /**
# Line 224 | Line 220 | public class LinkedTransferQueueTest ext
220              }
221              q.addAll(Arrays.asList(ints));
222              shouldThrow();
223 <        } catch (NullPointerException success) {
228 <        }
223 >        } catch (NullPointerException success) {}
224      }
225  
226      /**
# Line 284 | Line 279 | public class LinkedTransferQueueTest ext
279      public void testTakeFromEmpty() throws InterruptedException {
280          final LinkedTransferQueue q = new LinkedTransferQueue();
281          Thread t = newStartedThread(new CheckedInterruptedRunnable() {
282 <            void realRun() throws InterruptedException {
282 >            public void realRun() throws InterruptedException {
283                  q.take();
284              }});
285          Thread.sleep(SHORT_DELAY_MS);
# Line 297 | Line 292 | public class LinkedTransferQueueTest ext
292       */
293      public void testBlockingTake() throws InterruptedException {
294          final LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
295 <        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
296 <            void realRun() throws InterruptedException {
295 >        Thread t = new Thread(new CheckedRunnable() {
296 >            public void realRun() throws InterruptedException {
297                  for (int i = 0; i < SIZE; ++i) {
298 <                    threadAssertEquals(i, (int) q.take());
298 >                    assertEquals(i, (int) q.take());
299                  }
300 <                q.take();
300 >                try {
301 >                    q.take();
302 >                    shouldThrow();
303 >                } catch (InterruptedException success) {}
304              }});
305 <        Thread.sleep(SMALL_DELAY_MS);
305 >
306 >        t.start();
307 >        Thread.sleep(SHORT_DELAY_MS);
308          t.interrupt();
309          t.join();
310          checkEmpty(q);
# Line 355 | Line 355 | public class LinkedTransferQueueTest ext
355       */
356      public void testInterruptedTimedPoll() throws InterruptedException {
357          final LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
358 <        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
359 <            void realRun() throws InterruptedException {
358 >        Thread t = newStartedThread(new CheckedRunnable() {
359 >            public void realRun() throws InterruptedException {
360                  for (int i = 0; i < SIZE; ++i) {
361                      long t0 = System.nanoTime();
362 <                    threadAssertEquals(i, (int) q.poll(LONG_DELAY_MS,
363 <                                                       MILLISECONDS));
362 >                    assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
363                      long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024);
364                      assertTrue(millisElapsed < SMALL_DELAY_MS);
365                  }
366 <                q.poll(LONG_DELAY_MS, MILLISECONDS);
366 >                try {
367 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
368 >                    shouldThrow();
369 >                } catch (InterruptedException success) {}
370              }});
369        Thread.sleep(SMALL_DELAY_MS);
370        t.interrupt();
371        t.join();
372        checkEmpty(q);
373    }
371  
375    /**
376     * timed poll before a delayed offer fails; after offer succeeds;
377     * on interruption throws
378     */
379    public void testTimedPollWithOffer() throws InterruptedException {
380        final LinkedTransferQueue q = new LinkedTransferQueue();
381        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
382            void realRun() throws InterruptedException {
383                threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
384                q.poll(LONG_DELAY_MS, MILLISECONDS);
385                q.poll(LONG_DELAY_MS, MILLISECONDS);
386            }});
372          Thread.sleep(SMALL_DELAY_MS);
388        assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS));
373          t.interrupt();
374          t.join();
375 +        checkEmpty(q);
376      }
377  
378      /**
# Line 417 | Line 402 | public class LinkedTransferQueueTest ext
402          try {
403              q.element();
404              shouldThrow();
405 <        } catch (NoSuchElementException success) {
421 <        }
405 >        } catch (NoSuchElementException success) {}
406          checkEmpty(q);
407      }
408  
# Line 433 | Line 417 | public class LinkedTransferQueueTest ext
417          try {
418              q.remove();
419              shouldThrow();
420 <        } catch (NoSuchElementException success) {
437 <        }
420 >        } catch (NoSuchElementException success) {}
421          checkEmpty(q);
422      }
423  
# Line 463 | Line 446 | public class LinkedTransferQueueTest ext
446          assertTrue(q.remove(one));
447          assertTrue(q.remove(two));
448          assertTrue(q.add(three));
449 <        assertTrue(q.take() == three);
449 >        assertSame(q.take(), three);
450      }
451  
452      /**
# Line 545 | Line 528 | public class LinkedTransferQueueTest ext
528      }
529  
530      /**
531 <     * toArray contains all elements
531 >     * toArray() contains all elements
532       */
533      public void testToArray() throws InterruptedException {
534          LinkedTransferQueue q = populatedQueue(SIZE);
# Line 571 | Line 554 | public class LinkedTransferQueueTest ext
554       * toArray(null) throws NullPointerException
555       */
556      public void testToArray_BadArg() {
557 +        LinkedTransferQueue q = populatedQueue(SIZE);
558          try {
575            LinkedTransferQueue q = populatedQueue(SIZE);
559              Object o[] = q.toArray(null);
560              shouldThrow();
561 <        } catch (NullPointerException success) {
579 <        }
561 >        } catch (NullPointerException success) {}
562      }
563  
564      /**
565 <     * toArray with incompatible array type throws CCE
565 >     * toArray(incompatible array type) throws CCE
566       */
567      public void testToArray1_BadArg() {
568 +        LinkedTransferQueue q = populatedQueue(SIZE);
569          try {
587            LinkedTransferQueue q = populatedQueue(SIZE);
570              Object o[] = q.toArray(new String[10]);
571              shouldThrow();
572 <        } catch (ArrayStoreException success) {
591 <        }
572 >        } catch (ArrayStoreException success) {}
573      }
574  
575      /**
# Line 618 | Line 599 | public class LinkedTransferQueueTest ext
599          it.remove();
600  
601          it = q.iterator();
602 <        assertEquals(it.next(), one);
603 <        assertEquals(it.next(), three);
602 >        assertSame(it.next(), one);
603 >        assertSame(it.next(), three);
604          assertFalse(it.hasNext());
605      }
606  
# Line 677 | Line 658 | public class LinkedTransferQueueTest ext
658          ExecutorService executor = Executors.newFixedThreadPool(2);
659  
660          executor.execute(new CheckedRunnable() {
661 <            void realRun() {
662 <                threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS,
682 <                                         MILLISECONDS));
661 >            public void realRun() {
662 >                assertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS));
663              }});
664  
665          executor.execute(new CheckedRunnable() {
666 <            void realRun() throws InterruptedException {
666 >            public void realRun() throws InterruptedException {
667                  Thread.sleep(SMALL_DELAY_MS);
668 <                threadAssertEquals(one, q.take());
668 >                assertSame(one, q.take());
669              }});
670  
671          joinPool(executor);
672      }
673  
674      /**
675 <     * poll retrieves elements across Executor threads
675 >     * timed poll retrieves elements across Executor threads
676       */
677      public void testPollInExecutor() {
678          final LinkedTransferQueue q = new LinkedTransferQueue();
679          ExecutorService executor = Executors.newFixedThreadPool(2);
680  
681          executor.execute(new CheckedRunnable() {
682 <            void realRun() throws InterruptedException {
683 <                threadAssertNull(q.poll());
684 <                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS,
685 <                                                MILLISECONDS));
706 <                threadAssertTrue(q.isEmpty());
682 >            public void realRun() throws InterruptedException {
683 >                assertNull(q.poll());
684 >                assertSame(one, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
685 >                assertTrue(q.isEmpty());
686              }});
687  
688          executor.execute(new CheckedRunnable() {
689 <            void realRun() throws InterruptedException {
689 >            public void realRun() throws InterruptedException {
690                  Thread.sleep(SMALL_DELAY_MS);
691                  q.put(one);
692              }});
# Line 747 | Line 726 | public class LinkedTransferQueueTest ext
726          try {
727              q.drainTo(null);
728              shouldThrow();
729 <        } catch (NullPointerException success) {
751 <        }
729 >        } catch (NullPointerException success) {}
730      }
731  
732      /**
# Line 759 | Line 737 | public class LinkedTransferQueueTest ext
737          try {
738              q.drainTo(q);
739              shouldThrow();
740 <        } catch (IllegalArgumentException success) {
763 <        }
740 >        } catch (IllegalArgumentException success) {}
741      }
742  
743      /**
# Line 790 | Line 767 | public class LinkedTransferQueueTest ext
767      }
768  
769      /**
770 <     * drainTo empties full queue, unblocking a waiting put.
770 >     * drainTo(c) empties full queue, unblocking a waiting put.
771       */
772      public void testDrainToWithActivePut() throws InterruptedException {
773          final LinkedTransferQueue q = populatedQueue(SIZE);
774          Thread t = newStartedThread(new CheckedRunnable() {
775 <            void realRun() {
775 >            public void realRun() {
776                  q.put(SIZE + 1);
777              }});
778          ArrayList l = new ArrayList();
# Line 816 | Line 793 | public class LinkedTransferQueueTest ext
793          try {
794              q.drainTo(null, SIZE);
795              shouldThrow();
796 <        } catch (NullPointerException success) {
820 <        }
796 >        } catch (NullPointerException success) {}
797      }
798  
799      /**
# Line 828 | Line 804 | public class LinkedTransferQueueTest ext
804          try {
805              q.drainTo(q, SIZE);
806              shouldThrow();
807 <        } catch (IllegalArgumentException success) {
832 <        }
807 >        } catch (IllegalArgumentException success) {}
808      }
809  
810      /**
811 <     * drainTo(c, n) empties first max {n, size} elements of queue into c
811 >     * drainTo(c, n) empties first min(n, size) elements of queue into c
812       */
813      public void testDrainToN() {
814          LinkedTransferQueue q = new LinkedTransferQueue();
# Line 855 | Line 830 | public class LinkedTransferQueueTest ext
830      }
831  
832      /**
833 <     * poll and take decrement the waiting consumer count
833 >     * timed poll() or take() increments the waiting consumer count;
834 >     * offer(e) decrements the waiting consumer count
835       */
836      public void testWaitingConsumer() throws InterruptedException {
837          final LinkedTransferQueue q = new LinkedTransferQueue();
838 <        final ConsumerObserver waiting = new ConsumerObserver();
838 >        assertEquals(q.getWaitingConsumerCount(), 0);
839 >        assertFalse(q.hasWaitingConsumer());
840  
841          Thread t = newStartedThread(new CheckedRunnable() {
842 <            void realRun() throws InterruptedException {
842 >            public void realRun() throws InterruptedException {
843                  Thread.sleep(SMALL_DELAY_MS);
844 <                threadAssertTrue(q.hasWaitingConsumer());
845 <                waiting.setWaitingConsumer(q.getWaitingConsumerCount());
846 <                threadAssertTrue(q.offer(new Object()));
844 >                assertTrue(q.hasWaitingConsumer());
845 >                assertEquals(q.getWaitingConsumerCount(), 1);
846 >                assertTrue(q.offer(one));
847 >                assertFalse(q.hasWaitingConsumer());
848 >                assertEquals(q.getWaitingConsumerCount(), 0);
849              }});
850  
851 <        assertTrue(q.poll(LONG_DELAY_MS, MILLISECONDS) != null);
852 <        assertTrue(q.getWaitingConsumerCount()
853 <                   < waiting.getWaitingConsumers());
851 >        assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
852 >        assertEquals(q.getWaitingConsumerCount(), 0);
853 >        assertFalse(q.hasWaitingConsumer());
854          t.join();
855      }
856  
# Line 883 | Line 862 | public class LinkedTransferQueueTest ext
862              LinkedTransferQueue q = new LinkedTransferQueue();
863              q.transfer(null);
864              shouldThrow();
865 <        } catch (NullPointerException ex) {
887 <        }
865 >        } catch (NullPointerException success) {}
866      }
867  
868      /**
# Line 896 | Line 874 | public class LinkedTransferQueueTest ext
874              = new LinkedTransferQueue<Integer>();
875  
876          Thread t = newStartedThread(new CheckedRunnable() {
877 <            void realRun() throws InterruptedException {
877 >            public void realRun() throws InterruptedException {
878                  q.transfer(SIZE);
879 <                threadAssertTrue(q.isEmpty());
879 >                assertTrue(q.isEmpty());
880              }});
881  
882          Thread.sleep(SHORT_DELAY_MS);
# Line 916 | Line 894 | public class LinkedTransferQueueTest ext
894              = new LinkedTransferQueue<Integer>();
895  
896          Thread first = newStartedThread(new CheckedRunnable() {
897 <            void realRun() throws InterruptedException {
897 >            public void realRun() throws InterruptedException {
898                  Integer i = SIZE + 1;
899                  q.transfer(i);
900 <                threadAssertTrue(!q.contains(i));
901 <                threadAssertEquals(1, q.size());
900 >                assertTrue(!q.contains(i));
901 >                assertEquals(1, q.size());
902              }});
903  
904          Thread interruptedThread = newStartedThread(
905              new CheckedInterruptedRunnable() {
906 <                void realRun() throws InterruptedException {
906 >                public void realRun() throws InterruptedException {
907                      while (q.size() == 0)
908                          Thread.yield();
909                      q.transfer(SIZE);
# Line 951 | Line 929 | public class LinkedTransferQueueTest ext
929          final LinkedTransferQueue q = new LinkedTransferQueue();
930  
931          Thread t = newStartedThread(new CheckedRunnable() {
932 <            void realRun() throws InterruptedException {
932 >            public void realRun() throws InterruptedException {
933                  q.transfer(four);
934 <                threadAssertFalse(q.contains(four));
935 <                threadAssertEquals(three, q.poll());
934 >                assertFalse(q.contains(four));
935 >                assertSame(three, q.poll());
936              }});
937  
938          Thread.sleep(SHORT_DELAY_MS);
939          assertTrue(q.offer(three));
940 <        assertEquals(four, q.poll());
940 >        assertSame(four, q.poll());
941          t.join();
942      }
943  
# Line 972 | Line 950 | public class LinkedTransferQueueTest ext
950              = new LinkedTransferQueue<Integer>();
951  
952          Thread t = newStartedThread(new CheckedRunnable() {
953 <            void realRun() throws InterruptedException {
953 >            public void realRun() throws InterruptedException {
954                  q.transfer(SIZE);
955                  checkEmpty(q);
956              }});
# Line 991 | Line 969 | public class LinkedTransferQueueTest ext
969              final LinkedTransferQueue q = new LinkedTransferQueue();
970              q.tryTransfer(null);
971              shouldThrow();
972 <        } catch (NullPointerException ex) {
995 <        }
972 >        } catch (NullPointerException success) {}
973      }
974  
975      /**
# Line 1015 | Line 992 | public class LinkedTransferQueueTest ext
992          final LinkedTransferQueue q = new LinkedTransferQueue();
993  
994          Thread t = newStartedThread(new CheckedRunnable() {
995 <            void realRun() {
995 >            public void realRun() {
996                  while (! q.hasWaitingConsumer())
997                      Thread.yield();
998 <                threadAssertTrue(q.hasWaitingConsumer());
999 <                threadAssertTrue(q.isEmpty());
1000 <                threadAssertTrue(q.size() == 0);
1001 <                threadAssertTrue(q.tryTransfer(hotPotato));
998 >                assertTrue(q.hasWaitingConsumer());
999 >                assertTrue(q.isEmpty());
1000 >                assertEquals(q.size(), 0);
1001 >                assertTrue(q.tryTransfer(hotPotato));
1002              }});
1003  
1004 <        assertTrue(q.poll(MEDIUM_DELAY_MS, MILLISECONDS) == hotPotato);
1004 >        assertSame(hotPotato, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
1005          checkEmpty(q);
1006          t.join();
1007      }
# Line 1038 | Line 1015 | public class LinkedTransferQueueTest ext
1015          final LinkedTransferQueue q = new LinkedTransferQueue();
1016  
1017          Thread t = newStartedThread(new CheckedRunnable() {
1018 <            void realRun() {
1018 >            public void realRun() {
1019                  while (! q.hasWaitingConsumer())
1020                      Thread.yield();
1021 <                threadAssertTrue(q.hasWaitingConsumer());
1022 <                threadAssertTrue(q.isEmpty());
1023 <                threadAssertTrue(q.size() == 0);
1024 <                threadAssertTrue(q.tryTransfer(hotPotato));
1021 >                assertTrue(q.hasWaitingConsumer());
1022 >                assertTrue(q.isEmpty());
1023 >                assertEquals(q.size(), 0);
1024 >                assertTrue(q.tryTransfer(hotPotato));
1025              }});
1026  
1027 <        assertTrue(q.take() == hotPotato);
1027 >        assertSame(q.take(), hotPotato);
1028          checkEmpty(q);
1029          t.join();
1030      }
# Line 1060 | Line 1037 | public class LinkedTransferQueueTest ext
1037          final LinkedTransferQueue q = new LinkedTransferQueue();
1038  
1039          Thread toInterrupt = newStartedThread(new CheckedInterruptedRunnable() {
1040 <            void realRun() throws InterruptedException {
1040 >            public void realRun() throws InterruptedException {
1041                  q.tryTransfer(new Object(), LONG_DELAY_MS, MILLISECONDS);
1042              }});
1043  
# Line 1076 | Line 1053 | public class LinkedTransferQueueTest ext
1053          final LinkedTransferQueue q = new LinkedTransferQueue();
1054  
1055          Thread t = newStartedThread(new CheckedRunnable() {
1056 <            void realRun() throws InterruptedException {
1057 <                threadAssertFalse
1058 <                    (q.tryTransfer(new Object(),
1059 <                                   SHORT_DELAY_MS, MILLISECONDS));
1056 >            public void realRun() throws InterruptedException {
1057 >                long t0 = System.nanoTime();
1058 >                assertFalse(q.tryTransfer(new Object(),
1059 >                                          SHORT_DELAY_MS, MILLISECONDS));
1060 >                long elapsed = NANOSECONDS.toMillis(System.nanoTime() - t0);
1061 >                assertTrue(elapsed >= SHORT_DELAY_MS);
1062              }});
1063  
1085        Thread.sleep(SMALL_DELAY_MS);
1064          checkEmpty(q);
1065 <        t.join();
1065 >        awaitTermination(t, MEDIUM_DELAY_MS);
1066 >        checkEmpty(q);
1067      }
1068  
1069      /**
# Line 1096 | Line 1075 | public class LinkedTransferQueueTest ext
1075          assertTrue(q.offer(four));
1076  
1077          Thread t = newStartedThread(new CheckedRunnable() {
1078 <            void realRun() throws InterruptedException {
1079 <                threadAssertTrue(q.tryTransfer(five,
1080 <                                               MEDIUM_DELAY_MS, MILLISECONDS));
1102 <                threadAssertTrue(q.isEmpty());
1078 >            public void realRun() throws InterruptedException {
1079 >                assertTrue(q.tryTransfer(five, MEDIUM_DELAY_MS, MILLISECONDS));
1080 >                assertTrue(q.isEmpty());
1081              }});
1082  
1083          Thread.sleep(SHORT_DELAY_MS);
1084          assertEquals(2, q.size());
1085 <        assertEquals(four, q.poll());
1086 <        assertEquals(five, q.poll());
1085 >        assertSame(four, q.poll());
1086 >        assertSame(five, q.poll());
1087          checkEmpty(q);
1088          t.join();
1089      }
# Line 1120 | Line 1098 | public class LinkedTransferQueueTest ext
1098          assertEquals(1, q.size());
1099          assertFalse(q.tryTransfer(five, SHORT_DELAY_MS, MILLISECONDS));
1100          assertEquals(1, q.size());
1101 <        assertEquals(four, q.poll());
1124 <        checkEmpty(q);
1101 >        assertSame(four, q.poll());
1102          assertNull(q.poll());
1103 +        checkEmpty(q);
1104      }
1105  
1106      private LinkedTransferQueue<Integer> populatedQueue(int n) {
# Line 1136 | Line 1114 | public class LinkedTransferQueueTest ext
1114          assertFalse(q.isEmpty());
1115          return q;
1116      }
1139
1140    private static class ConsumerObserver {
1141
1142        private int waitingConsumers;
1143
1144        private ConsumerObserver() {
1145        }
1146
1147        private void setWaitingConsumer(int i) {
1148            this.waitingConsumers = i;
1149        }
1150
1151        private int getWaitingConsumers() {
1152            return waitingConsumers;
1153        }
1154    }
1117   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines