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.9 by jsr166, Sat Nov 21 08:37:39 2009 UTC vs.
Revision 1.17 by jsr166, Sun Nov 22 00:17:37 2009 UTC

# Line 169 | Line 169 | public class LinkedBlockingDequeTest ext
169              q.getFirst();
170              shouldThrow();
171          } catch (NoSuchElementException success) {}
172 +        assertNull(q.peekFirst());
173      }
174  
175      /**
# Line 199 | Line 200 | public class LinkedBlockingDequeTest ext
200              q.removeFirst();
201              shouldThrow();
202          } catch (NoSuchElementException success) {}
203 +        assertNull(q.peekFirst());
204 +    }
205 +
206 +    /**
207 +     *  removeLast removes last element, or throws NSEE if empty
208 +     */
209 +    public void testRemoveLast() {
210 +        LinkedBlockingDeque q = populatedDeque(SIZE);
211 +        for (int i = SIZE - 1; i >= 0; --i) {
212 +            assertEquals(i, ((Integer)q.removeLast()).intValue());
213 +        }
214 +        try {
215 +            q.removeLast();
216 +            shouldThrow();
217 +        } catch (NoSuchElementException success) {}
218 +        assertNull(q.peekLast());
219      }
220  
221      /**
# Line 276 | Line 293 | public class LinkedBlockingDequeTest ext
293      }
294  
295      /**
296 <     * Constructor throws IAE if  capacity argument nonpositive
296 >     * Constructor throws IAE if capacity argument nonpositive
297       */
298      public void testConstructor2() {
299          try {
# Line 323 | Line 340 | public class LinkedBlockingDequeTest ext
340       * Deque contains all elements of collection used to initialize
341       */
342      public void testConstructor6() {
343 <        try {
344 <            Integer[] ints = new Integer[SIZE];
345 <            for (int i = 0; i < SIZE; ++i)
346 <                ints[i] = new Integer(i);
347 <            LinkedBlockingDeque q = new LinkedBlockingDeque(Arrays.asList(ints));
348 <            for (int i = 0; i < SIZE; ++i)
332 <                assertEquals(ints[i], q.poll());
333 <        }
334 <        finally {}
343 >        Integer[] ints = new Integer[SIZE];
344 >        for (int i = 0; i < SIZE; ++i)
345 >            ints[i] = new Integer(i);
346 >        LinkedBlockingDeque q = new LinkedBlockingDeque(Arrays.asList(ints));
347 >        for (int i = 0; i < SIZE; ++i)
348 >            assertEquals(ints[i], q.poll());
349      }
350  
351      /**
# Line 526 | Line 540 | public class LinkedBlockingDequeTest ext
540              shouldThrow();
541          } catch (IllegalStateException success) {}
542      }
543 +
544      /**
545       * Deque contains all elements, in traversal order, of successful addAll
546       */
547      public void testAddAll5() {
548 <        try {
549 <            Integer[] empty = new Integer[0];
550 <            Integer[] ints = new Integer[SIZE];
551 <            for (int i = 0; i < SIZE; ++i)
552 <                ints[i] = new Integer(i);
553 <            LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
554 <            assertFalse(q.addAll(Arrays.asList(empty)));
555 <            assertTrue(q.addAll(Arrays.asList(ints)));
556 <            for (int i = 0; i < SIZE; ++i)
542 <                assertEquals(ints[i], q.poll());
543 <        }
544 <        finally {}
548 >        Integer[] empty = new Integer[0];
549 >        Integer[] ints = new Integer[SIZE];
550 >        for (int i = 0; i < SIZE; ++i)
551 >            ints[i] = new Integer(i);
552 >        LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
553 >        assertFalse(q.addAll(Arrays.asList(empty)));
554 >        assertTrue(q.addAll(Arrays.asList(ints)));
555 >        for (int i = 0; i < SIZE; ++i)
556 >            assertEquals(ints[i], q.poll());
557      }
558  
559  
560      /**
561       * put(null) throws NPE
562       */
563 <     public void testPutNull() throws InterruptedException {
563 >    public void testPutNull() throws InterruptedException {
564          try {
565              LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
566              q.put(null);
567              shouldThrow();
568          } catch (NullPointerException success) {}
569 <     }
569 >    }
570  
571      /**
572       * all elements successfully put are contained
573       */
574 <     public void testPut() throws InterruptedException {
575 <         LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
576 <         for (int i = 0; i < SIZE; ++i) {
577 <             Integer I = new Integer(i);
578 <             q.put(I);
579 <             assertTrue(q.contains(I));
580 <         }
581 <         assertEquals(0, q.remainingCapacity());
574 >    public void testPut() throws InterruptedException {
575 >        LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
576 >        for (int i = 0; i < SIZE; ++i) {
577 >            Integer I = new Integer(i);
578 >            q.put(I);
579 >            assertTrue(q.contains(I));
580 >        }
581 >        assertEquals(0, q.remainingCapacity());
582      }
583  
584      /**
585       * put blocks interruptibly if full
586       */
587      public void testBlockingPut() throws InterruptedException {
588 +        final LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
589          Thread t = new Thread(new CheckedRunnable() {
590 <            public void realRun() {
591 <                int added = 0;
590 >            public void realRun() throws InterruptedException {
591 >                for (int i = 0; i < SIZE; ++i)
592 >                    q.put(i);
593 >                assertEquals(SIZE, q.size());
594 >                assertEquals(0, q.remainingCapacity());
595                  try {
596 <                    LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
597 <                    for (int i = 0; i < SIZE; ++i) {
598 <                        q.put(new Integer(i));
583 <                        ++added;
584 <                    }
585 <                    q.put(new Integer(SIZE));
586 <                    threadShouldThrow();
587 <                } catch (InterruptedException success) {
588 <                    threadAssertEquals(added, SIZE);
589 <                }
596 >                    q.put(99);
597 >                    shouldThrow();
598 >                } catch (InterruptedException success) {}
599              }});
600  
601          t.start();
602          Thread.sleep(SHORT_DELAY_MS);
603          t.interrupt();
604          t.join();
605 +        assertEquals(SIZE, q.size());
606 +        assertEquals(0, q.remainingCapacity());
607      }
608  
609      /**
610       * put blocks waiting for take when full
611       */
612      public void testPutWithTake() throws InterruptedException {
613 <        final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
614 <        Thread t = new Thread(new Runnable() {
615 <                public void run() {
616 <                    int added = 0;
617 <                    try {
618 <                        q.put(new Object());
619 <                        ++added;
620 <                        q.put(new Object());
621 <                        ++added;
622 <                        q.put(new Object());
623 <                        ++added;
613 <                        q.put(new Object());
614 <                        ++added;
615 <                        threadShouldThrow();
616 <                    } catch (InterruptedException success) {
617 <                        threadAssertTrue(added >= 2);
618 <                    }
619 <                }
620 <            });
613 >        final int capacity = 2;
614 >        final LinkedBlockingDeque q = new LinkedBlockingDeque(capacity);
615 >        Thread t = new Thread(new CheckedRunnable() {
616 >            public void realRun() throws InterruptedException {
617 >                for (int i = 0; i < capacity + 1; i++)
618 >                    q.put(i);
619 >                try {
620 >                    q.put(99);
621 >                    shouldThrow();
622 >                } catch (InterruptedException success) {}
623 >            }});
624  
625          t.start();
626          Thread.sleep(SHORT_DELAY_MS);
627 <        q.take();
627 >        assertEquals(q.remainingCapacity(), 0);
628 >        assertEquals(0, q.take());
629 >        Thread.sleep(SHORT_DELAY_MS);
630          t.interrupt();
631          t.join();
632 +        assertEquals(q.remainingCapacity(), 0);
633      }
634  
635      /**
# Line 631 | Line 637 | public class LinkedBlockingDequeTest ext
637       */
638      public void testTimedOffer() throws InterruptedException {
639          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
640 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
640 >        Thread t = new Thread(new CheckedRunnable() {
641              public void realRun() throws InterruptedException {
642                  q.put(new Object());
643                  q.put(new Object());
644 <                threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS));
645 <                q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS);
646 <            }};
644 >                assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS));
645 >                try {
646 >                    q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS);
647 >                    shouldThrow();
648 >                } catch (InterruptedException success) {}
649 >            }});
650  
651          t.start();
652          Thread.sleep(SMALL_DELAY_MS);
# Line 675 | Line 684 | public class LinkedBlockingDequeTest ext
684       * Take removes existing elements until empty, then blocks interruptibly
685       */
686      public void testBlockingTake() throws InterruptedException {
687 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
687 >        final LinkedBlockingDeque q = populatedDeque(SIZE);
688 >        Thread t = new Thread(new CheckedRunnable() {
689              public void realRun() throws InterruptedException {
680                LinkedBlockingDeque q = populatedDeque(SIZE);
690                  for (int i = 0; i < SIZE; ++i) {
691                      assertEquals(i, ((Integer)q.take()).intValue());
692                  }
693 <                q.take();
694 <            }};
693 >                try {
694 >                    q.take();
695 >                    shouldThrow();
696 >                } catch (InterruptedException success) {}
697 >            }});
698  
699          t.start();
700          Thread.sleep(SHORT_DELAY_MS);
# Line 729 | Line 741 | public class LinkedBlockingDequeTest ext
741       * returning timeout status
742       */
743      public void testInterruptedTimedPoll() throws InterruptedException {
744 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
744 >        Thread t = new Thread(new CheckedRunnable() {
745              public void realRun() throws InterruptedException {
746                  LinkedBlockingDeque q = populatedDeque(SIZE);
747                  for (int i = 0; i < SIZE; ++i) {
748 <                    threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
748 >                    assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, MILLISECONDS)).intValue());
749                  }
750 <                q.poll(SMALL_DELAY_MS, MILLISECONDS);
751 <            }};
750 >                try {
751 >                    q.poll(SMALL_DELAY_MS, MILLISECONDS);
752 >                    shouldThrow();
753 >                } catch (InterruptedException success) {}
754 >            }});
755  
756          t.start();
757          Thread.sleep(SHORT_DELAY_MS);
# Line 750 | Line 765 | public class LinkedBlockingDequeTest ext
765       */
766      public void testTimedPollWithOffer() throws InterruptedException {
767          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
768 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
768 >        Thread t = new Thread(new CheckedRunnable() {
769              public void realRun() throws InterruptedException {
770 <                threadAssertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
771 <                q.poll(LONG_DELAY_MS, MILLISECONDS);
772 <                q.poll(LONG_DELAY_MS, MILLISECONDS);
773 <            }};
770 >                assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
771 >                assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));
772 >                try {
773 >                    q.poll(LONG_DELAY_MS, MILLISECONDS);
774 >                    shouldThrow();
775 >                } catch (InterruptedException success) {}
776 >            }});
777  
778          t.start();
779          Thread.sleep(SMALL_DELAY_MS);
# Line 793 | Line 811 | public class LinkedBlockingDequeTest ext
811       * putFirst blocks interruptibly if full
812       */
813      public void testBlockingPutFirst() throws InterruptedException {
814 <        Thread t = new Thread(new Runnable() {
815 <                public void run() {
816 <                    int added = 0;
817 <                    try {
818 <                        LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
819 <                        for (int i = 0; i < SIZE; ++i) {
820 <                            q.putFirst(new Integer(i));
821 <                            ++added;
822 <                        }
823 <                        q.putFirst(new Integer(SIZE));
824 <                        threadShouldThrow();
825 <                    } catch (InterruptedException success) {
808 <                        threadAssertEquals(added, SIZE);
809 <                    }
810 <                }});
814 >        final LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
815 >        Thread t = new Thread(new CheckedRunnable() {
816 >            public void realRun() throws InterruptedException {
817 >                for (int i = 0; i < SIZE; ++i)
818 >                    q.putFirst(i);
819 >                assertEquals(SIZE, q.size());
820 >                assertEquals(0, q.remainingCapacity());
821 >                try {
822 >                    q.putFirst(99);
823 >                    shouldThrow();
824 >                } catch (InterruptedException success) {}
825 >            }});
826  
827          t.start();
828          Thread.sleep(SHORT_DELAY_MS);
829          t.interrupt();
830          t.join();
831 +        assertEquals(SIZE, q.size());
832 +        assertEquals(0, q.remainingCapacity());
833      }
834  
835      /**
836       * putFirst blocks waiting for take when full
837       */
838      public void testPutFirstWithTake() throws InterruptedException {
839 <        final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
840 <        Thread t = new Thread(new Runnable() {
841 <                public void run() {
842 <                    int added = 0;
843 <                    try {
844 <                        q.putFirst(new Object());
845 <                        ++added;
846 <                        q.putFirst(new Object());
847 <                        ++added;
848 <                        q.putFirst(new Object());
849 <                        ++added;
833 <                        q.putFirst(new Object());
834 <                        ++added;
835 <                        threadShouldThrow();
836 <                    } catch (InterruptedException success) {
837 <                        threadAssertTrue(added >= 2);
838 <                    }
839 <                }
840 <            });
839 >        final int capacity = 2;
840 >        final LinkedBlockingDeque q = new LinkedBlockingDeque(capacity);
841 >        Thread t = new Thread(new CheckedRunnable() {
842 >            public void realRun() throws InterruptedException {
843 >                for (int i = 0; i < capacity + 1; i++)
844 >                    q.putFirst(i);
845 >                try {
846 >                    q.putFirst(99);
847 >                    shouldThrow();
848 >                } catch (InterruptedException success) {}
849 >            }});
850  
851          t.start();
852          Thread.sleep(SHORT_DELAY_MS);
853 <        q.take();
853 >        assertEquals(q.remainingCapacity(), 0);
854 >        assertEquals(capacity - 1, q.take());
855 >        Thread.sleep(SHORT_DELAY_MS);
856          t.interrupt();
857          t.join();
858 +        assertEquals(q.remainingCapacity(), 0);
859      }
860  
861      /**
# Line 851 | Line 863 | public class LinkedBlockingDequeTest ext
863       */
864      public void testTimedOfferFirst() throws InterruptedException {
865          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
866 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
866 >        Thread t = new Thread(new CheckedRunnable() {
867              public void realRun() throws InterruptedException {
868                  q.putFirst(new Object());
869                  q.putFirst(new Object());
870 <                threadAssertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, MILLISECONDS));
871 <                q.offerFirst(new Object(), LONG_DELAY_MS, MILLISECONDS);
872 <            }};
870 >                assertFalse(q.offerFirst(new Object(), SHORT_DELAY_MS, MILLISECONDS));
871 >                try {
872 >                    q.offerFirst(new Object(), LONG_DELAY_MS, MILLISECONDS);
873 >                    shouldThrow();
874 >                } catch (InterruptedException success) {}
875 >            }});
876  
877          t.start();
878          Thread.sleep(SMALL_DELAY_MS);
# Line 895 | Line 910 | public class LinkedBlockingDequeTest ext
910       * TakeFirst removes existing elements until empty, then blocks interruptibly
911       */
912      public void testBlockingTakeFirst() throws InterruptedException {
913 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
913 >        final LinkedBlockingDeque q = populatedDeque(SIZE);
914 >        Thread t = new Thread(new CheckedRunnable() {
915              public void realRun() throws InterruptedException {
916 <                LinkedBlockingDeque q = populatedDeque(SIZE);
917 <                for (int i = 0; i < SIZE; ++i) {
918 <                    assertEquals(i, ((Integer)q.takeFirst()).intValue());
919 <                }
920 <                q.takeFirst();
921 <            }};
916 >                for (int i = 0; i < SIZE; ++i)
917 >                    assertEquals(i, q.takeFirst());
918 >                try {
919 >                    q.takeFirst();
920 >                    shouldThrow();
921 >                } catch (InterruptedException success) {}
922 >            }});
923  
924          t.start();
925          Thread.sleep(SHORT_DELAY_MS);
# Line 938 | Line 955 | public class LinkedBlockingDequeTest ext
955       * returning timeout status
956       */
957      public void testInterruptedTimedPollFirst() throws InterruptedException {
958 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
958 >        Thread t = new Thread(new CheckedRunnable() {
959              public void realRun() throws InterruptedException {
960                  LinkedBlockingDeque q = populatedDeque(SIZE);
961                  for (int i = 0; i < SIZE; ++i) {
962 <                    threadAssertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue());
962 >                    assertEquals(i, ((Integer)q.pollFirst(SHORT_DELAY_MS, MILLISECONDS)).intValue());
963                  }
964 <                q.pollFirst(SMALL_DELAY_MS, MILLISECONDS);
965 <            }};
964 >                try {
965 >                    q.pollFirst(SMALL_DELAY_MS, MILLISECONDS);
966 >                    shouldThrow();
967 >                } catch (InterruptedException success) {}
968 >            }});
969  
970          t.start();
971          Thread.sleep(SHORT_DELAY_MS);
# Line 959 | Line 979 | public class LinkedBlockingDequeTest ext
979       */
980      public void testTimedPollFirstWithOfferFirst() throws InterruptedException {
981          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
982 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
982 >        Thread t = new Thread(new CheckedRunnable() {
983              public void realRun() throws InterruptedException {
984 <                threadAssertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS));
985 <                q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
986 <                q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
987 <            }};
984 >                assertNull(q.pollFirst(SHORT_DELAY_MS, MILLISECONDS));
985 >                assertSame(zero, q.pollFirst(LONG_DELAY_MS, MILLISECONDS));
986 >                try {
987 >                    q.pollFirst(LONG_DELAY_MS, MILLISECONDS);
988 >                    shouldThrow();
989 >                } catch (InterruptedException success) {}
990 >            }});
991  
992          t.start();
993          Thread.sleep(SMALL_DELAY_MS);
# Line 1001 | Line 1024 | public class LinkedBlockingDequeTest ext
1024       * putLast blocks interruptibly if full
1025       */
1026      public void testBlockingPutLast() throws InterruptedException {
1027 <        Thread t = new Thread(new Runnable() {
1028 <                public void run() {
1029 <                    int added = 0;
1030 <                    try {
1031 <                        LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
1032 <                        for (int i = 0; i < SIZE; ++i) {
1033 <                            q.putLast(new Integer(i));
1034 <                            ++added;
1035 <                        }
1036 <                        q.putLast(new Integer(SIZE));
1037 <                        threadShouldThrow();
1038 <                    } catch (InterruptedException success) {
1039 <                        threadAssertEquals(added, SIZE);
1017 <                    }
1018 <                }});
1027 >        final LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
1028 >        Thread t = new Thread(new CheckedRunnable() {
1029 >            public void realRun() throws InterruptedException {
1030 >                for (int i = 0; i < SIZE; ++i)
1031 >                    q.putLast(i);
1032 >                assertEquals(SIZE, q.size());
1033 >                assertEquals(0, q.remainingCapacity());
1034 >                try {
1035 >                    q.putLast(99);
1036 >                    shouldThrow();
1037 >                } catch (InterruptedException success) {}
1038 >            }});
1039 >
1040          t.start();
1041          Thread.sleep(SHORT_DELAY_MS);
1042          t.interrupt();
1043          t.join();
1044 +        assertEquals(SIZE, q.size());
1045 +        assertEquals(0, q.remainingCapacity());
1046      }
1047  
1048      /**
1049       * putLast blocks waiting for take when full
1050       */
1051      public void testPutLastWithTake() throws InterruptedException {
1052 <        final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
1053 <        Thread t = new Thread(new Runnable() {
1054 <                public void run() {
1055 <                    int added = 0;
1056 <                    try {
1057 <                        q.putLast(new Object());
1058 <                        ++added;
1059 <                        q.putLast(new Object());
1060 <                        ++added;
1061 <                        q.putLast(new Object());
1062 <                        ++added;
1040 <                        q.putLast(new Object());
1041 <                        ++added;
1042 <                        threadShouldThrow();
1043 <                    } catch (InterruptedException success) {
1044 <                        threadAssertTrue(added >= 2);
1045 <                    }
1046 <                }
1047 <            });
1052 >        final int capacity = 2;
1053 >        final LinkedBlockingDeque q = new LinkedBlockingDeque(capacity);
1054 >        Thread t = new Thread(new CheckedRunnable() {
1055 >            public void realRun() throws InterruptedException {
1056 >                for (int i = 0; i < capacity + 1; i++)
1057 >                    q.putLast(i);
1058 >                try {
1059 >                    q.putLast(99);
1060 >                    shouldThrow();
1061 >                } catch (InterruptedException success) {}
1062 >            }});
1063  
1064          t.start();
1065          Thread.sleep(SHORT_DELAY_MS);
1066 <        q.take();
1066 >        assertEquals(q.remainingCapacity(), 0);
1067 >        assertEquals(0, q.take());
1068 >        Thread.sleep(SHORT_DELAY_MS);
1069          t.interrupt();
1070          t.join();
1071 +        assertEquals(q.remainingCapacity(), 0);
1072      }
1073  
1074      /**
# Line 1058 | Line 1076 | public class LinkedBlockingDequeTest ext
1076       */
1077      public void testTimedOfferLast() throws InterruptedException {
1078          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
1079 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
1079 >        Thread t = new Thread(new CheckedRunnable() {
1080              public void realRun() throws InterruptedException {
1081                  q.putLast(new Object());
1082                  q.putLast(new Object());
1083 <                threadAssertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, MILLISECONDS));
1084 <                q.offerLast(new Object(), LONG_DELAY_MS, MILLISECONDS);
1085 <            }};
1083 >                assertFalse(q.offerLast(new Object(), SHORT_DELAY_MS, MILLISECONDS));
1084 >                try {
1085 >                    q.offerLast(new Object(), LONG_DELAY_MS, MILLISECONDS);
1086 >                    shouldThrow();
1087 >                } catch (InterruptedException success) {}
1088 >            }});
1089  
1090          t.start();
1091          Thread.sleep(SMALL_DELAY_MS);
# Line 1102 | Line 1123 | public class LinkedBlockingDequeTest ext
1123       * TakeLast removes existing elements until empty, then blocks interruptibly
1124       */
1125      public void testBlockingTakeLast() throws InterruptedException {
1126 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
1126 >        final LinkedBlockingDeque q = populatedDeque(SIZE);
1127 >        Thread t = new Thread(new CheckedRunnable() {
1128              public void realRun() throws InterruptedException {
1129 <                LinkedBlockingDeque q = populatedDeque(SIZE);
1130 <                for (int i = 0; i < SIZE; ++i) {
1131 <                    assertEquals(SIZE-i-1, ((Integer)q.takeLast()).intValue());
1132 <                }
1133 <                q.takeLast();
1134 <            }};
1129 >                for (int i = 0; i < SIZE; ++i)
1130 >                    assertEquals(SIZE - 1 - i, q.takeLast());
1131 >                try {
1132 >                    q.takeLast();
1133 >                    shouldThrow();
1134 >                } catch (InterruptedException success) {}
1135 >            }});
1136  
1137          t.start();
1138          Thread.sleep(SHORT_DELAY_MS);
# Line 1117 | Line 1140 | public class LinkedBlockingDequeTest ext
1140          t.join();
1141      }
1142  
1120
1143      /**
1144       * timed pollLast with zero timeout succeeds when non-empty, else times out
1145       */
# Line 1145 | Line 1167 | public class LinkedBlockingDequeTest ext
1167       * returning timeout status
1168       */
1169      public void testInterruptedTimedPollLast() throws InterruptedException {
1170 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
1170 >        Thread t = new Thread(new CheckedRunnable() {
1171              public void realRun() throws InterruptedException {
1172                  LinkedBlockingDeque q = populatedDeque(SIZE);
1173                  for (int i = 0; i < SIZE; ++i) {
1174 <                    threadAssertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue());
1174 >                    assertEquals(SIZE-i-1, ((Integer)q.pollLast(SHORT_DELAY_MS, MILLISECONDS)).intValue());
1175                  }
1176 <                q.pollLast(SMALL_DELAY_MS, MILLISECONDS);
1177 <            }};
1176 >                try {
1177 >                    q.pollLast(SMALL_DELAY_MS, MILLISECONDS);
1178 >                    shouldThrow();
1179 >                } catch (InterruptedException success) {}
1180 >            }});
1181  
1182          t.start();
1183          Thread.sleep(SHORT_DELAY_MS);
# Line 1559 | Line 1584 | public class LinkedBlockingDequeTest ext
1584          try {
1585              q.drainTo(q);
1586              shouldThrow();
1587 <        } catch (IllegalArgumentException success) {
1563 <        }
1587 >        } catch (IllegalArgumentException success) {}
1588      }
1589  
1590      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines