--- jsr166/src/test/tck/PriorityQueueTest.java 2016/06/01 16:08:04 1.37 +++ jsr166/src/test/tck/PriorityQueueTest.java 2017/08/04 03:30:21 1.44 @@ -15,14 +15,21 @@ import java.util.PriorityQueue; import java.util.Queue; import junit.framework.Test; -import junit.framework.TestSuite; public class PriorityQueueTest extends JSR166TestCase { public static void main(String[] args) { main(suite(), args); } public static Test suite() { - return new TestSuite(PriorityQueueTest.class); + class Implementation implements CollectionImplementation { + public Class klazz() { return PriorityQueue.class; } + public Collection emptyCollection() { return new PriorityQueue(); } + public Object makeElement(int i) { return i; } + public boolean isConcurrent() { return false; } + public boolean permitsNulls() { return false; } + } + return newTestSuite(PriorityQueueTest.class, + CollectionTest.testSuite(new Implementation())); } static class MyReverseComparator implements Comparator { @@ -33,10 +40,10 @@ public class PriorityQueueTest extends J /** * Returns a new queue of given size containing consecutive - * Integers 0 ... n. + * Integers 0 ... n - 1. */ - private PriorityQueue populatedQueue(int n) { - PriorityQueue q = new PriorityQueue(n); + private static PriorityQueue populatedQueue(int n) { + PriorityQueue q = new PriorityQueue<>(n); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) assertTrue(q.offer(new Integer(i))); @@ -44,6 +51,7 @@ public class PriorityQueueTest extends J assertTrue(q.offer(new Integer(i))); assertFalse(q.isEmpty()); assertEquals(n, q.size()); + assertEquals((Integer) 0, q.peek()); return q; } @@ -55,7 +63,7 @@ public class PriorityQueueTest extends J } /** - * Constructor throws IAE if capacity argument nonpositive + * Constructor throws IllegalArgumentException if capacity argument nonpositive */ public void testConstructor2() { try { @@ -487,7 +495,7 @@ public class PriorityQueueTest extends J } /** - * A deserialized serialized queue has same elements + * A deserialized/reserialized queue has same elements */ public void testSerialization() throws Exception { Queue x = populatedQueue(SIZE);