--- jsr166/src/test/tck/LinkedBlockingDequeTest.java 2010/09/29 12:33:48 1.23 +++ jsr166/src/test/tck/LinkedBlockingDequeTest.java 2010/10/09 19:30:35 1.25 @@ -11,12 +11,27 @@ import static java.util.concurrent.TimeU import java.io.*; public class LinkedBlockingDequeTest extends JSR166TestCase { + + public static class Unbounded extends BlockingQueueTest { + protected BlockingQueue emptyCollection() { + return new LinkedBlockingDeque(); + } + } + + public static class Bounded extends BlockingQueueTest { + protected BlockingQueue emptyCollection() { + return new LinkedBlockingDeque(20); + } + } + public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { - return new TestSuite(LinkedBlockingDequeTest.class); + return newTestSuite(LinkedBlockingDequeTest.class, + new Unbounded().testSuite(), + new Bounded().testSuite()); } /** @@ -93,7 +108,7 @@ public class LinkedBlockingDequeTest ext } /** - * pollFirst succeeds unless empty + * pollFirst succeeds unless empty */ public void testPollFirst() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -104,7 +119,7 @@ public class LinkedBlockingDequeTest ext } /** - * pollLast succeeds unless empty + * pollLast succeeds unless empty */ public void testPollLast() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -115,7 +130,7 @@ public class LinkedBlockingDequeTest ext } /** - * peekFirst returns next element, or null if empty + * peekFirst returns next element, or null if empty */ public void testPeekFirst() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -129,7 +144,7 @@ public class LinkedBlockingDequeTest ext } /** - * peek returns next element, or null if empty + * peek returns next element, or null if empty */ public void testPeek() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -143,7 +158,7 @@ public class LinkedBlockingDequeTest ext } /** - * peekLast returns next element, or null if empty + * peekLast returns next element, or null if empty */ public void testPeekLast() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -173,7 +188,7 @@ public class LinkedBlockingDequeTest ext } /** - * getLast() returns last element, or throws NSEE if empty + * getLast() returns last element, or throws NSEE if empty */ public void testLastElement() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -219,7 +234,7 @@ public class LinkedBlockingDequeTest ext } /** - * remove removes next element, or throws NSEE if empty + * remove removes next element, or throws NSEE if empty */ public void testRemove() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -442,7 +457,7 @@ public class LinkedBlockingDequeTest ext /** - * pop removes next element, or throws NSEE if empty + * pop removes next element, or throws NSEE if empty */ public void testPop() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -762,30 +777,6 @@ public class LinkedBlockingDequeTest ext } /** - * timed poll before a delayed offer fails; after offer succeeds; - * on interruption throws - */ - public void testTimedPollWithOffer() throws InterruptedException { - final LinkedBlockingDeque q = new LinkedBlockingDeque(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(); - } - - - /** * putFirst(null) throws NPE */ public void testPutFirstNull() throws InterruptedException { @@ -976,8 +967,8 @@ public class LinkedBlockingDequeTest ext } /** - * timed pollFirst before a delayed offerFirst fails; after offerFirst succeeds; - * on interruption throws + * timed pollFirst before a delayed offerFirst fails; after offerFirst succeeds; + * on interruption throws */ public void testTimedPollFirstWithOfferFirst() throws InterruptedException { final LinkedBlockingDeque q = new LinkedBlockingDeque(2); @@ -1188,8 +1179,8 @@ public class LinkedBlockingDequeTest ext } /** - * timed poll before a delayed offerLast fails; after offerLast succeeds; - * on interruption throws + * timed poll before a delayed offerLast fails; after offerLast succeeds; + * on interruption throws */ public void testTimedPollWithOfferLast() throws InterruptedException { final LinkedBlockingDeque q = new LinkedBlockingDeque(2); @@ -1426,7 +1417,7 @@ public class LinkedBlockingDequeTest ext /** - * Descending iterator iterates through all elements + * Descending iterator iterates through all elements */ public void testDescendingIterator() { LinkedBlockingDeque q = populatedDeque(SIZE); @@ -1445,7 +1436,7 @@ public class LinkedBlockingDequeTest ext } /** - * Descending iterator ordering is reverse FIFO + * Descending iterator ordering is reverse FIFO */ public void testDescendingIteratorOrdering() { final LinkedBlockingDeque q = new LinkedBlockingDeque();