--- jsr166/src/test/tck/ArrayBlockingQueueTest.java 2010/09/29 12:33:48 1.31 +++ jsr166/src/test/tck/ArrayBlockingQueueTest.java 2010/10/09 19:30:34 1.33 @@ -14,11 +14,27 @@ import static java.util.concurrent.TimeU import java.io.*; public class ArrayBlockingQueueTest extends JSR166TestCase { + + public static class Fair extends BlockingQueueTest { + protected BlockingQueue emptyCollection() { + return new ArrayBlockingQueue(20, true); + } + } + + public static class NonFair extends BlockingQueueTest { + protected BlockingQueue emptyCollection() { + return new ArrayBlockingQueue(20, false); + } + } + public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } + public static Test suite() { - return new TestSuite(ArrayBlockingQueueTest.class); + return newTestSuite(ArrayBlockingQueueTest.class, + new Fair().testSuite(), + new NonFair().testSuite()); } /** @@ -145,7 +161,7 @@ public class ArrayBlockingQueueTest exte } /** - * offer(null) throws NPE + * offer(null) throws NPE */ public void testOfferNull() { try { @@ -156,7 +172,7 @@ public class ArrayBlockingQueueTest exte } /** - * add(null) throws NPE + * add(null) throws NPE */ public void testAddNull() { try { @@ -191,7 +207,7 @@ public class ArrayBlockingQueueTest exte } /** - * addAll(null) throws NPE + * addAll(null) throws NPE */ public void testAddAll1() { try { @@ -214,7 +230,7 @@ public class ArrayBlockingQueueTest exte /** - * addAll of a collection with null elements throws NPE + * addAll of a collection with null elements throws NPE */ public void testAddAll2() { try { @@ -270,7 +286,7 @@ public class ArrayBlockingQueueTest exte } /** - * put(null) throws NPE + * put(null) throws NPE */ public void testPutNull() throws InterruptedException { try { @@ -472,30 +488,6 @@ public class ArrayBlockingQueueTest exte } /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() throws InterruptedException { - final ArrayBlockingQueue q = new ArrayBlockingQueue(2); - Thread t = new Thread(new CheckedRunnable() { - public void realRun() throws InterruptedException { - try { - assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); - assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); - q.poll(LONG_DELAY_MS, MILLISECONDS); - shouldThrow(); - } catch (InterruptedException success) {} - }}); - - t.start(); - Thread.sleep(SMALL_DELAY_MS); - assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); - t.interrupt(); - t.join(); - } - - - /** * peek returns next element, or null if empty */ public void testPeek() { @@ -631,7 +623,7 @@ public class ArrayBlockingQueueTest exte } /** - * toArray contains all elements + * toArray contains all elements */ public void testToArray() throws InterruptedException { ArrayBlockingQueue q = populatedQueue(SIZE);