--- jsr166/src/test/tck/LinkedTransferQueueTest.java 2011/05/27 20:07:24 1.46 +++ jsr166/src/test/tck/LinkedTransferQueueTest.java 2011/05/30 22:43:20 1.47 @@ -13,10 +13,15 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; -import java.util.concurrent.*; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedTransferQueue; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; import junit.framework.Test; @@ -65,9 +70,9 @@ public class LinkedTransferQueueTest ext * NullPointerException */ public void testConstructor3() { + Collection elements = Arrays.asList(new Integer[SIZE]); try { - Integer[] ints = new Integer[SIZE]; - new LinkedTransferQueue(Arrays.asList(ints)); + new LinkedTransferQueue(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -77,12 +82,12 @@ public class LinkedTransferQueueTest ext * throws NullPointerException */ public void testConstructor4() { + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE-1; ++i) + ints[i] = i; + Collection elements = Arrays.asList(ints); try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) { - ints[i] = i; - } - new LinkedTransferQueue(Arrays.asList(ints)); + new LinkedTransferQueue(elements); shouldThrow(); } catch (NullPointerException success) {} } @@ -129,39 +134,6 @@ public class LinkedTransferQueueTest ext } /** - * offer(null) throws NullPointerException - */ - public void testOfferNull() { - try { - LinkedTransferQueue q = new LinkedTransferQueue(); - q.offer(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** - * add(null) throws NullPointerException - */ - public void testAddNull() { - try { - LinkedTransferQueue q = new LinkedTransferQueue(); - q.add(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** - * addAll(null) throws NullPointerException - */ - public void testAddAll1() { - try { - LinkedTransferQueue q = new LinkedTransferQueue(); - q.addAll(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { @@ -173,18 +145,6 @@ public class LinkedTransferQueueTest ext } /** - * addAll of a collection with null elements throws NullPointerException - */ - public void testAddAll2() { - try { - LinkedTransferQueue q = new LinkedTransferQueue(); - Integer[] ints = new Integer[SIZE]; - q.addAll(Arrays.asList(ints)); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** * addAll of a collection with any null elements throws * NullPointerException after possibly adding some elements */ @@ -218,17 +178,6 @@ public class LinkedTransferQueueTest ext } /** - * put(null) throws NullPointerException - */ - public void testPutNull() throws InterruptedException { - try { - LinkedTransferQueue q = new LinkedTransferQueue(); - q.put(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** * all elements successfully put are contained */ public void testPut() { @@ -561,17 +510,6 @@ public class LinkedTransferQueueTest ext } /** - * toArray(null) throws NullPointerException - */ - public void testToArray_NullArg() { - LinkedTransferQueue q = populatedQueue(SIZE); - try { - q.toArray(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** * toArray(incompatible array type) throws ArrayStoreException */ public void testToArray1_BadArg() { @@ -734,28 +672,6 @@ public class LinkedTransferQueueTest ext } /** - * drainTo(null) throws NullPointerException - */ - public void testDrainToNull() { - LinkedTransferQueue q = populatedQueue(SIZE); - try { - q.drainTo(null); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** - * drainTo(this) throws IllegalArgumentException - */ - public void testDrainToSelf() { - LinkedTransferQueue q = populatedQueue(SIZE); - try { - q.drainTo(q); - shouldThrow(); - } catch (IllegalArgumentException success) {} - } - - /** * drainTo(c) empties queue into another collection c */ public void testDrainTo() { @@ -801,28 +717,6 @@ public class LinkedTransferQueueTest ext } /** - * drainTo(null, n) throws NullPointerException - */ - public void testDrainToNullN() { - LinkedTransferQueue q = populatedQueue(SIZE); - try { - q.drainTo(null, SIZE); - shouldThrow(); - } catch (NullPointerException success) {} - } - - /** - * drainTo(this, n) throws IllegalArgumentException - */ - public void testDrainToSelfN() { - LinkedTransferQueue q = populatedQueue(SIZE); - try { - q.drainTo(q, SIZE); - shouldThrow(); - } catch (IllegalArgumentException success) {} - } - - /** * drainTo(c, n) empties first min(n, size) elements of queue into c */ public void testDrainToN() {