24 |
|
@SuppressWarnings({"unchecked", "rawtypes"}) |
25 |
|
public class LinkedTransferQueueTest extends JSR166TestCase { |
26 |
|
|
27 |
+ |
public static class Generic extends BlockingQueueTest { |
28 |
+ |
protected BlockingQueue emptyCollection() { |
29 |
+ |
return new LinkedTransferQueue(); |
30 |
+ |
} |
31 |
+ |
} |
32 |
+ |
|
33 |
|
public static void main(String[] args) { |
34 |
|
junit.textui.TestRunner.run(suite()); |
35 |
|
} |
36 |
|
|
37 |
|
public static Test suite() { |
38 |
< |
return new TestSuite(LinkedTransferQueueTest.class); |
38 |
> |
return newTestSuite(LinkedTransferQueueTest.class, |
39 |
> |
new Generic().testSuite()); |
40 |
|
} |
41 |
|
|
42 |
|
void checkEmpty(LinkedTransferQueue q) throws InterruptedException { |
375 |
|
} |
376 |
|
|
377 |
|
/** |
371 |
– |
* timed poll before a delayed offer fails; after offer succeeds; |
372 |
– |
* on interruption throws |
373 |
– |
*/ |
374 |
– |
public void testTimedPollWithOffer() throws InterruptedException { |
375 |
– |
final LinkedTransferQueue q = new LinkedTransferQueue(); |
376 |
– |
Thread t = new Thread(new CheckedRunnable() { |
377 |
– |
public void realRun() throws InterruptedException { |
378 |
– |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
379 |
– |
assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
380 |
– |
try { |
381 |
– |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
382 |
– |
shouldThrow(); |
383 |
– |
} catch (InterruptedException success) {} |
384 |
– |
}}); |
385 |
– |
|
386 |
– |
t.start(); |
387 |
– |
Thread.sleep(SMALL_DELAY_MS); |
388 |
– |
assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); |
389 |
– |
t.interrupt(); |
390 |
– |
t.join(); |
391 |
– |
} |
392 |
– |
|
393 |
– |
/** |
378 |
|
* peek returns next element, or null if empty |
379 |
|
*/ |
380 |
|
public void testPeek() throws InterruptedException { |