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.56 by jsr166, Wed Dec 31 19:21:20 2014 UTC vs.
Revision 1.60 by jsr166, Fri May 15 18:21:19 2015 UTC

# Line 32 | Line 32 | public class LinkedTransferQueueTest ext
32      }
33  
34      public static void main(String[] args) {
35 <        junit.textui.TestRunner.run(suite());
35 >        main(suite(), args);
36      }
37  
38      public static Test suite() {
# Line 115 | Line 115 | public class LinkedTransferQueueTest ext
115       * remainingCapacity() always returns Integer.MAX_VALUE
116       */
117      public void testRemainingCapacity() {
118 <        LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
118 >        BlockingQueue q = populatedQueue(SIZE);
119          for (int i = 0; i < SIZE; ++i) {
120              assertEquals(Integer.MAX_VALUE, q.remainingCapacity());
121              assertEquals(SIZE - i, q.size());
122 <            q.remove();
122 >            assertEquals(i, q.remove());
123          }
124          for (int i = 0; i < SIZE; ++i) {
125              assertEquals(Integer.MAX_VALUE, q.remainingCapacity());
126              assertEquals(i, q.size());
127 <            q.add(i);
127 >            assertTrue(q.add(i));
128          }
129      }
130  
# Line 132 | Line 132 | public class LinkedTransferQueueTest ext
132       * addAll(this) throws IllegalArgumentException
133       */
134      public void testAddAllSelf() {
135 +        LinkedTransferQueue q = populatedQueue(SIZE);
136          try {
136            LinkedTransferQueue q = populatedQueue(SIZE);
137              q.addAll(q);
138              shouldThrow();
139          } catch (IllegalArgumentException success) {}
# Line 144 | Line 144 | public class LinkedTransferQueueTest ext
144       * NullPointerException after possibly adding some elements
145       */
146      public void testAddAll3() {
147 +        LinkedTransferQueue q = new LinkedTransferQueue();
148 +        Integer[] ints = new Integer[SIZE];
149 +        for (int i = 0; i < SIZE - 1; ++i)
150 +            ints[i] = i;
151          try {
148            LinkedTransferQueue q = new LinkedTransferQueue();
149            Integer[] ints = new Integer[SIZE];
150            for (int i = 0; i < SIZE - 1; ++i) {
151                ints[i] = i;
152            }
152              q.addAll(Arrays.asList(ints));
153              shouldThrow();
154          } catch (NullPointerException success) {}
# Line 500 | Line 499 | public class LinkedTransferQueueTest ext
499      public void testIterator() throws InterruptedException {
500          LinkedTransferQueue q = populatedQueue(SIZE);
501          Iterator it = q.iterator();
502 <        int i = 0;
503 <        while (it.hasNext()) {
504 <            assertEquals(it.next(), i++);
506 <        }
502 >        int i;
503 >        for (i = 0; it.hasNext(); i++)
504 >            assertTrue(q.contains(it.next()));
505          assertEquals(i, SIZE);
506 +        assertIteratorExhausted(it);
507 +
508 +        it = q.iterator();
509 +        for (i = 0; it.hasNext(); i++)
510 +            assertEquals(it.next(), q.take());
511 +        assertEquals(i, SIZE);
512 +        assertIteratorExhausted(it);
513 +    }
514 +
515 +    /**
516 +     * iterator of empty collection has no elements
517 +     */
518 +    public void testEmptyIterator() {
519 +        assertIteratorExhausted(new LinkedTransferQueue().iterator());
520      }
521  
522      /**
# Line 849 | Line 861 | public class LinkedTransferQueueTest ext
861       * tryTransfer(null) throws NullPointerException
862       */
863      public void testTryTransfer1() {
864 +        final LinkedTransferQueue q = new LinkedTransferQueue();
865          try {
853            final LinkedTransferQueue q = new LinkedTransferQueue();
866              q.tryTransfer(null);
867              shouldThrow();
868          } catch (NullPointerException success) {}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines