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.10 by jsr166, Sat Nov 21 09:28:16 2009 UTC vs.
Revision 1.11 by jsr166, Sat Nov 21 10:25:05 2009 UTC

# Line 276 | Line 276 | public class LinkedBlockingDequeTest ext
276      }
277  
278      /**
279 <     * Constructor throws IAE if  capacity argument nonpositive
279 >     * Constructor throws IAE if capacity argument nonpositive
280       */
281      public void testConstructor2() {
282          try {
# Line 792 | Line 792 | public class LinkedBlockingDequeTest ext
792       * putFirst blocks interruptibly if full
793       */
794      public void testBlockingPutFirst() throws InterruptedException {
795 <        Thread t = new Thread(new Runnable() {
796 <                public void run() {
797 <                    int added = 0;
798 <                    try {
799 <                        LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
800 <                        for (int i = 0; i < SIZE; ++i) {
801 <                            q.putFirst(new Integer(i));
802 <                            ++added;
803 <                        }
804 <                        q.putFirst(new Integer(SIZE));
805 <                        threadShouldThrow();
806 <                    } catch (InterruptedException success) {
807 <                        threadAssertEquals(added, SIZE);
795 >        Thread t = new Thread(new CheckedRunnable() {
796 >            public void realRun() {
797 >                int added = 0;
798 >                try {
799 >                    LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
800 >                    for (int i = 0; i < SIZE; ++i) {
801 >                        q.putFirst(new Integer(i));
802 >                        ++added;
803                      }
804 <                }});
804 >                    q.putFirst(new Integer(SIZE));
805 >                    threadShouldThrow();
806 >                } catch (InterruptedException success) {
807 >                    threadAssertEquals(added, SIZE);
808 >                }
809 >            }});
810  
811          t.start();
812          Thread.sleep(SHORT_DELAY_MS);
# Line 819 | Line 819 | public class LinkedBlockingDequeTest ext
819       */
820      public void testPutFirstWithTake() throws InterruptedException {
821          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
822 <        Thread t = new Thread(new Runnable() {
823 <                public void run() {
824 <                    int added = 0;
825 <                    try {
826 <                        q.putFirst(new Object());
827 <                        ++added;
828 <                        q.putFirst(new Object());
829 <                        ++added;
830 <                        q.putFirst(new Object());
831 <                        ++added;
832 <                        q.putFirst(new Object());
833 <                        ++added;
834 <                        threadShouldThrow();
835 <                    } catch (InterruptedException success) {
836 <                        threadAssertTrue(added >= 2);
837 <                    }
822 >        Thread t = new Thread(new CheckedRunnable() {
823 >            public void realRun() {
824 >                int added = 0;
825 >                try {
826 >                    q.putFirst(new Object());
827 >                    ++added;
828 >                    q.putFirst(new Object());
829 >                    ++added;
830 >                    q.putFirst(new Object());
831 >                    ++added;
832 >                    q.putFirst(new Object());
833 >                    ++added;
834 >                    threadShouldThrow();
835 >                } catch (InterruptedException success) {
836 >                    threadAssertTrue(added >= 2);
837                  }
838 <            });
838 >            }});
839  
840          t.start();
841          Thread.sleep(SHORT_DELAY_MS);
# Line 1000 | Line 999 | public class LinkedBlockingDequeTest ext
999       * putLast blocks interruptibly if full
1000       */
1001      public void testBlockingPutLast() throws InterruptedException {
1002 <        Thread t = new Thread(new Runnable() {
1003 <                public void run() {
1004 <                    int added = 0;
1005 <                    try {
1006 <                        LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
1007 <                        for (int i = 0; i < SIZE; ++i) {
1008 <                            q.putLast(new Integer(i));
1009 <                            ++added;
1011 <                        }
1012 <                        q.putLast(new Integer(SIZE));
1013 <                        threadShouldThrow();
1014 <                    } catch (InterruptedException success) {
1015 <                        threadAssertEquals(added, SIZE);
1002 >        Thread t = new Thread(new CheckedRunnable() {
1003 >            public void realRun() {
1004 >                int added = 0;
1005 >                try {
1006 >                    LinkedBlockingDeque q = new LinkedBlockingDeque(SIZE);
1007 >                    for (int i = 0; i < SIZE; ++i) {
1008 >                        q.putLast(new Integer(i));
1009 >                        ++added;
1010                      }
1011 <                }});
1011 >                    q.putLast(new Integer(SIZE));
1012 >                    threadShouldThrow();
1013 >                } catch (InterruptedException success) {
1014 >                    threadAssertEquals(added, SIZE);
1015 >                }
1016 >            }});
1017 >
1018          t.start();
1019          Thread.sleep(SHORT_DELAY_MS);
1020          t.interrupt();
# Line 1026 | Line 1026 | public class LinkedBlockingDequeTest ext
1026       */
1027      public void testPutLastWithTake() throws InterruptedException {
1028          final LinkedBlockingDeque q = new LinkedBlockingDeque(2);
1029 <        Thread t = new Thread(new Runnable() {
1030 <                public void run() {
1031 <                    int added = 0;
1032 <                    try {
1033 <                        q.putLast(new Object());
1034 <                        ++added;
1035 <                        q.putLast(new Object());
1036 <                        ++added;
1037 <                        q.putLast(new Object());
1038 <                        ++added;
1039 <                        q.putLast(new Object());
1040 <                        ++added;
1041 <                        threadShouldThrow();
1042 <                    } catch (InterruptedException success) {
1043 <                        threadAssertTrue(added >= 2);
1044 <                    }
1029 >        Thread t = new Thread(new CheckedRunnable() {
1030 >            public void realRun() {
1031 >                int added = 0;
1032 >                try {
1033 >                    q.putLast(new Object());
1034 >                    ++added;
1035 >                    q.putLast(new Object());
1036 >                    ++added;
1037 >                    q.putLast(new Object());
1038 >                    ++added;
1039 >                    q.putLast(new Object());
1040 >                    ++added;
1041 >                    threadShouldThrow();
1042 >                } catch (InterruptedException success) {
1043 >                    threadAssertTrue(added >= 2);
1044                  }
1045 <            });
1045 >            }});
1046  
1047          t.start();
1048          Thread.sleep(SHORT_DELAY_MS);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines