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

Comparing jsr166/src/test/tck/PriorityBlockingQueueTest.java (file contents):
Revision 1.15 by jsr166, Sat Nov 21 00:04:40 2009 UTC vs.
Revision 1.16 by jsr166, Sat Nov 21 02:07:27 2009 UTC

# Line 13 | Line 13 | import java.io.*;
13  
14   public class PriorityBlockingQueueTest extends JSR166TestCase {
15      public static void main(String[] args) {
16 <        junit.textui.TestRunner.run (suite());
16 >        junit.textui.TestRunner.run (suite());
17      }
18      public static Test suite() {
19 <        return new TestSuite(PriorityBlockingQueueTest.class);
19 >        return new TestSuite(PriorityBlockingQueueTest.class);
20      }
21  
22      private static final int NOCAP = Integer.MAX_VALUE;
# Line 39 | Line 39 | public class PriorityBlockingQueueTest e
39      private PriorityBlockingQueue populatedQueue(int n) {
40          PriorityBlockingQueue q = new PriorityBlockingQueue(n);
41          assertTrue(q.isEmpty());
42 <        for (int i = n-1; i >= 0; i-=2)
43 <            assertTrue(q.offer(new Integer(i)));
44 <        for (int i = (n & 1); i < n; i+=2)
45 <            assertTrue(q.offer(new Integer(i)));
42 >        for (int i = n-1; i >= 0; i-=2)
43 >            assertTrue(q.offer(new Integer(i)));
44 >        for (int i = (n & 1); i < n; i+=2)
45 >            assertTrue(q.offer(new Integer(i)));
46          assertFalse(q.isEmpty());
47          assertEquals(NOCAP, q.remainingCapacity());
48 <        assertEquals(n, q.size());
48 >        assertEquals(n, q.size());
49          return q;
50      }
51  
# Line 164 | Line 164 | public class PriorityBlockingQueueTest e
164       * offer(null) throws NPE
165       */
166      public void testOfferNull() {
167 <        try {
167 >        try {
168              PriorityBlockingQueue q = new PriorityBlockingQueue(1);
169              q.offer(null);
170              shouldThrow();
# Line 175 | Line 175 | public class PriorityBlockingQueueTest e
175       * add(null) throws NPE
176       */
177      public void testAddNull() {
178 <        try {
178 >        try {
179              PriorityBlockingQueue q = new PriorityBlockingQueue(1);
180              q.add(null);
181              shouldThrow();
# Line 282 | Line 282 | public class PriorityBlockingQueueTest e
282       * put(null) throws NPE
283       */
284       public void testPutNull() {
285 <        try {
285 >        try {
286              PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
287              q.put(null);
288              shouldThrow();
# Line 398 | Line 398 | public class PriorityBlockingQueueTest e
398          for (int i = 0; i < SIZE; ++i) {
399              assertEquals(i, ((Integer)q.poll()).intValue());
400          }
401 <        assertNull(q.poll());
401 >        assertNull(q.poll());
402      }
403  
404      /**
# Line 481 | Line 481 | public class PriorityBlockingQueueTest e
481              assertTrue(q.peek() == null ||
482                         i != ((Integer)q.peek()).intValue());
483          }
484 <        assertNull(q.peek());
484 >        assertNull(q.peek());
485      }
486  
487      /**
# Line 609 | Line 609 | public class PriorityBlockingQueueTest e
609       */
610      public void testToArray() throws InterruptedException {
611          PriorityBlockingQueue q = populatedQueue(SIZE);
612 <        Object[] o = q.toArray();
612 >        Object[] o = q.toArray();
613          Arrays.sort(o);
614 <        for (int i = 0; i < o.length; i++)
615 <            assertEquals(o[i], q.take());
614 >        for (int i = 0; i < o.length; i++)
615 >            assertEquals(o[i], q.take());
616      }
617  
618      /**
# Line 620 | Line 620 | public class PriorityBlockingQueueTest e
620       */
621      public void testToArray2() throws InterruptedException {
622          PriorityBlockingQueue q = populatedQueue(SIZE);
623 <        Integer[] ints = new Integer[SIZE];
624 <        ints = (Integer[])q.toArray(ints);
623 >        Integer[] ints = new Integer[SIZE];
624 >        ints = (Integer[])q.toArray(ints);
625          Arrays.sort(ints);
626          for (int i = 0; i < ints.length; i++)
627              assertEquals(ints[i], q.take());
# Line 631 | Line 631 | public class PriorityBlockingQueueTest e
631       * toArray(null) throws NPE
632       */
633      public void testToArray_BadArg() {
634 <        try {
634 >        try {
635              PriorityBlockingQueue q = populatedQueue(SIZE);
636 <            Object o[] = q.toArray(null);
637 <            shouldThrow();
638 <        } catch (NullPointerException success) {}
636 >            Object o[] = q.toArray(null);
637 >            shouldThrow();
638 >        } catch (NullPointerException success) {}
639      }
640  
641      /**
642       * toArray with incompatible array type throws CCE
643       */
644      public void testToArray1_BadArg() {
645 <        try {
645 >        try {
646              PriorityBlockingQueue q = populatedQueue(SIZE);
647 <            Object o[] = q.toArray(new String[10] );
648 <            shouldThrow();
649 <        } catch (ArrayStoreException  success) {}
647 >            Object o[] = q.toArray(new String[10] );
648 >            shouldThrow();
649 >        } catch (ArrayStoreException  success) {}
650      }
651  
652      /**
# Line 655 | Line 655 | public class PriorityBlockingQueueTest e
655      public void testIterator() {
656          PriorityBlockingQueue q = populatedQueue(SIZE);
657          int i = 0;
658 <        Iterator it = q.iterator();
658 >        Iterator it = q.iterator();
659          while (it.hasNext()) {
660              assertTrue(q.contains(it.next()));
661              ++i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines