--- jsr166/src/test/tck/AbstractQueueTest.java 2015/02/28 18:06:38 1.11 +++ jsr166/src/test/tck/AbstractQueueTest.java 2021/01/26 13:33:05 1.19 @@ -16,32 +16,32 @@ 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); } - static class Succeed extends AbstractQueue { - public boolean offer(Integer x) { + static class Succeed extends AbstractQueue { + public boolean offer(Item x) { if (x == null) throw new NullPointerException(); return true; } - public Integer peek() { return one; } - public Integer poll() { return one; } + public Item peek() { return one; } + public Item poll() { return one; } public int size() { return 0; } - public Iterator iterator() { return null; } // not needed + public Iterator iterator() { return null; } // not needed } - static class Fail extends AbstractQueue { - public boolean offer(Integer x) { + static class Fail extends AbstractQueue { + public boolean offer(Item x) { if (x == null) throw new NullPointerException(); return false; } - public Integer peek() { return null; } - public Integer poll() { return null; } + public Item peek() { return null; } + public Item poll() { return null; } public int size() { return 0; } - public Iterator iterator() { return null; } // not needed + public Iterator iterator() { return null; } // not needed } /** @@ -53,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(); @@ -64,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(); @@ -79,7 +79,7 @@ public class AbstractQueueTest extends J */ public void testRemoveS() { Succeed q = new Succeed(); - q.remove(); + assertSame(one, q.remove()); } /** @@ -98,7 +98,7 @@ public class AbstractQueueTest extends J */ public void testElementS() { Succeed q = new Succeed(); - q.element(); + assertSame(one, q.element()); } /** @@ -113,7 +113,7 @@ public class AbstractQueueTest extends J } /** - * addAll(null) throws NPE + * addAll(null) throws NullPointerException */ public void testAddAll1() { Succeed q = new Succeed(); @@ -124,7 +124,7 @@ public class AbstractQueueTest extends J } /** - * addAll(this) throws IAE + * addAll(this) throws IllegalArgumentException */ public void testAddAllSelf() { Succeed q = new Succeed(); @@ -135,13 +135,13 @@ public class AbstractQueueTest extends J } /** - * 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]; + Item[] items = new Item[SIZE]; try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (NullPointerException success) {} } @@ -152,25 +152,23 @@ public class AbstractQueueTest extends J */ 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); + Item[] items = new Item[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + items[i] = itemFor(i); try { - q.addAll(Arrays.asList(ints)); + q.addAll(Arrays.asList(items)); 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(); + Item[] items = seqItems(SIZE); 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)); + q.addAll(Arrays.asList(items)); shouldThrow(); } catch (IllegalStateException success) {} }