[cvs] / jsr166 / src / test / tck / ArrayBlockingQueueTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/ArrayBlockingQueueTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31, Wed Sep 29 12:33:48 2010 UTC revision 1.32, Wed Oct 6 07:49:22 2010 UTC
# Line 14  Line 14 
14  import java.io.*;  import java.io.*;
15    
16  public class ArrayBlockingQueueTest extends JSR166TestCase {  public class ArrayBlockingQueueTest extends JSR166TestCase {
17    
18        public static class Fair extends BlockingQueueTest {
19            protected BlockingQueue emptyCollection() {
20                return new ArrayBlockingQueue(20, true);
21            }
22        }
23    
24        public static class NonFair extends BlockingQueueTest {
25            protected BlockingQueue emptyCollection() {
26                return new ArrayBlockingQueue(20, false);
27            }
28        }
29    
30      public static void main(String[] args) {      public static void main(String[] args) {
31          junit.textui.TestRunner.run(suite());          junit.textui.TestRunner.run(suite());
32      }      }
33    
34      public static Test suite() {      public static Test suite() {
35          return new TestSuite(ArrayBlockingQueueTest.class);          return newTestSuite(ArrayBlockingQueueTest.class,
36                                new Fair().testSuite(),
37                                new NonFair().testSuite());
38      }      }
39    
40      /**      /**
# Line 472  Line 488 
488      }      }
489    
490      /**      /**
      *  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();  
     }  
   
   
     /**  
491       * peek returns next element, or null if empty       * peek returns next element, or null if empty
492       */       */
493      public void testPeek() {      public void testPeek() {

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8