ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/SynchronousQueueTest.java
(Generate patch)

Comparing jsr166/src/test/tck/SynchronousQueueTest.java (file contents):
Revision 1.24 by dl, Wed Sep 29 12:33:48 2010 UTC vs.
Revision 1.25 by jsr166, Wed Oct 6 07:49:23 2010 UTC

# Line 14 | Line 14 | import java.io.*;
14  
15   public class SynchronousQueueTest extends JSR166TestCase {
16  
17 +    public static class Fair extends BlockingQueueTest {
18 +        protected BlockingQueue emptyCollection() {
19 +            return new SynchronousQueue(true);
20 +        }
21 +    }
22 +
23 +    public static class NonFair extends BlockingQueueTest {
24 +        protected BlockingQueue emptyCollection() {
25 +            return new SynchronousQueue(false);
26 +        }
27 +    }
28 +
29      public static void main(String[] args) {
30          junit.textui.TestRunner.run(suite());
31      }
32  
33      public static Test suite() {
34 <        return new TestSuite(SynchronousQueueTest.class);
34 >        return newTestSuite(SynchronousQueueTest.class,
35 >                            new Fair().testSuite(),
36 >                            new NonFair().testSuite());
37      }
38  
39      /**
# Line 338 | Line 352 | public class SynchronousQueueTest extend
352          t.interrupt();
353          t.join();
354      }
341
342    /**
343     *  timed poll before a delayed offer fails; after offer succeeds;
344     *  on interruption throws
345     */
346    public void testTimedPollWithOffer() throws InterruptedException {
347        final SynchronousQueue q = new SynchronousQueue();
348        Thread t = new Thread(new CheckedRunnable() {
349            public void realRun() throws InterruptedException {
350                try {
351                    assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
352                    assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));
353                    q.poll(LONG_DELAY_MS, MILLISECONDS);
354                    shouldThrow();
355                } catch (InterruptedException success) {}
356            }});
357
358        t.start();
359        Thread.sleep(SMALL_DELAY_MS);
360        assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS));
361        t.interrupt();
362        t.join();
363    }
355  
356      /**
357       * Interrupted timed poll throws InterruptedException instead of

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines