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.64 by jsr166, Sat Aug 6 17:02:49 2016 UTC vs.
Revision 1.71 by jsr166, Sat May 13 21:52:59 2017 UTC

# Line 41 | Line 41 | public class LinkedBlockingDequeTest ext
41      }
42  
43      public static Test suite() {
44 +        class Implementation implements CollectionImplementation {
45 +            public Class<?> klazz() { return LinkedBlockingDeque.class; }
46 +            public Collection emptyCollection() { return new LinkedBlockingDeque(); }
47 +            public Object makeElement(int i) { return i; }
48 +            public boolean isConcurrent() { return true; }
49 +            public boolean permitsNulls() { return false; }
50 +        }
51          return newTestSuite(LinkedBlockingDequeTest.class,
52                              new Unbounded().testSuite(),
53 <                            new Bounded().testSuite());
53 >                            new Bounded().testSuite(),
54 >                            CollectionTest.testSuite(new Implementation()));
55      }
56  
57      /**
58       * Returns a new deque of given size containing consecutive
59 <     * Integers 0 ... n.
59 >     * Integers 0 ... n - 1.
60       */
61 <    private LinkedBlockingDeque<Integer> populatedDeque(int n) {
61 >    private static LinkedBlockingDeque<Integer> populatedDeque(int n) {
62          LinkedBlockingDeque<Integer> q =
63              new LinkedBlockingDeque<Integer>(n);
64          assertTrue(q.isEmpty());
# Line 59 | Line 67 | public class LinkedBlockingDequeTest ext
67          assertFalse(q.isEmpty());
68          assertEquals(0, q.remainingCapacity());
69          assertEquals(n, q.size());
70 +        assertEquals((Integer) 0, q.peekFirst());
71 +        assertEquals((Integer) (n - 1), q.peekLast());
72          return q;
73      }
74  
# Line 629 | 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 679 | Line 689 | public class LinkedBlockingDequeTest ext
689          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
690          Thread t = newStartedThread(new CheckedRunnable() {
691              public void realRun() throws InterruptedException {
692 <                for (int i = 0; i < SIZE; ++i) {
683 <                    assertEquals(i, q.take());
684 <                }
692 >                for (int i = 0; i < SIZE; i++) assertEquals(i, q.take());
693  
694                  Thread.currentThread().interrupt();
695                  try {
# Line 699 | Line 707 | public class LinkedBlockingDequeTest ext
707              }});
708  
709          await(pleaseInterrupt);
710 <        assertThreadStaysAlive(t);
710 >        assertThreadBlocks(t, Thread.State.WAITING);
711          t.interrupt();
712          awaitTermination(t);
713      }
# Line 764 | Line 772 | public class LinkedBlockingDequeTest ext
772                  }
773              }});
774  
775 <        aboutToWait.await();
775 >        await(aboutToWait);
776          waitForThreadToEnterWaitState(t);
777          t.interrupt();
778          awaitTermination(t);
# Line 918 | Line 926 | public class LinkedBlockingDequeTest ext
926              }});
927  
928          await(threadStarted);
929 <        assertThreadStaysAlive(t);
929 >        assertThreadBlocks(t, Thread.State.WAITING);
930          t.interrupt();
931          awaitTermination(t);
932      }
# Line 959 | Line 967 | public class LinkedBlockingDequeTest ext
967              }});
968  
969          await(threadStarted);
970 <        assertThreadStaysAlive(t);
970 >        assertThreadBlocks(t, Thread.State.WAITING);
971          t.interrupt();
972          awaitTermination(t);
973      }
# Line 991 | Line 999 | public class LinkedBlockingDequeTest ext
999          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
1000          Thread t = newStartedThread(new CheckedRunnable() {
1001              public void realRun() throws InterruptedException {
1002 <                for (int i = 0; i < SIZE; ++i) {
995 <                    assertEquals(i, q.takeFirst());
996 <                }
1002 >                for (int i = 0; i < SIZE; i++) assertEquals(i, q.takeFirst());
1003  
1004                  Thread.currentThread().interrupt();
1005                  try {
# Line 1011 | Line 1017 | public class LinkedBlockingDequeTest ext
1017              }});
1018  
1019          await(pleaseInterrupt);
1020 <        assertThreadStaysAlive(t);
1020 >        assertThreadBlocks(t, Thread.State.WAITING);
1021          t.interrupt();
1022          awaitTermination(t);
1023      }
# Line 1258 | Line 1264 | public class LinkedBlockingDequeTest ext
1264          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
1265          Thread t = newStartedThread(new CheckedRunnable() {
1266              public void realRun() throws InterruptedException {
1267 <                for (int i = 0; i < SIZE; ++i) {
1267 >                for (int i = 0; i < SIZE; i++)
1268                      assertEquals(SIZE - i - 1, q.takeLast());
1263                }
1269  
1270                  Thread.currentThread().interrupt();
1271                  try {
# Line 1278 | Line 1283 | public class LinkedBlockingDequeTest ext
1283              }});
1284  
1285          await(pleaseInterrupt);
1286 <        assertThreadStaysAlive(t);
1286 >        assertThreadBlocks(t, Thread.State.WAITING);
1287          t.interrupt();
1288          awaitTermination(t);
1289      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines