--- jsr166/src/test/tck/ArrayBlockingQueueTest.java 2021/01/26 13:33:05 1.98 +++ jsr166/src/test/tck/ArrayBlockingQueueTest.java 2021/01/27 01:57:24 1.99 @@ -173,7 +173,7 @@ public class ArrayBlockingQueueTest exte public void testConstructor7() { Item[] items = defaultItems; Collection elements = Arrays.asList(items); - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, true, elements); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE, true, elements); for (int i = 0; i < SIZE; ++i) mustEqual(items[i], q.poll()); } @@ -217,7 +217,7 @@ public class ArrayBlockingQueueTest exte * Offer succeeds if not full; fails if full */ public void testOffer() { - ArrayBlockingQueue q = new ArrayBlockingQueue(1); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(1); assertTrue(q.offer(zero)); assertFalse(q.offer(one)); } @@ -226,7 +226,7 @@ public class ArrayBlockingQueueTest exte * add succeeds if not full; throws IllegalStateException if full */ public void testAdd() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; i++) assertTrue(q.add(itemFor(i))); mustEqual(0, q.remainingCapacity()); try { @@ -251,7 +251,7 @@ public class ArrayBlockingQueueTest exte * possibly adding some elements */ public void testAddAll3() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); Item[] items = new Item[2]; items[0] = zero; try { q.addAll(Arrays.asList(items)); @@ -283,7 +283,7 @@ public class ArrayBlockingQueueTest exte public void testAddAll5() { Item[] empty = new Item[0]; Item[] items = defaultItems; - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); assertFalse(q.addAll(Arrays.asList(empty))); assertTrue(q.addAll(Arrays.asList(items))); for (int i = 0; i < SIZE; ++i) @@ -294,7 +294,7 @@ public class ArrayBlockingQueueTest exte * all elements successfully put are contained */ public void testPut() throws InterruptedException { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { Item x = itemFor(i); q.put(x); @@ -307,7 +307,7 @@ public class ArrayBlockingQueueTest exte * put blocks interruptibly if full */ public void testBlockingPut() throws InterruptedException { - final ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -344,7 +344,7 @@ public class ArrayBlockingQueueTest exte */ public void testPutWithTake() throws InterruptedException { final int capacity = 2; - final ArrayBlockingQueue q = new ArrayBlockingQueue(capacity); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(capacity); final CountDownLatch pleaseTake = new CountDownLatch(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { @@ -384,7 +384,7 @@ public class ArrayBlockingQueueTest exte * timed offer times out if full and elements not taken */ public void testTimedOffer() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(2); final CountDownLatch pleaseInterrupt = new CountDownLatch(1); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -609,7 +609,7 @@ public class ArrayBlockingQueueTest exte */ public void testContainsAll() { ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayBlockingQueue p = new ArrayBlockingQueue(SIZE); + ArrayBlockingQueue p = new ArrayBlockingQueue<>(SIZE); for (int i = 0; i < SIZE; ++i) { assertTrue(q.containsAll(p)); assertFalse(p.containsAll(q)); @@ -747,14 +747,14 @@ public class ArrayBlockingQueueTest exte * iterator of empty collection has no elements */ public void testEmptyIterator() { - assertIteratorExhausted(new ArrayBlockingQueue(SIZE).iterator()); + assertIteratorExhausted(new ArrayBlockingQueue<>(SIZE).iterator()); } /** * iterator.remove removes current element */ public void testIteratorRemove() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(3); q.add(two); q.add(one); q.add(three); @@ -773,7 +773,7 @@ public class ArrayBlockingQueueTest exte * iterator ordering is FIFO */ public void testIteratorOrdering() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(3); q.add(one); q.add(two); q.add(three); @@ -791,7 +791,7 @@ public class ArrayBlockingQueueTest exte * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(3); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(3); q.add(one); q.add(two); q.add(three); @@ -817,7 +817,7 @@ public class ArrayBlockingQueueTest exte * offer transfers elements across Executor tasks */ public void testOfferInExecutor() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(2); q.add(one); q.add(two); final CheckedBarrier threadsStarted = new CheckedBarrier(2); @@ -844,7 +844,7 @@ public class ArrayBlockingQueueTest exte * timed poll retrieves elements across Executor threads */ public void testPollInExecutor() { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); + final ArrayBlockingQueue q = new ArrayBlockingQueue<>(2); final CheckedBarrier threadsStarted = new CheckedBarrier(2); final ExecutorService executor = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(executor)) { @@ -887,7 +887,7 @@ public class ArrayBlockingQueueTest exte */ public void testDrainTo() { ArrayBlockingQueue q = populatedQueue(SIZE); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); mustEqual(0, q.size()); mustEqual(SIZE, l.size()); @@ -917,7 +917,7 @@ public class ArrayBlockingQueueTest exte }}); t.start(); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l); assertTrue(l.size() >= SIZE); for (int i = 0; i < SIZE; ++i) @@ -930,11 +930,11 @@ public class ArrayBlockingQueueTest exte * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() { - ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE * 2); + ArrayBlockingQueue q = new ArrayBlockingQueue<>(SIZE * 2); for (int i = 0; i < SIZE + 2; ++i) { for (int j = 0; j < SIZE; j++) mustOffer(q, j); - ArrayList l = new ArrayList(); + ArrayList l = new ArrayList<>(); q.drainTo(l, i); int k = (i < SIZE) ? i : SIZE; mustEqual(k, l.size());