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.64 by jsr166, Sun Oct 16 20:44:18 2016 UTC

# Line 48 | Line 48 | public class LinkedBlockingQueueTest ext
48  
49      /**
50       * Returns a new queue of given size containing consecutive
51 <     * Integers 0 ... n.
51 >     * Integers 0 ... n - 1.
52       */
53      private LinkedBlockingQueue<Integer> populatedQueue(int n) {
54          LinkedBlockingQueue<Integer> q =
# Line 59 | Line 59 | public class LinkedBlockingQueueTest ext
59          assertFalse(q.isEmpty());
60          assertEquals(0, q.remainingCapacity());
61          assertEquals(n, q.size());
62 +        assertEquals((Integer) 0, q.peek());
63          return q;
64      }
65  
# Line 440 | Line 441 | public class LinkedBlockingQueueTest ext
441          final CountDownLatch aboutToWait = new CountDownLatch(1);
442          Thread t = newStartedThread(new CheckedRunnable() {
443              public void realRun() throws InterruptedException {
444 +                long startTime = System.nanoTime();
445                  for (int i = 0; i < SIZE; ++i) {
444                    long t0 = System.nanoTime();
446                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
446                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
447                  }
448                long t0 = System.nanoTime();
448                  aboutToWait.countDown();
449                  try {
450 <                    q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
450 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
451                      shouldThrow();
452                  } catch (InterruptedException success) {
453 <                    assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
453 >                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
454                  }
455              }});
456  
457 <        aboutToWait.await();
458 <        waitForThreadToEnterWaitState(t, SMALL_DELAY_MS);
457 >        await(aboutToWait);
458 >        waitForThreadToEnterWaitState(t);
459          t.interrupt();
460 <        awaitTermination(t, MEDIUM_DELAY_MS);
460 >        awaitTermination(t);
461          checkEmpty(q);
462      }
463  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines