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

Comparing jsr166/src/test/tck/LinkedBlockingDequeTest.java (file contents):
Revision 1.75 by jsr166, Sat May 13 23:50:00 2017 UTC vs.
Revision 1.79 by jsr166, Sun May 14 04:02:06 2017 UTC

# Line 626 | Line 626 | public class LinkedBlockingDequeTest ext
626                  pleaseTake.countDown();
627                  q.put(86);
628  
629 +                Thread.currentThread().interrupt();
630 +                try {
631 +                    q.put(99);
632 +                    shouldThrow();
633 +                } catch (InterruptedException success) {}
634 +                assertFalse(Thread.interrupted());
635 +
636                  pleaseInterrupt.countDown();
637                  try {
638                      q.put(99);
# Line 663 | Line 670 | public class LinkedBlockingDequeTest ext
670                      q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
671                      shouldThrow();
672                  } catch (InterruptedException success) {}
673 +                assertFalse(Thread.interrupted());
674              }});
675  
676          await(pleaseInterrupt);
# Line 756 | Line 764 | public class LinkedBlockingDequeTest ext
764       */
765      public void testInterruptedTimedPoll() throws InterruptedException {
766          final BlockingQueue<Integer> q = populatedDeque(SIZE);
767 <        final CountDownLatch aboutToWait = new CountDownLatch(1);
767 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
768          Thread t = newStartedThread(new CheckedRunnable() {
769              public void realRun() throws InterruptedException {
770                  long startTime = System.nanoTime();
771 <                for (int i = 0; i < SIZE; ++i) {
771 >                for (int i = 0; i < SIZE; i++)
772                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
773 <                }
774 <                aboutToWait.countDown();
773 >
774 >                Thread.currentThread().interrupt();
775                  try {
776                      q.poll(LONG_DELAY_MS, MILLISECONDS);
777                      shouldThrow();
778 <                } catch (InterruptedException success) {
779 <                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
780 <                }
778 >                } catch (InterruptedException success) {}
779 >                assertFalse(Thread.interrupted());
780 >
781 >                pleaseInterrupt.countDown();
782 >                try {
783 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
784 >                    shouldThrow();
785 >                } catch (InterruptedException success) {}
786 >                assertFalse(Thread.interrupted());
787 >
788 >                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
789              }});
790  
791 <        await(aboutToWait);
791 >        await(pleaseInterrupt);
792          assertThreadBlocks(t, Thread.State.TIMED_WAITING);
793          t.interrupt();
794          awaitTermination(t);
# Line 891 | Line 907 | public class LinkedBlockingDequeTest ext
907                      q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
908                      shouldThrow();
909                  } catch (InterruptedException success) {}
910 +                assertFalse(Thread.interrupted());
911              }});
912  
913          await(pleaseInterrupt);
# Line 1059 | Line 1076 | public class LinkedBlockingDequeTest ext
1076          Thread t = newStartedThread(new CheckedRunnable() {
1077              public void realRun() throws InterruptedException {
1078                  long startTime = System.nanoTime();
1079 <                for (int i = 0; i < SIZE; ++i) {
1079 >                for (int i = 0; i < SIZE; i++)
1080                      assertEquals(i, q.pollFirst(LONG_DELAY_MS, MILLISECONDS));
1064                }
1081  
1082                  Thread.currentThread().interrupt();
1083                  try {
# Line 1076 | Line 1092 | public class LinkedBlockingDequeTest ext
1092                      shouldThrow();
1093                  } catch (InterruptedException success) {}
1094                  assertFalse(Thread.interrupted());
1095 +
1096                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1097              }});
1098  
# Line 1113 | Line 1130 | public class LinkedBlockingDequeTest ext
1130                      q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
1131                      shouldThrow();
1132                  } catch (InterruptedException success) {}
1133 +                assertFalse(Thread.interrupted());
1134                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1135              }});
1136  
# Line 1325 | Line 1343 | public class LinkedBlockingDequeTest ext
1343          Thread t = newStartedThread(new CheckedRunnable() {
1344              public void realRun() throws InterruptedException {
1345                  long startTime = System.nanoTime();
1346 <                for (int i = 0; i < SIZE; ++i) {
1346 >                for (int i = 0; i < SIZE; i++)
1347                      assertEquals(SIZE - i - 1,
1348                                   q.pollLast(LONG_DELAY_MS, MILLISECONDS));
1331                }
1349  
1350                  Thread.currentThread().interrupt();
1351                  try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines