--- jsr166/src/test/tck/ArrayBlockingQueueTest.java 2016/11/06 03:49:39 1.78 +++ jsr166/src/test/tck/ArrayBlockingQueueTest.java 2016/11/06 06:27:04 1.81 @@ -269,7 +269,7 @@ public class ArrayBlockingQueueTest exte * addAll throws ISE if not enough room */ public void testAddAll_insufficientSpace() { - int size = ThreadLocalRandom.current().nextInt(SIZE); + int size = ThreadLocalRandom.current().nextInt(1, SIZE); ArrayBlockingQueue q = populatedQueue(0, size, size, false); // Just fits: q.addAll(populatedQueue(size, size, 2 * size, false)); @@ -565,8 +565,10 @@ public class ArrayBlockingQueueTest exte * contains(x) reports true when elements added but not yet removed */ public void testContains() { - ArrayBlockingQueue q = populatedQueue(SIZE); - for (int i = 0; i < SIZE; ++i) { + int size = ThreadLocalRandom.current().nextInt(1, SIZE); + ArrayBlockingQueue q = populatedQueue(size, size, 2 * size, false); + assertFalse(q.contains(null)); + for (int i = 0; i < size; ++i) { assertTrue(q.contains(new Integer(i))); assertEquals(i, q.poll()); assertFalse(q.contains(new Integer(i))); @@ -577,11 +579,13 @@ public class ArrayBlockingQueueTest exte * clear removes all elements */ public void testClear() { - ArrayBlockingQueue q = populatedQueue(SIZE); + int size = ThreadLocalRandom.current().nextInt(1, 5); + ArrayBlockingQueue q = populatedQueue(size, size, 2 * size, false); + int capacity = size + q.remainingCapacity(); q.clear(); assertTrue(q.isEmpty()); assertEquals(0, q.size()); - assertEquals(SIZE, q.remainingCapacity()); + assertEquals(capacity, q.remainingCapacity()); q.add(one); assertFalse(q.isEmpty()); assertTrue(q.contains(one)); @@ -935,8 +939,8 @@ public class ArrayBlockingQueueTest exte */ public void testNeverContainsNull() { Collection[] qs = { - new ArrayBlockingQueue(10), - populatedQueue(2), + populatedQueue(0, 1, 10, false), + populatedQueue(2, 2, 10, true), }; for (Collection q : qs) {