11 |
|
import java.io.*; |
12 |
|
|
13 |
|
public class LinkedBlockingDequeTest extends JSR166TestCase { |
14 |
+ |
|
15 |
+ |
public static class Unbounded extends BlockingQueueTest { |
16 |
+ |
protected BlockingQueue emptyCollection() { |
17 |
+ |
return new LinkedBlockingDeque(); |
18 |
+ |
} |
19 |
+ |
} |
20 |
+ |
|
21 |
+ |
public static class Bounded extends BlockingQueueTest { |
22 |
+ |
protected BlockingQueue emptyCollection() { |
23 |
+ |
return new LinkedBlockingDeque(20); |
24 |
+ |
} |
25 |
+ |
} |
26 |
+ |
|
27 |
|
public static void main(String[] args) { |
28 |
|
junit.textui.TestRunner.run(suite()); |
29 |
|
} |
30 |
|
|
31 |
|
public static Test suite() { |
32 |
< |
return new TestSuite(LinkedBlockingDequeTest.class); |
32 |
> |
return newTestSuite(LinkedBlockingDequeTest.class, |
33 |
> |
new Unbounded().testSuite(), |
34 |
> |
new Bounded().testSuite()); |
35 |
|
} |
36 |
|
|
37 |
|
/** |
777 |
|
} |
778 |
|
|
779 |
|
/** |
765 |
– |
* timed poll before a delayed offer fails; after offer succeeds; |
766 |
– |
* on interruption throws |
767 |
– |
*/ |
768 |
– |
public void testTimedPollWithOffer() throws InterruptedException { |
769 |
– |
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |
770 |
– |
Thread t = new Thread(new CheckedRunnable() { |
771 |
– |
public void realRun() throws InterruptedException { |
772 |
– |
try { |
773 |
– |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
774 |
– |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
775 |
– |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
776 |
– |
shouldThrow(); |
777 |
– |
} catch (InterruptedException success) {} |
778 |
– |
}}); |
779 |
– |
|
780 |
– |
t.start(); |
781 |
– |
Thread.sleep(SMALL_DELAY_MS); |
782 |
– |
assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); |
783 |
– |
t.interrupt(); |
784 |
– |
t.join(); |
785 |
– |
} |
786 |
– |
|
787 |
– |
|
788 |
– |
/** |
780 |
|
* putFirst(null) throws NPE |
781 |
|
*/ |
782 |
|
public void testPutFirstNull() throws InterruptedException { |
1179 |
|
} |
1180 |
|
|
1181 |
|
/** |
1182 |
< |
* timed poll before a delayed offerLast fails; after offerLast succeeds; |
1183 |
< |
* on interruption throws |
1182 |
> |
* timed poll before a delayed offerLast fails; after offerLast succeeds; |
1183 |
> |
* on interruption throws |
1184 |
|
*/ |
1185 |
|
public void testTimedPollWithOfferLast() throws InterruptedException { |
1186 |
|
final LinkedBlockingDeque q = new LinkedBlockingDeque(2); |