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

Comparing jsr166/src/test/tck/LinkedBlockingQueueTest.java (file contents):
Revision 1.61 by jsr166, Sun Oct 4 18:49:02 2015 UTC vs.
Revision 1.65 by jsr166, Mon Oct 17 01:31:30 2016 UTC

# Line 41 | Line 41 | public class LinkedBlockingQueueTest ext
41      }
42  
43      public static Test suite() {
44 +        class Implementation implements CollectionImplementation {
45 +            public Class<?> klazz() { return LinkedBlockingQueue.class; }
46 +            public Collection emptyCollection() { return new LinkedBlockingQueue(); }
47 +            public Object makeElement(int i) { return i; }
48 +            public boolean isConcurrent() { return true; }
49 +            public boolean permitsNulls() { return false; }
50 +        }
51          return newTestSuite(LinkedBlockingQueueTest.class,
52                              new Unbounded().testSuite(),
53 <                            new Bounded().testSuite());
53 >                            new Bounded().testSuite(),
54 >                            CollectionTest.testSuite(new Implementation()));
55      }
56  
57      /**
58       * Returns a new queue of given size containing consecutive
59 <     * Integers 0 ... n.
59 >     * Integers 0 ... n - 1.
60       */
61      private LinkedBlockingQueue<Integer> populatedQueue(int n) {
62          LinkedBlockingQueue<Integer> q =
# Line 59 | Line 67 | public class LinkedBlockingQueueTest ext
67          assertFalse(q.isEmpty());
68          assertEquals(0, q.remainingCapacity());
69          assertEquals(n, q.size());
70 +        assertEquals((Integer) 0, q.peek());
71          return q;
72      }
73  
# Line 440 | Line 449 | public class LinkedBlockingQueueTest ext
449          final CountDownLatch aboutToWait = new CountDownLatch(1);
450          Thread t = newStartedThread(new CheckedRunnable() {
451              public void realRun() throws InterruptedException {
452 +                long startTime = System.nanoTime();
453                  for (int i = 0; i < SIZE; ++i) {
444                    long t0 = System.nanoTime();
454                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
446                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
455                  }
448                long t0 = System.nanoTime();
456                  aboutToWait.countDown();
457                  try {
458 <                    q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
458 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
459                      shouldThrow();
460                  } catch (InterruptedException success) {
461 <                    assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
461 >                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
462                  }
463              }});
464  
465 <        aboutToWait.await();
466 <        waitForThreadToEnterWaitState(t, SMALL_DELAY_MS);
465 >        await(aboutToWait);
466 >        waitForThreadToEnterWaitState(t);
467          t.interrupt();
468 <        awaitTermination(t, MEDIUM_DELAY_MS);
468 >        awaitTermination(t);
469          checkEmpty(q);
470      }
471  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines