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

Comparing jsr166/src/test/tck/ArrayBlockingQueueTest.java (file contents):
Revision 1.81 by jsr166, Sun Nov 6 06:27:04 2016 UTC vs.
Revision 1.87 by jsr166, Sun May 14 00:56:43 2017 UTC

# Line 340 | Line 340 | public class ArrayBlockingQueueTest exte
340              }});
341  
342          await(pleaseInterrupt);
343 <        assertThreadStaysAlive(t);
343 >        assertThreadBlocks(t, Thread.State.WAITING);
344          t.interrupt();
345          awaitTermination(t);
346          assertEquals(SIZE, q.size());
# Line 375 | Line 375 | public class ArrayBlockingQueueTest exte
375          assertEquals(0, q.take());
376  
377          await(pleaseInterrupt);
378 <        assertThreadStaysAlive(t);
378 >        assertThreadBlocks(t, Thread.State.WAITING);
379          t.interrupt();
380          awaitTermination(t);
381          assertEquals(0, q.remainingCapacity());
# Line 399 | Line 399 | public class ArrayBlockingQueueTest exte
399                      q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
400                      shouldThrow();
401                  } catch (InterruptedException success) {}
402 +                assertFalse(Thread.interrupted());
403              }});
404  
405          await(pleaseInterrupt);
406 <        assertThreadStaysAlive(t);
406 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
407          t.interrupt();
408          awaitTermination(t);
409      }
# Line 425 | Line 426 | public class ArrayBlockingQueueTest exte
426          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
427          Thread t = newStartedThread(new CheckedRunnable() {
428              public void realRun() throws InterruptedException {
429 <                for (int i = 0; i < SIZE; ++i) {
429 <                    assertEquals(i, q.take());
430 <                }
429 >                for (int i = 0; i < SIZE; i++) assertEquals(i, q.take());
430  
431                  Thread.currentThread().interrupt();
432                  try {
# Line 445 | Line 444 | public class ArrayBlockingQueueTest exte
444              }});
445  
446          await(pleaseInterrupt);
447 <        assertThreadStaysAlive(t);
447 >        assertThreadBlocks(t, Thread.State.WAITING);
448          t.interrupt();
449          awaitTermination(t);
450      }
# Line 495 | Line 494 | public class ArrayBlockingQueueTest exte
494       */
495      public void testInterruptedTimedPoll() throws InterruptedException {
496          final BlockingQueue<Integer> q = populatedQueue(SIZE);
497 <        final CountDownLatch aboutToWait = new CountDownLatch(1);
497 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
498          Thread t = newStartedThread(new CheckedRunnable() {
499              public void realRun() throws InterruptedException {
500                  long startTime = System.nanoTime();
501                  for (int i = 0; i < SIZE; ++i) {
502                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
503                  }
504 <                aboutToWait.countDown();
504 >
505 >                pleaseInterrupt.countDown();
506                  try {
507                      q.poll(LONG_DELAY_MS, MILLISECONDS);
508                      shouldThrow();
509 <                } catch (InterruptedException success) {
510 <                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
511 <                }
509 >                } catch (InterruptedException success) {}
510 >                assertFalse(Thread.interrupted());
511 >
512 >                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
513              }});
514  
515 <        await(aboutToWait);
516 <        waitForThreadToEnterWaitState(t);
515 >        await(pleaseInterrupt);
516 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
517          t.interrupt();
518          awaitTermination(t);
519          checkEmpty(q);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines