--- jsr166/src/test/tck/AbstractQueueTest.java 2011/05/27 19:07:06 1.8 +++ jsr166/src/test/tck/AbstractQueueTest.java 2018/01/10 16:46:21 1.17 @@ -6,15 +6,17 @@ * Pat Fisher, Mike Judd. */ -import junit.framework.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; -import java.io.*; +import java.util.AbstractQueue; +import java.util.Arrays; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import junit.framework.Test; +import junit.framework.TestSuite; public class AbstractQueueTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { return new TestSuite(AbstractQueueTest.class); @@ -51,7 +53,7 @@ public class AbstractQueueTest extends J } /** - * add throws ISE true if offer fails + * add throws IllegalStateException if offer fails */ public void testAddF() { Fail q = new Fail(); @@ -62,7 +64,7 @@ public class AbstractQueueTest extends J } /** - * add throws NPE if offer does + * add throws NullPointerException if offer does */ public void testAddNPE() { Succeed q = new Succeed(); @@ -77,7 +79,7 @@ public class AbstractQueueTest extends J */ public void testRemoveS() { Succeed q = new Succeed(); - q.remove(); + assertSame(one, q.remove()); } /** @@ -111,34 +113,34 @@ public class AbstractQueueTest extends J } /** - * addAll(null) throws NPE + * addAll(null) throws NullPointerException */ public void testAddAll1() { + Succeed q = new Succeed(); try { - Succeed q = new Succeed(); q.addAll(null); shouldThrow(); } catch (NullPointerException success) {} } /** - * addAll(this) throws IAE + * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { + Succeed q = new Succeed(); try { - Succeed q = new Succeed(); q.addAll(q); shouldThrow(); } catch (IllegalArgumentException success) {} } /** - * addAll of a collection with null elements throws NPE + * addAll of a collection with null elements throws NullPointerException */ public void testAddAll2() { + Succeed q = new Succeed(); + Integer[] ints = new Integer[SIZE]; try { - Succeed q = new Succeed(); - Integer[] ints = new Integer[SIZE]; q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} @@ -149,25 +151,25 @@ public class AbstractQueueTest extends J * possibly adding some elements */ public void testAddAll3() { + Succeed q = new Succeed(); + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + ints[i] = new Integer(i); try { - Succeed q = new Succeed(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} } /** - * addAll throws ISE if an add fails + * addAll throws IllegalStateException if an add fails */ public void testAddAll4() { + Fail q = new Fail(); + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE; ++i) + ints[i] = new Integer(i); try { - Fail q = new Fail(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(i); q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (IllegalStateException success) {}