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.68 by jsr166, Sat Mar 25 21:41:10 2017 UTC vs.
Revision 1.77 by jsr166, Sun May 14 00:56:43 2017 UTC

# Line 604 | Line 604 | public class LinkedBlockingDequeTest ext
604              }});
605  
606          await(pleaseInterrupt);
607 <        assertThreadStaysAlive(t);
607 >        assertThreadBlocks(t, Thread.State.WAITING);
608          t.interrupt();
609          awaitTermination(t);
610          assertEquals(SIZE, q.size());
# Line 639 | Line 639 | public class LinkedBlockingDequeTest ext
639          assertEquals(0, q.take());
640  
641          await(pleaseInterrupt);
642 <        assertThreadStaysAlive(t);
642 >        assertThreadBlocks(t, Thread.State.WAITING);
643          t.interrupt();
644          awaitTermination(t);
645          assertEquals(0, q.remainingCapacity());
# Line 663 | Line 663 | public class LinkedBlockingDequeTest ext
663                      q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
664                      shouldThrow();
665                  } catch (InterruptedException success) {}
666 +                assertFalse(Thread.interrupted());
667              }});
668  
669          await(pleaseInterrupt);
670 <        assertThreadStaysAlive(t);
670 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
671          t.interrupt();
672          awaitTermination(t);
673      }
# Line 689 | Line 690 | public class LinkedBlockingDequeTest ext
690          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
691          Thread t = newStartedThread(new CheckedRunnable() {
692              public void realRun() throws InterruptedException {
693 <                for (int i = 0; i < SIZE; ++i) {
693 <                    assertEquals(i, q.take());
694 <                }
693 >                for (int i = 0; i < SIZE; i++) assertEquals(i, q.take());
694  
695                  Thread.currentThread().interrupt();
696                  try {
# Line 709 | Line 708 | public class LinkedBlockingDequeTest ext
708              }});
709  
710          await(pleaseInterrupt);
711 <        assertThreadStaysAlive(t);
711 >        assertThreadBlocks(t, Thread.State.WAITING);
712          t.interrupt();
713          awaitTermination(t);
714      }
# Line 758 | Line 757 | public class LinkedBlockingDequeTest ext
757       */
758      public void testInterruptedTimedPoll() throws InterruptedException {
759          final BlockingQueue<Integer> q = populatedDeque(SIZE);
760 <        final CountDownLatch aboutToWait = new CountDownLatch(1);
760 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
761          Thread t = newStartedThread(new CheckedRunnable() {
762              public void realRun() throws InterruptedException {
763                  long startTime = System.nanoTime();
764                  for (int i = 0; i < SIZE; ++i) {
765                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
766                  }
767 <                aboutToWait.countDown();
767 >
768 >                pleaseInterrupt.countDown();
769                  try {
770                      q.poll(LONG_DELAY_MS, MILLISECONDS);
771                      shouldThrow();
772 <                } catch (InterruptedException success) {
773 <                    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
774 <                }
772 >                } catch (InterruptedException success) {}
773 >                assertFalse(Thread.interrupted());
774 >
775 >                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
776              }});
777  
778 <        await(aboutToWait);
779 <        waitForThreadToEnterWaitState(t);
778 >        await(pleaseInterrupt);
779 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
780          t.interrupt();
781          awaitTermination(t);
782          checkEmpty(q);
# Line 834 | Line 835 | public class LinkedBlockingDequeTest ext
835              }});
836  
837          await(pleaseInterrupt);
838 <        assertThreadStaysAlive(t);
838 >        assertThreadBlocks(t, Thread.State.WAITING);
839          t.interrupt();
840          awaitTermination(t);
841          assertEquals(SIZE, q.size());
# Line 869 | Line 870 | public class LinkedBlockingDequeTest ext
870          assertEquals(capacity - 1, q.take());
871  
872          await(pleaseInterrupt);
873 <        assertThreadStaysAlive(t);
873 >        assertThreadBlocks(t, Thread.State.WAITING);
874          t.interrupt();
875          awaitTermination(t);
876          assertEquals(0, q.remainingCapacity());
# Line 893 | Line 894 | public class LinkedBlockingDequeTest ext
894                      q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
895                      shouldThrow();
896                  } catch (InterruptedException success) {}
897 +                assertFalse(Thread.interrupted());
898              }});
899  
900          await(pleaseInterrupt);
901 <        assertThreadStaysAlive(t);
901 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
902          t.interrupt();
903          awaitTermination(t);
904      }
# Line 928 | Line 930 | public class LinkedBlockingDequeTest ext
930              }});
931  
932          await(threadStarted);
933 <        assertThreadStaysAlive(t);
933 >        assertThreadBlocks(t, Thread.State.WAITING);
934          t.interrupt();
935          awaitTermination(t);
936      }
# Line 969 | Line 971 | public class LinkedBlockingDequeTest ext
971              }});
972  
973          await(threadStarted);
974 <        assertThreadStaysAlive(t);
974 >        assertThreadBlocks(t, Thread.State.WAITING);
975          t.interrupt();
976          awaitTermination(t);
977      }
# Line 1001 | Line 1003 | public class LinkedBlockingDequeTest ext
1003          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
1004          Thread t = newStartedThread(new CheckedRunnable() {
1005              public void realRun() throws InterruptedException {
1006 <                for (int i = 0; i < SIZE; ++i) {
1005 <                    assertEquals(i, q.takeFirst());
1006 <                }
1006 >                for (int i = 0; i < SIZE; i++) assertEquals(i, q.takeFirst());
1007  
1008                  Thread.currentThread().interrupt();
1009                  try {
# Line 1021 | Line 1021 | public class LinkedBlockingDequeTest ext
1021              }});
1022  
1023          await(pleaseInterrupt);
1024 <        assertThreadStaysAlive(t);
1024 >        assertThreadBlocks(t, Thread.State.WAITING);
1025          t.interrupt();
1026          awaitTermination(t);
1027      }
# Line 1080 | Line 1080 | public class LinkedBlockingDequeTest ext
1080                      shouldThrow();
1081                  } catch (InterruptedException success) {}
1082                  assertFalse(Thread.interrupted());
1083 +
1084                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1085              }});
1086  
1087          await(pleaseInterrupt);
1088 <        assertThreadStaysAlive(t);
1088 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1089          t.interrupt();
1090          awaitTermination(t);
1091      }
# Line 1117 | Line 1118 | public class LinkedBlockingDequeTest ext
1118                      q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
1119                      shouldThrow();
1120                  } catch (InterruptedException success) {}
1121 +                assertFalse(Thread.interrupted());
1122                  assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1123              }});
1124  
# Line 1125 | Line 1127 | public class LinkedBlockingDequeTest ext
1127          assertTrue(q.offerFirst(zero, LONG_DELAY_MS, MILLISECONDS));
1128          assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1129          barrier.await();
1130 <        assertThreadStaysAlive(t);
1130 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1131          t.interrupt();
1132          awaitTermination(t);
1133      }
# Line 1183 | Line 1185 | public class LinkedBlockingDequeTest ext
1185              }});
1186  
1187          await(pleaseInterrupt);
1188 <        assertThreadStaysAlive(t);
1188 >        assertThreadBlocks(t, Thread.State.WAITING);
1189          t.interrupt();
1190          awaitTermination(t);
1191          assertEquals(SIZE, q.size());
# Line 1218 | Line 1220 | public class LinkedBlockingDequeTest ext
1220          assertEquals(0, q.take());
1221  
1222          await(pleaseInterrupt);
1223 <        assertThreadStaysAlive(t);
1223 >        assertThreadBlocks(t, Thread.State.WAITING);
1224          t.interrupt();
1225          awaitTermination(t);
1226          assertEquals(0, q.remainingCapacity());
# Line 1245 | Line 1247 | public class LinkedBlockingDequeTest ext
1247              }});
1248  
1249          await(pleaseInterrupt);
1250 <        assertThreadStaysAlive(t);
1250 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1251          t.interrupt();
1252          awaitTermination(t);
1253      }
# Line 1268 | Line 1270 | public class LinkedBlockingDequeTest ext
1270          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
1271          Thread t = newStartedThread(new CheckedRunnable() {
1272              public void realRun() throws InterruptedException {
1273 <                for (int i = 0; i < SIZE; ++i) {
1273 >                for (int i = 0; i < SIZE; i++)
1274                      assertEquals(SIZE - i - 1, q.takeLast());
1273                }
1275  
1276                  Thread.currentThread().interrupt();
1277                  try {
# Line 1288 | Line 1289 | public class LinkedBlockingDequeTest ext
1289              }});
1290  
1291          await(pleaseInterrupt);
1292 <        assertThreadStaysAlive(t);
1292 >        assertThreadBlocks(t, Thread.State.WAITING);
1293          t.interrupt();
1294          awaitTermination(t);
1295      }
# Line 1353 | Line 1354 | public class LinkedBlockingDequeTest ext
1354              }});
1355  
1356          await(pleaseInterrupt);
1357 <        assertThreadStaysAlive(t);
1357 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1358          t.interrupt();
1359          awaitTermination(t);
1360          checkEmpty(q);
# Line 1399 | Line 1400 | public class LinkedBlockingDequeTest ext
1400          assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1401  
1402          barrier.await();
1403 <        assertThreadStaysAlive(t);
1403 >        assertThreadBlocks(t, Thread.State.TIMED_WAITING);
1404          t.interrupt();
1405          awaitTermination(t);
1406      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines