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

Comparing jsr166/src/test/tck/LinkedBlockingDequeTest.java (file contents):
Revision 1.17 by jsr166, Sun Nov 22 00:17:37 2009 UTC vs.
Revision 1.29 by jsr166, Wed Nov 3 07:54:52 2010 UTC

# Line 11 | Line 11 | import static java.util.concurrent.TimeU
11   import java.io.*;
12  
13   public class LinkedBlockingDequeTest extends JSR166TestCase {
14 +
15 +    public static class Unbounded extends BlockingQueueTest {
16 +        protected BlockingQueue emptyCollection() {
17 +            return new LinkedBlockingDeque();
18 +        }
19 +    }
20 +
21 +    public static class Bounded extends BlockingQueueTest {
22 +        protected BlockingQueue emptyCollection() {
23 +            return new LinkedBlockingDeque(20);
24 +        }
25 +    }
26 +
27      public static void main(String[] args) {
28 <        junit.textui.TestRunner.run (suite());
28 >        junit.textui.TestRunner.run(suite());
29      }
30  
31      public static Test suite() {
32 <        return new TestSuite(LinkedBlockingDequeTest.class);
32 >        return newTestSuite(LinkedBlockingDequeTest.class,
33 >                            new Unbounded().testSuite(),
34 >                            new Bounded().testSuite());
35      }
36  
37      /**
# Line 93 | Line 108 | public class LinkedBlockingDequeTest ext
108      }
109  
110      /**
111 <     *  pollFirst succeeds unless empty
111 >     * pollFirst succeeds unless empty
112       */
113      public void testPollFirst() {
114          LinkedBlockingDeque q = populatedDeque(SIZE);
115          for (int i = 0; i < SIZE; ++i) {
116 <            assertEquals(i, ((Integer)q.pollFirst()).intValue());
116 >            assertEquals(i, q.pollFirst());
117          }
118          assertNull(q.pollFirst());
119      }
120  
121      /**
122 <     *  pollLast succeeds unless empty
122 >     * pollLast succeeds unless empty
123       */
124      public void testPollLast() {
125          LinkedBlockingDeque q = populatedDeque(SIZE);
126          for (int i = SIZE-1; i >= 0; --i) {
127 <            assertEquals(i, ((Integer)q.pollLast()).intValue());
127 >            assertEquals(i, q.pollLast());
128          }
129          assertNull(q.pollLast());
130      }
131  
132      /**
133 <     *  peekFirst returns next element, or null if empty
133 >     * peekFirst returns next element, or null if empty
134       */
135      public void testPeekFirst() {
136          LinkedBlockingDeque q = populatedDeque(SIZE);
137          for (int i = 0; i < SIZE; ++i) {
138 <            assertEquals(i, ((Integer)q.peekFirst()).intValue());
139 <            q.pollFirst();
138 >            assertEquals(i, q.peekFirst());
139 >            assertEquals(i, q.pollFirst());
140              assertTrue(q.peekFirst() == null ||
141 <                       i != ((Integer)q.peekFirst()).intValue());
141 >                       !q.peekFirst().equals(i));
142          }
143          assertNull(q.peekFirst());
144      }
145  
146      /**
147 <     *  peek returns next element, or null if empty
147 >     * peek returns next element, or null if empty
148       */
149      public void testPeek() {
150          LinkedBlockingDeque q = populatedDeque(SIZE);
151          for (int i = 0; i < SIZE; ++i) {
152 <            assertEquals(i, ((Integer)q.peek()).intValue());
153 <            q.pollFirst();
152 >            assertEquals(i, q.peek());
153 >            assertEquals(i, q.pollFirst());
154              assertTrue(q.peek() == null ||
155 <                       i != ((Integer)q.peek()).intValue());
155 >                       !q.peek().equals(i));
156          }
157          assertNull(q.peek());
158      }
159  
160      /**
161 <     *  peekLast returns next element, or null if empty
161 >     * peekLast returns next element, or null if empty
162       */
163      public void testPeekLast() {
164          LinkedBlockingDeque q = populatedDeque(SIZE);
165          for (int i = SIZE-1; i >= 0; --i) {
166 <            assertEquals(i, ((Integer)q.peekLast()).intValue());
167 <            q.pollLast();
166 >            assertEquals(i, q.peekLast());
167 >            assertEquals(i, q.pollLast());
168              assertTrue(q.peekLast() == null ||
169 <                       i != ((Integer)q.peekLast()).intValue());
169 >                       !q.peekLast().equals(i));
170          }
171          assertNull(q.peekLast());
172      }
173  
174      /**
175 <     * getFirst returns next getFirst, or throws NSEE if empty
175 >     * getFirst() returns first element, or throws NSEE if empty
176       */
177      public void testFirstElement() {
178          LinkedBlockingDeque q = populatedDeque(SIZE);
179          for (int i = 0; i < SIZE; ++i) {
180 <            assertEquals(i, ((Integer)q.getFirst()).intValue());
181 <            q.pollFirst();
180 >            assertEquals(i, q.getFirst());
181 >            assertEquals(i, q.pollFirst());
182          }
183          try {
184              q.getFirst();
# Line 173 | Line 188 | public class LinkedBlockingDequeTest ext
188      }
189  
190      /**
191 <     *  getLast returns next element, or throws NSEE if empty
191 >     * getLast() returns last element, or throws NSEE if empty
192       */
193      public void testLastElement() {
194          LinkedBlockingDeque q = populatedDeque(SIZE);
195          for (int i = SIZE-1; i >= 0; --i) {
196 <            assertEquals(i, ((Integer)q.getLast()).intValue());
197 <            q.pollLast();
196 >            assertEquals(i, q.getLast());
197 >            assertEquals(i, q.pollLast());
198          }
199          try {
200              q.getLast();
# Line 189 | Line 204 | public class LinkedBlockingDequeTest ext
204      }
205  
206      /**
207 <     *  removeFirst removes next element, or throws NSEE if empty
207 >     * removeFirst() removes first element, or throws NSEE if empty
208       */
209      public void testRemoveFirst() {
210          LinkedBlockingDeque q = populatedDeque(SIZE);
211          for (int i = 0; i < SIZE; ++i) {
212 <            assertEquals(i, ((Integer)q.removeFirst()).intValue());
212 >            assertEquals(i, q.removeFirst());
213          }
214          try {
215              q.removeFirst();
# Line 204 | Line 219 | public class LinkedBlockingDequeTest ext
219      }
220  
221      /**
222 <     *  removeLast removes last element, or throws NSEE if empty
222 >     * removeLast() removes last element, or throws NSEE if empty
223       */
224      public void testRemoveLast() {
225          LinkedBlockingDeque q = populatedDeque(SIZE);
226          for (int i = SIZE - 1; i >= 0; --i) {
227 <            assertEquals(i, ((Integer)q.removeLast()).intValue());
227 >            assertEquals(i, q.removeLast());
228          }
229          try {
230              q.removeLast();
# Line 219 | Line 234 | public class LinkedBlockingDequeTest ext
234      }
235  
236      /**
237 <     *  remove removes next element, or throws NSEE if empty
237 >     * remove removes next element, or throws NSEE if empty
238       */
239      public void testRemove() {
240          LinkedBlockingDeque q = populatedDeque(SIZE);
241          for (int i = 0; i < SIZE; ++i) {
242 <            assertEquals(i, ((Integer)q.remove()).intValue());
242 >            assertEquals(i, q.remove());
243          }
244          try {
245              q.remove();
# Line 269 | Line 284 | public class LinkedBlockingDequeTest ext
284          LinkedBlockingDeque q = populatedDeque(3);
285          q.pollLast();
286          q.addFirst(four);
287 <        assertEquals(four,q.peekFirst());
287 >        assertSame(four, q.peekFirst());
288      }
289  
290      /**
# Line 279 | Line 294 | public class LinkedBlockingDequeTest ext
294          LinkedBlockingDeque q = populatedDeque(3);
295          q.pollLast();
296          q.addLast(four);
297 <        assertEquals(four,q.peekLast());
297 >        assertSame(four, q.peekLast());
298      }
299  
300  
# Line 437 | Line 452 | public class LinkedBlockingDequeTest ext
452          LinkedBlockingDeque q = populatedDeque(3);
453          q.pollLast();
454          q.push(four);
455 <        assertEquals(four,q.peekFirst());
455 >        assertSame(four, q.peekFirst());
456      }
457  
458  
459      /**
460 <     *  pop removes next element, or throws NSEE if empty
460 >     * pop removes next element, or throws NSEE if empty
461       */
462      public void testPop() {
463          LinkedBlockingDeque q = populatedDeque(SIZE);
464          for (int i = 0; i < SIZE; ++i) {
465 <            assertEquals(i, ((Integer)q.pop()).intValue());
465 >            assertEquals(i, q.pop());
466          }
467          try {
468              q.pop();
# Line 513 | Line 528 | public class LinkedBlockingDequeTest ext
528              shouldThrow();
529          } catch (NullPointerException success) {}
530      }
531 +
532      /**
533       * addAll of a collection with any null elements throws NPE after
534       * possibly adding some elements
# Line 527 | Line 543 | public class LinkedBlockingDequeTest ext
543              shouldThrow();
544          } catch (NullPointerException success) {}
545      }
546 +
547      /**
548       * addAll throws ISE if not enough room
549       */
# Line 660 | Line 677 | public class LinkedBlockingDequeTest ext
677      public void testTake() throws InterruptedException {
678          LinkedBlockingDeque q = populatedDeque(SIZE);
679          for (int i = 0; i < SIZE; ++i) {
680 <            assertEquals(i, ((Integer)q.take()).intValue());
680 >            assertEquals(i, q.take());
681          }
682      }
683  
684      /**
668     * take blocks interruptibly when empty
669     */
670    public void testTakeFromEmpty() throws InterruptedException {
671        final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
672        Thread t = new ThreadShouldThrow(InterruptedException.class) {
673            public void realRun() throws InterruptedException {
674                q.take();
675            }};
676
677        t.start();
678        Thread.sleep(SHORT_DELAY_MS);
679        t.interrupt();
680        t.join();
681    }
682
683    /**
685       * Take removes existing elements until empty, then blocks interruptibly
686       */
687      public void testBlockingTake() throws InterruptedException {
# Line 688 | Line 689 | public class LinkedBlockingDequeTest ext
689          Thread t = new Thread(new CheckedRunnable() {
690              public void realRun() throws InterruptedException {
691                  for (int i = 0; i < SIZE; ++i) {
692 <                    assertEquals(i, ((Integer)q.take()).intValue());
692 >                    assertEquals(i, q.take());
693                  }
694                  try {
695                      q.take();
# Line 709 | Line 710 | public class LinkedBlockingDequeTest ext
710      public void testPoll() {
711          LinkedBlockingDeque q = populatedDeque(SIZE);
712          for (int i = 0; i < SIZE; ++i) {
713 <            assertEquals(i, ((Integer)q.poll()).intValue());
713 >            assertEquals(i, q.poll());
714          }
715          assertNull(q.poll());
716      }
# Line 720 | Line 721 | public class LinkedBlockingDequeTest ext
721      public void testTimedPoll0() throws InterruptedException {
722          LinkedBlockingDeque q = populatedDeque(SIZE);
723          for (int i = 0; i < SIZE; ++i) {
724 <            assertEquals(i, ((Integer)q.poll(0, MILLISECONDS)).intValue());
724 >            assertEquals(i, q.poll(0, MILLISECONDS));
725          }
726          assertNull(q.poll(0, MILLISECONDS));
727      }
# Line 731 | Line 732 | public class LinkedBlockingDequeTest ext
732      public void testTimedPoll() throws InterruptedException {
733          LinkedBlockingDeque q = populatedDeque(SIZE);
734          for (int i = 0; i < SIZE; ++i) {
735 <            assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
735 >            assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));
736          }
737          assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
738      }
# Line 745 | Line 746 | public class LinkedBlockingDequeTest ext
746              public void realRun() throws InterruptedException {
747                  LinkedBlockingDeque q = populatedDeque(SIZE);
748                  for (int i = 0; i < SIZE; ++i) {
749 <                    assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
749 >                    assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));
750                  }
751                  try {
752                      q.poll(SMALL_DELAY_MS, MILLISECONDS);
# Line 760 | Line 761 | public class LinkedBlockingDequeTest ext
761      }
762  
763      /**
763     *  timed poll before a delayed offer fails; after offer succeeds;
764     *  on interruption throws
765     */
766    public void testTimedPollWithOffer() throws InterruptedException {
767        final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
768        Thread t = new Thread(new CheckedRunnable() {
769            public void realRun() throws InterruptedException {
770                assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
771                assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));
772                try {
773                    q.poll(LONG_DELAY_MS, MILLISECONDS);
774                    shouldThrow();
775                } catch (InterruptedException success) {}
776            }});
777
778        t.start();
779        Thread.sleep(SMALL_DELAY_MS);
780        assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS));
781        t.interrupt();
782        t.join();
783    }
784
785
786    /**
764       * putFirst(null) throws NPE
765       */
766       public void testPutFirstNull() throws InterruptedException {
# Line 886 | Line 863 | public class LinkedBlockingDequeTest ext
863      public void testTakeFirst() throws InterruptedException {
864          LinkedBlockingDeque q = populatedDeque(SIZE);
865          for (int i = 0; i < SIZE; ++i) {
866 <            assertEquals(i, ((Integer)q.takeFirst()).intValue());
866 >            assertEquals(i, q.takeFirst());
867          }
868      }
869  
# Line 934 | Line 911 | public class LinkedBlockingDequeTest ext
911      public void testTimedPollFirst0() throws InterruptedException {
912          LinkedBlockingDeque q = populatedDeque(SIZE);
913          for (int i = 0; i < SIZE; ++i) {
914 <            assertEquals(i, ((Integer)q.pollFirst(0, MILLISECONDS)).intValue());
914 >            assertEquals(i, q.pollFirst(0, MILLISECONDS));
915          }
916          assertNull(q.pollFirst(0, MILLISECONDS));
917      }
# Line 945 | Line 922 | public class LinkedBlockingDequeTest ext
922      public void testTimedPollFirst() throws InterruptedException {
923          LinkedBlockingDeque q = populatedDeque(SIZE);
924          for (int i = 0; i < SIZE; ++i) {
925 <            assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue());
925 >            assertEquals(i, q.pollFirst(SHORT_DELAY_MS, MILLISECONDS));
926          }
927          assertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS));
928      }
# Line 959 | Line 936 | public class LinkedBlockingDequeTest ext
936              public void realRun() throws InterruptedException {
937                  LinkedBlockingDeque q = populatedDeque(SIZE);
938                  for (int i = 0; i < SIZE; ++i) {
939 <                    assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue());
939 >                    assertEquals(i, q.pollFirst(SHORT_DELAY_MS, MILLISECONDS));
940                  }
941                  try {
942                      q.pollFirst(SMALL_DELAY_MS, MILLISECONDS);
# Line 974 | Line 951 | public class LinkedBlockingDequeTest ext
951      }
952  
953      /**
954 <     *  timed pollFirst before a delayed offerFirst fails; after offerFirst succeeds;
955 <     *  on interruption throws
954 >     * timed pollFirst before a delayed offerFirst fails; after offerFirst succeeds;
955 >     * on interruption throws
956       */
957      public void testTimedPollFirstWithOfferFirst() throws InterruptedException {
958          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
# Line 1099 | Line 1076 | public class LinkedBlockingDequeTest ext
1076      public void testTakeLast() throws InterruptedException {
1077          LinkedBlockingDeque q = populatedDeque(SIZE);
1078          for (int i = 0; i < SIZE; ++i) {
1079 <            assertEquals(SIZE-i-1, ((Integer)q.takeLast()).intValue());
1079 >            assertEquals(SIZE-i-1, q.takeLast());
1080          }
1081      }
1082  
# Line 1146 | Line 1123 | public class LinkedBlockingDequeTest ext
1123      public void testTimedPollLast0() throws InterruptedException {
1124          LinkedBlockingDeque q = populatedDeque(SIZE);
1125          for (int i = 0; i < SIZE; ++i) {
1126 <            assertEquals(SIZE-i-1, ((Integer)q.pollLast(0, MILLISECONDS)).intValue());
1126 >            assertEquals(SIZE-i-1, q.pollLast(0, MILLISECONDS));
1127          }
1128          assertNull(q.pollLast(0, MILLISECONDS));
1129      }
# Line 1157 | Line 1134 | public class LinkedBlockingDequeTest ext
1134      public void testTimedPollLast() throws InterruptedException {
1135          LinkedBlockingDeque q = populatedDeque(SIZE);
1136          for (int i = 0; i < SIZE; ++i) {
1137 <            assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue());
1137 >            assertEquals(SIZE-i-1, q.pollLast(SHORT_DELAY_MS, MILLISECONDS));
1138          }
1139          assertNull(q.pollLast(SHORT_DELAY_MS, MILLISECONDS));
1140      }
# Line 1171 | Line 1148 | public class LinkedBlockingDequeTest ext
1148              public void realRun() throws InterruptedException {
1149                  LinkedBlockingDeque q = populatedDeque(SIZE);
1150                  for (int i = 0; i < SIZE; ++i) {
1151 <                    assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue());
1151 >                    assertEquals(SIZE-i-1, q.pollLast(SHORT_DELAY_MS, MILLISECONDS));
1152                  }
1153                  try {
1154                      q.pollLast(SMALL_DELAY_MS, MILLISECONDS);
# Line 1186 | Line 1163 | public class LinkedBlockingDequeTest ext
1163      }
1164  
1165      /**
1166 <     *  timed poll before a delayed offerLast fails; after offerLast succeeds;
1167 <     *  on interruption throws
1166 >     * timed poll before a delayed offerLast fails; after offerLast succeeds;
1167 >     * on interruption throws
1168       */
1169      public void testTimedPollWithOfferLast() throws InterruptedException {
1170          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
# Line 1215 | Line 1192 | public class LinkedBlockingDequeTest ext
1192      public void testElement() {
1193          LinkedBlockingDeque q = populatedDeque(SIZE);
1194          for (int i = 0; i < SIZE; ++i) {
1195 <            assertEquals(i, ((Integer)q.element()).intValue());
1195 >            assertEquals(i, q.element());
1196              q.poll();
1197          }
1198          try {
# Line 1341 | Line 1318 | public class LinkedBlockingDequeTest ext
1318       * toArray(null) throws NPE
1319       */
1320      public void testToArray_BadArg() {
1321 +        LinkedBlockingDeque q = populatedDeque(SIZE);
1322          try {
1345            LinkedBlockingDeque q = populatedDeque(SIZE);
1323              Object o[] = q.toArray(null);
1324              shouldThrow();
1325          } catch (NullPointerException success) {}
1326      }
1327  
1328      /**
1329 <     * toArray with incompatible array type throws CCE
1329 >     * toArray(incompatible array type) throws ArrayStoreException
1330       */
1331      public void testToArray1_BadArg() {
1332 +        LinkedBlockingDeque q = populatedDeque(SIZE);
1333          try {
1334 <            LinkedBlockingDeque q = populatedDeque(SIZE);
1357 <            Object o[] = q.toArray(new String[10] );
1334 >            q.toArray(new String[10]);
1335              shouldThrow();
1336          } catch (ArrayStoreException success) {}
1337      }
# Line 1374 | Line 1351 | public class LinkedBlockingDequeTest ext
1351      /**
1352       * iterator.remove removes current element
1353       */
1354 <    public void testIteratorRemove () {
1354 >    public void testIteratorRemove() {
1355          final LinkedBlockingDeque q = new LinkedBlockingDeque(3);
1356          q.add(two);
1357          q.add(one);
# Line 1385 | Line 1362 | public class LinkedBlockingDequeTest ext
1362          it.remove();
1363  
1364          it = q.iterator();
1365 <        assertEquals(it.next(), one);
1366 <        assertEquals(it.next(), three);
1365 >        assertSame(it.next(), one);
1366 >        assertSame(it.next(), three);
1367          assertFalse(it.hasNext());
1368      }
1369  
# Line 1402 | Line 1379 | public class LinkedBlockingDequeTest ext
1379          assertEquals(0, q.remainingCapacity());
1380          int k = 0;
1381          for (Iterator it = q.iterator(); it.hasNext();) {
1382 <            int i = ((Integer)(it.next())).intValue();
1406 <            assertEquals(++k, i);
1382 >            assertEquals(++k, it.next());
1383          }
1384          assertEquals(3, k);
1385      }
# Line 1411 | Line 1387 | public class LinkedBlockingDequeTest ext
1387      /**
1388       * Modifications do not cause iterators to fail
1389       */
1390 <    public void testWeaklyConsistentIteration () {
1390 >    public void testWeaklyConsistentIteration() {
1391          final LinkedBlockingDeque q = new LinkedBlockingDeque(3);
1392          q.add(one);
1393          q.add(two);
# Line 1425 | Line 1401 | public class LinkedBlockingDequeTest ext
1401  
1402  
1403      /**
1404 <     *  Descending iterator iterates through all elements
1404 >     * Descending iterator iterates through all elements
1405       */
1406      public void testDescendingIterator() {
1407          LinkedBlockingDeque q = populatedDeque(SIZE);
# Line 1444 | Line 1420 | public class LinkedBlockingDequeTest ext
1420      }
1421  
1422      /**
1423 <     *  Descending iterator ordering is reverse FIFO
1423 >     * Descending iterator ordering is reverse FIFO
1424       */
1425      public void testDescendingIteratorOrdering() {
1426          final LinkedBlockingDeque q = new LinkedBlockingDeque();
# Line 1454 | Line 1430 | public class LinkedBlockingDequeTest ext
1430              q.add(new Integer(1));
1431              int k = 0;
1432              for (Iterator it = q.descendingIterator(); it.hasNext();) {
1433 <                int i = ((Integer)(it.next())).intValue();
1458 <                assertEquals(++k, i);
1433 >                assertEquals(++k, it.next());
1434              }
1435  
1436              assertEquals(3, k);
# Line 1468 | Line 1443 | public class LinkedBlockingDequeTest ext
1443      /**
1444       * descendingIterator.remove removes current element
1445       */
1446 <    public void testDescendingIteratorRemove () {
1446 >    public void testDescendingIteratorRemove() {
1447          final LinkedBlockingDeque q = new LinkedBlockingDeque();
1448          for (int iters = 0; iters < 100; ++iters) {
1449              q.add(new Integer(3));
# Line 1510 | Line 1485 | public class LinkedBlockingDequeTest ext
1485          ExecutorService executor = Executors.newFixedThreadPool(2);
1486          executor.execute(new CheckedRunnable() {
1487              public void realRun() throws InterruptedException {
1488 <                threadAssertFalse(q.offer(three));
1489 <                threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS));
1490 <                threadAssertEquals(0, q.remainingCapacity());
1488 >                assertFalse(q.offer(three));
1489 >                assertTrue(q.offer(three, MEDIUM_DELAY_MS, MILLISECONDS));
1490 >                assertEquals(0, q.remainingCapacity());
1491              }});
1492  
1493          executor.execute(new CheckedRunnable() {
1494              public void realRun() throws InterruptedException {
1495                  Thread.sleep(SMALL_DELAY_MS);
1496 <                threadAssertEquals(one, q.take());
1496 >                assertSame(one, q.take());
1497              }});
1498  
1499          joinPool(executor);
# Line 1532 | Line 1507 | public class LinkedBlockingDequeTest ext
1507          ExecutorService executor = Executors.newFixedThreadPool(2);
1508          executor.execute(new CheckedRunnable() {
1509              public void realRun() throws InterruptedException {
1510 <                threadAssertNull(q.poll());
1511 <                threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
1512 <                threadAssertTrue(q.isEmpty());
1510 >                assertNull(q.poll());
1511 >                assertSame(one, q.poll(MEDIUM_DELAY_MS, MILLISECONDS));
1512 >                assertTrue(q.isEmpty());
1513              }});
1514  
1515          executor.execute(new CheckedRunnable() {
# Line 1654 | Line 1629 | public class LinkedBlockingDequeTest ext
1629      }
1630  
1631      /**
1632 <     * drainTo(c, n) empties first max {n, size} elements of deque into c
1632 >     * drainTo(c, n) empties first min(n, size) elements of queue into c
1633       */
1634      public void testDrainToN() {
1635          LinkedBlockingDeque q = new LinkedBlockingDeque();
# Line 1663 | Line 1638 | public class LinkedBlockingDequeTest ext
1638                  assertTrue(q.offer(new Integer(j)));
1639              ArrayList l = new ArrayList();
1640              q.drainTo(l, i);
1641 <            int k = (i < SIZE)? i : SIZE;
1641 >            int k = (i < SIZE) ? i : SIZE;
1642              assertEquals(l.size(), k);
1643              assertEquals(q.size(), SIZE-k);
1644              for (int j = 0; j < k; ++j)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines