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.16 by jsr166, Sat Nov 21 19:11:53 2009 UTC vs.
Revision 1.29 by jsr166, Thu Oct 28 19:05:04 2010 UTC

# Line 18 | Line 18 | 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 44 | Line 52 | public class LinkedTransferQueueTest ext
52          try {
53              q.element();
54              shouldThrow();
55 <        } catch (NoSuchElementException success) {
48 <        }
55 >        } catch (NoSuchElementException success) {}
56          try {
57              q.iterator().next();
58              shouldThrow();
59 <        } catch (NoSuchElementException success) {
53 <        }
59 >        } catch (NoSuchElementException success) {}
60          try {
61              q.remove();
62              shouldThrow();
63 <        } catch (NoSuchElementException success) {
58 <        }
63 >        } catch (NoSuchElementException success) {}
64      }
65  
66      /**
# Line 75 | Line 80 | public class LinkedTransferQueueTest ext
80          try {
81              new LinkedTransferQueue(null);
82              shouldThrow();
83 <        } catch (NullPointerException success) {
79 <        }
83 >        } catch (NullPointerException success) {}
84      }
85  
86      /**
# Line 88 | Line 92 | public class LinkedTransferQueueTest ext
92              Integer[] ints = new Integer[SIZE];
93              new LinkedTransferQueue(Arrays.asList(ints));
94              shouldThrow();
95 <        } catch (NullPointerException success) {
92 <        }
95 >        } catch (NullPointerException success) {}
96      }
97  
98      /**
# Line 104 | Line 107 | public class LinkedTransferQueueTest ext
107              }
108              new LinkedTransferQueue(Arrays.asList(ints));
109              shouldThrow();
110 <        } catch (NullPointerException success) {
108 <        }
110 >        } catch (NullPointerException success) {}
111      }
112  
113      /**
# Line 157 | Line 159 | public class LinkedTransferQueueTest ext
159              LinkedTransferQueue q = new LinkedTransferQueue();
160              q.offer(null);
161              shouldThrow();
162 <        } catch (NullPointerException success) {
161 <        }
162 >        } catch (NullPointerException success) {}
163      }
164  
165      /**
# Line 169 | Line 170 | public class LinkedTransferQueueTest ext
170              LinkedTransferQueue q = new LinkedTransferQueue();
171              q.add(null);
172              shouldThrow();
173 <        } catch (NullPointerException success) {
173 <        }
173 >        } catch (NullPointerException success) {}
174      }
175  
176      /**
# Line 181 | Line 181 | public class LinkedTransferQueueTest ext
181              LinkedTransferQueue q = new LinkedTransferQueue();
182              q.addAll(null);
183              shouldThrow();
184 <        } catch (NullPointerException success) {
185 <        }
184 >        } catch (NullPointerException success) {}
185      }
186  
187      /**
# Line 193 | Line 192 | public class LinkedTransferQueueTest ext
192              LinkedTransferQueue q = populatedQueue(SIZE);
193              q.addAll(q);
194              shouldThrow();
195 <        } catch (IllegalArgumentException success) {
197 <        }
195 >        } catch (IllegalArgumentException success) {}
196      }
197  
198      /**
# Line 206 | Line 204 | public class LinkedTransferQueueTest ext
204              Integer[] ints = new Integer[SIZE];
205              q.addAll(Arrays.asList(ints));
206              shouldThrow();
207 <        } catch (NullPointerException success) {
210 <        }
207 >        } catch (NullPointerException success) {}
208      }
209  
210      /**
# Line 223 | Line 220 | public class LinkedTransferQueueTest ext
220              }
221              q.addAll(Arrays.asList(ints));
222              shouldThrow();
223 <        } catch (NullPointerException success) {
227 <        }
223 >        } catch (NullPointerException success) {}
224      }
225  
226      /**
# Line 278 | Line 274 | public class LinkedTransferQueueTest ext
274      }
275  
276      /**
277 <     * take blocks interruptibly when empty
282 <     */
283 <    public void testTakeFromEmpty() throws InterruptedException {
284 <        final LinkedTransferQueue q = new LinkedTransferQueue();
285 <        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
286 <            void realRun() throws InterruptedException {
287 <                q.take();
288 <            }});
289 <        Thread.sleep(SHORT_DELAY_MS);
290 <        t.interrupt();
291 <        t.join();
292 <    }
293 <
294 <    /**
295 <     * Take removes existing elements until empty, then blocks interruptibly
277 >     * take removes existing elements until empty, then blocks interruptibly
278       */
279      public void testBlockingTake() throws InterruptedException {
280          final LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
281 <        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
282 <            void realRun() throws InterruptedException {
281 >        Thread t = new Thread(new CheckedRunnable() {
282 >            public void realRun() throws InterruptedException {
283                  for (int i = 0; i < SIZE; ++i) {
284 <                    threadAssertEquals(i, (int) q.take());
284 >                    assertEquals(i, (int) q.take());
285                  }
286 <                q.take();
286 >                try {
287 >                    q.take();
288 >                    shouldThrow();
289 >                } catch (InterruptedException success) {}
290              }});
291 <        Thread.sleep(SMALL_DELAY_MS);
291 >
292 >        t.start();
293 >        Thread.sleep(SHORT_DELAY_MS);
294          t.interrupt();
295 <        t.join();
295 >        awaitTermination(t, MEDIUM_DELAY_MS);
296          checkEmpty(q);
297      }
298  
# Line 341 | Line 328 | public class LinkedTransferQueueTest ext
328          for (int i = 0; i < SIZE; ++i) {
329              long t0 = System.nanoTime();
330              assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
331 <            long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024);
345 <            assertTrue(millisElapsed < SMALL_DELAY_MS);
331 >            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
332          }
333          assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
334          checkEmpty(q);
# Line 355 | Line 341 | public class LinkedTransferQueueTest ext
341      public void testInterruptedTimedPoll() throws InterruptedException {
342          final LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
343          Thread t = newStartedThread(new CheckedRunnable() {
344 <            void realRun() throws InterruptedException {
344 >            public void realRun() throws InterruptedException {
345                  for (int i = 0; i < SIZE; ++i) {
346                      long t0 = System.nanoTime();
347 <                    threadAssertEquals(i, (int) q.poll(LONG_DELAY_MS,
348 <                                                       MILLISECONDS));
363 <                    long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024);
364 <                    assertTrue(millisElapsed < SMALL_DELAY_MS);
347 >                    assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
348 >                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
349                  }
350                  try {
351                      q.poll(LONG_DELAY_MS, MILLISECONDS);
352 +                    shouldThrow();
353                  } catch (InterruptedException success) {}
354              }});
370        Thread.sleep(SMALL_DELAY_MS);
371        t.interrupt();
372        t.join();
373        checkEmpty(q);
374    }
355  
376    /**
377     * timed poll before a delayed offer fails; after offer succeeds;
378     * on interruption throws
379     */
380    public void testTimedPollWithOffer() throws InterruptedException {
381        final LinkedTransferQueue q = new LinkedTransferQueue();
382        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
383            void realRun() throws InterruptedException {
384                threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
385                q.poll(LONG_DELAY_MS, MILLISECONDS);
386                q.poll(LONG_DELAY_MS, MILLISECONDS);
387            }});
356          Thread.sleep(SMALL_DELAY_MS);
389        assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS));
357          t.interrupt();
358 <        t.join();
358 >        awaitTermination(t, MEDIUM_DELAY_MS);
359 >        checkEmpty(q);
360      }
361  
362      /**
# Line 418 | Line 386 | public class LinkedTransferQueueTest ext
386          try {
387              q.element();
388              shouldThrow();
389 <        } catch (NoSuchElementException success) {
422 <        }
389 >        } catch (NoSuchElementException success) {}
390          checkEmpty(q);
391      }
392  
# Line 434 | Line 401 | public class LinkedTransferQueueTest ext
401          try {
402              q.remove();
403              shouldThrow();
404 <        } catch (NoSuchElementException success) {
438 <        }
404 >        } catch (NoSuchElementException success) {}
405          checkEmpty(q);
406      }
407  
# Line 464 | Line 430 | public class LinkedTransferQueueTest ext
430          assertTrue(q.remove(one));
431          assertTrue(q.remove(two));
432          assertTrue(q.add(three));
433 <        assertTrue(q.take() == three);
433 >        assertSame(q.take(), three);
434      }
435  
436      /**
# Line 572 | Line 538 | public class LinkedTransferQueueTest ext
538       * toArray(null) throws NullPointerException
539       */
540      public void testToArray_BadArg() {
541 +        LinkedTransferQueue q = populatedQueue(SIZE);
542          try {
576            LinkedTransferQueue q = populatedQueue(SIZE);
543              Object o[] = q.toArray(null);
544              shouldThrow();
545 <        } catch (NullPointerException success) {
580 <        }
545 >        } catch (NullPointerException success) {}
546      }
547  
548      /**
549       * toArray(incompatible array type) throws CCE
550       */
551      public void testToArray1_BadArg() {
552 +        LinkedTransferQueue q = populatedQueue(SIZE);
553          try {
588            LinkedTransferQueue q = populatedQueue(SIZE);
554              Object o[] = q.toArray(new String[10]);
555              shouldThrow();
556 <        } catch (ArrayStoreException success) {
592 <        }
556 >        } catch (ArrayStoreException success) {}
557      }
558  
559      /**
# Line 619 | Line 583 | public class LinkedTransferQueueTest ext
583          it.remove();
584  
585          it = q.iterator();
586 <        assertEquals(it.next(), one);
587 <        assertEquals(it.next(), three);
586 >        assertSame(it.next(), one);
587 >        assertSame(it.next(), three);
588          assertFalse(it.hasNext());
589      }
590  
# Line 678 | Line 642 | public class LinkedTransferQueueTest ext
642          ExecutorService executor = Executors.newFixedThreadPool(2);
643  
644          executor.execute(new CheckedRunnable() {
645 <            void realRun() {
646 <                threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS,
683 <                                         MILLISECONDS));
645 >            public void realRun() {
646 >                assertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS));
647              }});
648  
649          executor.execute(new CheckedRunnable() {
650 <            void realRun() throws InterruptedException {
650 >            public void realRun() throws InterruptedException {
651                  Thread.sleep(SMALL_DELAY_MS);
652 <                threadAssertEquals(one, q.take());
652 >                assertSame(one, q.take());
653              }});
654  
655          joinPool(executor);
# Line 700 | Line 663 | public class LinkedTransferQueueTest ext
663          ExecutorService executor = Executors.newFixedThreadPool(2);
664  
665          executor.execute(new CheckedRunnable() {
666 <            void realRun() throws InterruptedException {
667 <                threadAssertNull(q.poll());
668 <                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS,
669 <                                                MILLISECONDS));
707 <                threadAssertTrue(q.isEmpty());
666 >            public void realRun() throws InterruptedException {
667 >                assertNull(q.poll());
668 >                assertSame(one, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
669 >                assertTrue(q.isEmpty());
670              }});
671  
672          executor.execute(new CheckedRunnable() {
673 <            void realRun() throws InterruptedException {
673 >            public void realRun() throws InterruptedException {
674                  Thread.sleep(SMALL_DELAY_MS);
675                  q.put(one);
676              }});
# Line 748 | Line 710 | public class LinkedTransferQueueTest ext
710          try {
711              q.drainTo(null);
712              shouldThrow();
713 <        } catch (NullPointerException success) {
752 <        }
713 >        } catch (NullPointerException success) {}
714      }
715  
716      /**
# Line 760 | Line 721 | public class LinkedTransferQueueTest ext
721          try {
722              q.drainTo(q);
723              shouldThrow();
724 <        } catch (IllegalArgumentException success) {
764 <        }
724 >        } catch (IllegalArgumentException success) {}
725      }
726  
727      /**
# Line 796 | Line 756 | public class LinkedTransferQueueTest ext
756      public void testDrainToWithActivePut() throws InterruptedException {
757          final LinkedTransferQueue q = populatedQueue(SIZE);
758          Thread t = newStartedThread(new CheckedRunnable() {
759 <            void realRun() {
759 >            public void realRun() {
760                  q.put(SIZE + 1);
761              }});
762          ArrayList l = new ArrayList();
# Line 805 | Line 765 | public class LinkedTransferQueueTest ext
765          for (int i = 0; i < SIZE; ++i) {
766              assertEquals(l.get(i), i);
767          }
768 <        t.join();
768 >        awaitTermination(t, MEDIUM_DELAY_MS);
769          assertTrue(q.size() + l.size() >= SIZE);
770      }
771  
# Line 817 | Line 777 | public class LinkedTransferQueueTest ext
777          try {
778              q.drainTo(null, SIZE);
779              shouldThrow();
780 <        } catch (NullPointerException success) {
821 <        }
780 >        } catch (NullPointerException success) {}
781      }
782  
783      /**
# Line 829 | Line 788 | public class LinkedTransferQueueTest ext
788          try {
789              q.drainTo(q, SIZE);
790              shouldThrow();
791 <        } catch (IllegalArgumentException success) {
833 <        }
791 >        } catch (IllegalArgumentException success) {}
792      }
793  
794      /**
795 <     * drainTo(c, n) empties first max {n, size} elements of queue into c
795 >     * drainTo(c, n) empties first min(n, size) elements of queue into c
796       */
797      public void testDrainToN() {
798          LinkedTransferQueue q = new LinkedTransferQueue();
# Line 865 | Line 823 | public class LinkedTransferQueueTest ext
823          assertFalse(q.hasWaitingConsumer());
824  
825          Thread t = newStartedThread(new CheckedRunnable() {
826 <            void realRun() throws InterruptedException {
826 >            public void realRun() throws InterruptedException {
827                  Thread.sleep(SMALL_DELAY_MS);
828 <                threadAssertTrue(q.hasWaitingConsumer());
829 <                threadAssertEquals(q.getWaitingConsumerCount(), 1);
830 <                threadAssertTrue(q.offer(new Object()));
831 <                threadAssertFalse(q.hasWaitingConsumer());
832 <                threadAssertEquals(q.getWaitingConsumerCount(), 0);
828 >                assertTrue(q.hasWaitingConsumer());
829 >                assertEquals(q.getWaitingConsumerCount(), 1);
830 >                assertTrue(q.offer(one));
831 >                assertFalse(q.hasWaitingConsumer());
832 >                assertEquals(q.getWaitingConsumerCount(), 0);
833              }});
834  
835 <        assertTrue(q.poll(LONG_DELAY_MS, MILLISECONDS) != null);
835 >        assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
836          assertEquals(q.getWaitingConsumerCount(), 0);
837          assertFalse(q.hasWaitingConsumer());
838 <        t.join();
838 >        awaitTermination(t, MEDIUM_DELAY_MS);
839      }
840  
841      /**
# Line 900 | Line 858 | public class LinkedTransferQueueTest ext
858              = new LinkedTransferQueue<Integer>();
859  
860          Thread t = newStartedThread(new CheckedRunnable() {
861 <            void realRun() throws InterruptedException {
861 >            public void realRun() throws InterruptedException {
862                  q.transfer(SIZE);
863 <                threadAssertTrue(q.isEmpty());
863 >                assertTrue(q.isEmpty());
864              }});
865  
866          Thread.sleep(SHORT_DELAY_MS);
867          assertEquals(1, q.size());
868          assertEquals(SIZE, (int) q.poll());
869          assertTrue(q.isEmpty());
870 <        t.join();
870 >        awaitTermination(t, MEDIUM_DELAY_MS);
871      }
872  
873      /**
# Line 920 | Line 878 | public class LinkedTransferQueueTest ext
878              = new LinkedTransferQueue<Integer>();
879  
880          Thread first = newStartedThread(new CheckedRunnable() {
881 <            void realRun() throws InterruptedException {
881 >            public void realRun() throws InterruptedException {
882                  Integer i = SIZE + 1;
883                  q.transfer(i);
884 <                threadAssertTrue(!q.contains(i));
885 <                threadAssertEquals(1, q.size());
884 >                assertTrue(!q.contains(i));
885 >                assertEquals(1, q.size());
886              }});
887  
888          Thread interruptedThread = newStartedThread(
889              new CheckedInterruptedRunnable() {
890 <                void realRun() throws InterruptedException {
890 >                public void realRun() throws InterruptedException {
891                      while (q.size() == 0)
892                          Thread.yield();
893                      q.transfer(SIZE);
# Line 955 | Line 913 | public class LinkedTransferQueueTest ext
913          final LinkedTransferQueue q = new LinkedTransferQueue();
914  
915          Thread t = newStartedThread(new CheckedRunnable() {
916 <            void realRun() throws InterruptedException {
916 >            public void realRun() throws InterruptedException {
917                  q.transfer(four);
918 <                threadAssertFalse(q.contains(four));
919 <                threadAssertEquals(three, q.poll());
918 >                assertFalse(q.contains(four));
919 >                assertSame(three, q.poll());
920              }});
921  
922          Thread.sleep(SHORT_DELAY_MS);
923          assertTrue(q.offer(three));
924 <        assertEquals(four, q.poll());
925 <        t.join();
924 >        assertSame(four, q.poll());
925 >        awaitTermination(t, MEDIUM_DELAY_MS);
926      }
927  
928      /**
# Line 976 | Line 934 | public class LinkedTransferQueueTest ext
934              = new LinkedTransferQueue<Integer>();
935  
936          Thread t = newStartedThread(new CheckedRunnable() {
937 <            void realRun() throws InterruptedException {
937 >            public void realRun() throws InterruptedException {
938                  q.transfer(SIZE);
939                  checkEmpty(q);
940              }});
# Line 984 | Line 942 | public class LinkedTransferQueueTest ext
942          Thread.sleep(SHORT_DELAY_MS);
943          assertEquals(SIZE, (int) q.take());
944          checkEmpty(q);
945 <        t.join();
945 >        awaitTermination(t, MEDIUM_DELAY_MS);
946      }
947  
948      /**
# Line 1018 | Line 976 | public class LinkedTransferQueueTest ext
976          final LinkedTransferQueue q = new LinkedTransferQueue();
977  
978          Thread t = newStartedThread(new CheckedRunnable() {
979 <            void realRun() {
979 >            public void realRun() {
980                  while (! q.hasWaitingConsumer())
981                      Thread.yield();
982 <                threadAssertTrue(q.hasWaitingConsumer());
983 <                threadAssertTrue(q.isEmpty());
984 <                threadAssertTrue(q.size() == 0);
985 <                threadAssertTrue(q.tryTransfer(hotPotato));
982 >                assertTrue(q.hasWaitingConsumer());
983 >                assertTrue(q.isEmpty());
984 >                assertEquals(q.size(), 0);
985 >                assertTrue(q.tryTransfer(hotPotato));
986              }});
987  
988 <        assertTrue(q.poll(MEDIUM_DELAY_MS, MILLISECONDS) == hotPotato);
988 >        assertSame(hotPotato, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
989          checkEmpty(q);
990 <        t.join();
990 >        awaitTermination(t, MEDIUM_DELAY_MS);
991      }
992  
993      /**
# Line 1041 | Line 999 | public class LinkedTransferQueueTest ext
999          final LinkedTransferQueue q = new LinkedTransferQueue();
1000  
1001          Thread t = newStartedThread(new CheckedRunnable() {
1002 <            void realRun() {
1002 >            public void realRun() {
1003                  while (! q.hasWaitingConsumer())
1004                      Thread.yield();
1005 <                threadAssertTrue(q.hasWaitingConsumer());
1006 <                threadAssertTrue(q.isEmpty());
1007 <                threadAssertTrue(q.size() == 0);
1008 <                threadAssertTrue(q.tryTransfer(hotPotato));
1005 >                assertTrue(q.hasWaitingConsumer());
1006 >                assertTrue(q.isEmpty());
1007 >                assertEquals(q.size(), 0);
1008 >                assertTrue(q.tryTransfer(hotPotato));
1009              }});
1010  
1011 <        assertTrue(q.take() == hotPotato);
1011 >        assertSame(q.take(), hotPotato);
1012          checkEmpty(q);
1013 <        t.join();
1013 >        awaitTermination(t, MEDIUM_DELAY_MS);
1014      }
1015  
1016      /**
# Line 1063 | Line 1021 | public class LinkedTransferQueueTest ext
1021          final LinkedTransferQueue q = new LinkedTransferQueue();
1022  
1023          Thread toInterrupt = newStartedThread(new CheckedInterruptedRunnable() {
1024 <            void realRun() throws InterruptedException {
1024 >            public void realRun() throws InterruptedException {
1025                  q.tryTransfer(new Object(), LONG_DELAY_MS, MILLISECONDS);
1026              }});
1027  
# Line 1079 | Line 1037 | public class LinkedTransferQueueTest ext
1037          final LinkedTransferQueue q = new LinkedTransferQueue();
1038  
1039          Thread t = newStartedThread(new CheckedRunnable() {
1040 <            void realRun() throws InterruptedException {
1041 <                threadAssertFalse
1042 <                    (q.tryTransfer(new Object(),
1043 <                                   SHORT_DELAY_MS, MILLISECONDS));
1040 >            public void realRun() throws InterruptedException {
1041 >                long t0 = System.nanoTime();
1042 >                assertFalse(q.tryTransfer(new Object(),
1043 >                                          SHORT_DELAY_MS, MILLISECONDS));
1044 >                assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS);
1045              }});
1046  
1088        Thread.sleep(SMALL_DELAY_MS);
1047          checkEmpty(q);
1048 <        t.join();
1048 >        awaitTermination(t, MEDIUM_DELAY_MS);
1049 >        checkEmpty(q);
1050      }
1051  
1052      /**
# Line 1099 | Line 1058 | public class LinkedTransferQueueTest ext
1058          assertTrue(q.offer(four));
1059  
1060          Thread t = newStartedThread(new CheckedRunnable() {
1061 <            void realRun() throws InterruptedException {
1062 <                threadAssertTrue(q.tryTransfer(five,
1063 <                                               MEDIUM_DELAY_MS, MILLISECONDS));
1105 <                threadAssertTrue(q.isEmpty());
1061 >            public void realRun() throws InterruptedException {
1062 >                assertTrue(q.tryTransfer(five, MEDIUM_DELAY_MS, MILLISECONDS));
1063 >                assertTrue(q.isEmpty());
1064              }});
1065  
1066          Thread.sleep(SHORT_DELAY_MS);
1067          assertEquals(2, q.size());
1068 <        assertEquals(four, q.poll());
1069 <        assertEquals(five, q.poll());
1068 >        assertSame(four, q.poll());
1069 >        assertSame(five, q.poll());
1070          checkEmpty(q);
1071 <        t.join();
1071 >        awaitTermination(t, MEDIUM_DELAY_MS);
1072      }
1073  
1074      /**
# Line 1123 | Line 1081 | public class LinkedTransferQueueTest ext
1081          assertEquals(1, q.size());
1082          assertFalse(q.tryTransfer(five, SHORT_DELAY_MS, MILLISECONDS));
1083          assertEquals(1, q.size());
1084 <        assertEquals(four, q.poll());
1084 >        assertSame(four, q.poll());
1085          assertNull(q.poll());
1086          checkEmpty(q);
1087      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines