--- jsr166/src/test/tck/LinkedTransferQueueTest.java 2015/02/28 19:59:23 1.58 +++ jsr166/src/test/tck/LinkedTransferQueueTest.java 2015/06/14 20:58:14 1.62 @@ -24,6 +24,13 @@ import junit.framework.Test; @SuppressWarnings({"unchecked", "rawtypes"}) public class LinkedTransferQueueTest extends JSR166TestCase { + static class Implementation implements CollectionImplementation { + public Class klazz() { return LinkedTransferQueue.class; } + public Collection emptyCollection() { return new LinkedTransferQueue(); } + public Object makeElement(int i) { return i; } + public boolean isConcurrent() { return true; } + public boolean permitsNulls() { return false; } + } public static class Generic extends BlockingQueueTest { protected BlockingQueue emptyCollection() { @@ -32,12 +39,13 @@ public class LinkedTransferQueueTest ext } public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { return newTestSuite(LinkedTransferQueueTest.class, - new Generic().testSuite()); + new Generic().testSuite(), + CollectionTest.testSuite(new Implementation())); } /** @@ -78,7 +86,7 @@ public class LinkedTransferQueueTest ext */ public void testConstructor4() { Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) + for (int i = 0; i < SIZE - 1; ++i) ints[i] = i; Collection elements = Arrays.asList(ints); try { @@ -132,8 +140,8 @@ public class LinkedTransferQueueTest ext * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { + LinkedTransferQueue q = populatedQueue(SIZE); try { - LinkedTransferQueue q = populatedQueue(SIZE); q.addAll(q); shouldThrow(); } catch (IllegalArgumentException success) {} @@ -144,12 +152,11 @@ public class LinkedTransferQueueTest ext * NullPointerException after possibly adding some elements */ public void testAddAll3() { + LinkedTransferQueue q = new LinkedTransferQueue(); + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + ints[i] = i; try { - LinkedTransferQueue q = new LinkedTransferQueue(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE - 1; ++i) { - ints[i] = i; - } q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} @@ -862,8 +869,8 @@ public class LinkedTransferQueueTest ext * tryTransfer(null) throws NullPointerException */ public void testTryTransfer1() { + final LinkedTransferQueue q = new LinkedTransferQueue(); try { - final LinkedTransferQueue q = new LinkedTransferQueue(); q.tryTransfer(null); shouldThrow(); } catch (NullPointerException success) {}