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.68 by jsr166, Sat May 13 21:52:59 2017 UTC vs.
Revision 1.73 by jsr166, Sun May 14 01:30:34 2017 UTC

# Line 292 | Line 292 | public class LinkedBlockingQueueTest ext
292              }});
293  
294          await(pleaseInterrupt);
295 <        assertThreadStaysAlive(t);
295 >        assertThreadBlocks(t, Thread.State.WAITING);
296          t.interrupt();
297          awaitTermination(t);
298          assertEquals(SIZE, q.size());
# Line 351 | Line 351 | public class LinkedBlockingQueueTest ext
351                      q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
352                      shouldThrow();
353                  } catch (InterruptedException success) {}
354 +                assertFalse(Thread.interrupted());
355              }});
356  
357          await(pleaseInterrupt);
358 <        assertThreadStaysAlive(t);
358 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
359          t.interrupt();
360          awaitTermination(t);
361      }
# Line 444 | Line 445 | public class LinkedBlockingQueueTest ext
445       */
446      public void testInterruptedTimedPoll() throws InterruptedException {
447          final BlockingQueue<Integer> q = populatedQueue(SIZE);
448 <        final CountDownLatch aboutToWait = new CountDownLatch(1);
448 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
449          Thread t = newStartedThread(new CheckedRunnable() {
450              public void realRun() throws InterruptedException {
451                  long startTime = System.nanoTime();
452 <                for (int i = 0; i < SIZE; ++i) {
452 >                for (int i = 0; i < SIZE; i++)
453                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
454 <                }
455 <                aboutToWait.countDown();
454 >
455 >                Thread.currentThread().interrupt();
456 >                try {
457 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
458 >                    shouldThrow();
459 >                } catch (InterruptedException success) {}
460 >                assertFalse(Thread.interrupted());
461 >
462 >                pleaseInterrupt.countDown();
463                  try {
464                      q.poll(LONG_DELAY_MS, MILLISECONDS);
465                      shouldThrow();
466 <                } catch (InterruptedException success) {
467 <                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
468 <                }
466 >                } catch (InterruptedException success) {}
467 >                assertFalse(Thread.interrupted());
468 >
469 >                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
470              }});
471  
472 <        await(aboutToWait);
473 <        waitForThreadToEnterWaitState(t);
472 >        await(pleaseInterrupt);
473 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
474          t.interrupt();
475          awaitTermination(t);
476          checkEmpty(q);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines