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.23 by jsr166, Sun Nov 22 00:17:37 2009 UTC vs.
Revision 1.24 by jsr166, Sun Nov 22 18:57:17 2009 UTC

# Line 25 | Line 25 | public class PriorityBlockingQueueTest e
25      /** Sample Comparator */
26      static class MyReverseComparator implements Comparator {
27          public int compare(Object x, Object y) {
28 <            int i = ((Integer)x).intValue();
29 <            int j = ((Integer)y).intValue();
30 <            if (i < j) return 1;
31 <            if (i > j) return -1;
32 <            return 0;
28 >            return ((Comparable)y).compareTo(x);
29          }
30      }
31  
# Line 348 | Line 344 | public class PriorityBlockingQueueTest e
344      public void testTake() throws InterruptedException {
345          PriorityBlockingQueue q = populatedQueue(SIZE);
346          for (int i = 0; i < SIZE; ++i) {
347 <            assertEquals(i, ((Integer)q.take()).intValue());
347 >            assertEquals(i, q.take());
348          }
349      }
350  
# Line 397 | Line 393 | public class PriorityBlockingQueueTest e
393      public void testPoll() {
394          PriorityBlockingQueue q = populatedQueue(SIZE);
395          for (int i = 0; i < SIZE; ++i) {
396 <            assertEquals(i, ((Integer)q.poll()).intValue());
396 >            assertEquals(i, q.poll());
397          }
398          assertNull(q.poll());
399      }
# Line 408 | Line 404 | public class PriorityBlockingQueueTest e
404      public void testTimedPoll0() throws InterruptedException {
405          PriorityBlockingQueue q = populatedQueue(SIZE);
406          for (int i = 0; i < SIZE; ++i) {
407 <            assertEquals(i, ((Integer)q.poll(0, MILLISECONDS)).intValue());
407 >            assertEquals(i, q.poll(0, MILLISECONDS));
408          }
409          assertNull(q.poll(0, MILLISECONDS));
410      }
# Line 419 | Line 415 | public class PriorityBlockingQueueTest e
415      public void testTimedPoll() throws InterruptedException {
416          PriorityBlockingQueue q = populatedQueue(SIZE);
417          for (int i = 0; i < SIZE; ++i) {
418 <            assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
418 >            assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));
419          }
420          assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
421      }
# Line 433 | Line 429 | public class PriorityBlockingQueueTest e
429              public void realRun() throws InterruptedException {
430                  PriorityBlockingQueue q = populatedQueue(SIZE);
431                  for (int i = 0; i < SIZE; ++i) {
432 <                    assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
432 >                    assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));
433                  }
434                  try {
435                      q.poll(SMALL_DELAY_MS, MILLISECONDS);
# Line 477 | Line 473 | public class PriorityBlockingQueueTest e
473      public void testPeek() {
474          PriorityBlockingQueue q = populatedQueue(SIZE);
475          for (int i = 0; i < SIZE; ++i) {
476 <            assertEquals(i, ((Integer)q.peek()).intValue());
477 <            q.poll();
476 >            assertEquals(i, q.peek());
477 >            assertEquals(i, q.poll());
478              assertTrue(q.peek() == null ||
479 <                       i != ((Integer)q.peek()).intValue());
479 >                       !q.peek().equals(i));
480          }
481          assertNull(q.peek());
482      }
# Line 491 | Line 487 | public class PriorityBlockingQueueTest e
487      public void testElement() {
488          PriorityBlockingQueue q = populatedQueue(SIZE);
489          for (int i = 0; i < SIZE; ++i) {
490 <            assertEquals(i, ((Integer)q.element()).intValue());
491 <            q.poll();
490 >            assertEquals(i, q.element());
491 >            assertEquals(i, q.poll());
492          }
493          try {
494              q.element();
# Line 506 | Line 502 | public class PriorityBlockingQueueTest e
502      public void testRemove() {
503          PriorityBlockingQueue q = populatedQueue(SIZE);
504          for (int i = 0; i < SIZE; ++i) {
505 <            assertEquals(i, ((Integer)q.remove()).intValue());
505 >            assertEquals(i, q.remove());
506          }
507          try {
508              q.remove();
# Line 632 | Line 628 | public class PriorityBlockingQueueTest e
628       * toArray(null) throws NPE
629       */
630      public void testToArray_BadArg() {
631 +        PriorityBlockingQueue q = populatedQueue(SIZE);
632          try {
636            PriorityBlockingQueue q = populatedQueue(SIZE);
633              Object o[] = q.toArray(null);
634              shouldThrow();
635          } catch (NullPointerException success) {}
# Line 643 | Line 639 | public class PriorityBlockingQueueTest e
639       * toArray with incompatible array type throws CCE
640       */
641      public void testToArray1_BadArg() {
642 +        PriorityBlockingQueue q = populatedQueue(SIZE);
643          try {
644 <            PriorityBlockingQueue q = populatedQueue(SIZE);
648 <            Object o[] = q.toArray(new String[10] );
644 >            Object o[] = q.toArray(new String[10]);
645              shouldThrow();
646          } catch (ArrayStoreException success) {}
647      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines