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

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.68 by jsr166, Sun Oct 31 18:33:47 2010 UTC vs.
Revision 1.72 by jsr166, Sun Nov 28 08:43:53 2010 UTC

# Line 7 | Line 7
7   */
8  
9   import junit.framework.*;
10 + import java.util.Arrays;
11 + import java.util.NoSuchElementException;
12   import java.util.PropertyPermission;
13   import java.util.concurrent.*;
14   import java.util.concurrent.atomic.AtomicReference;
# Line 260 | Line 262 | public class JSR166TestCase extends Test
262          SHORT_DELAY_MS = getShortDelay();
263          SMALL_DELAY_MS  = SHORT_DELAY_MS * 5;
264          MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10;
265 <        LONG_DELAY_MS   = SHORT_DELAY_MS * 50;
265 >        LONG_DELAY_MS   = SHORT_DELAY_MS * 200;
266      }
267  
268      /**
# Line 289 | Line 291 | public class JSR166TestCase extends Test
291       * earlier by threadRecordFailure.
292       */
293      public void tearDown() throws Exception {
294 <        Throwable t = threadFailure.get();
294 >        Throwable t = threadFailure.getAndSet(null);
295          if (t != null) {
296              if (t instanceof Error)
297                  throw (Error) t;
# Line 447 | Line 449 | public class JSR166TestCase extends Test
449          try {
450              exec.shutdown();
451              assertTrue("ExecutorService did not terminate in a timely manner",
452 <                       exec.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
452 >                       exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS));
453          } catch (SecurityException ok) {
454              // Allowed in case test doesn't have privs
455          } catch (InterruptedException ie) {
# Line 1007 | Line 1009 | public class JSR166TestCase extends Test
1009          }
1010      }
1011  
1012 +    public void checkEmpty(BlockingQueue q) {
1013 +        try {
1014 +            assertTrue(q.isEmpty());
1015 +            assertEquals(0, q.size());
1016 +            assertNull(q.peek());
1017 +            assertNull(q.poll());
1018 +            assertNull(q.poll(0, MILLISECONDS));
1019 +            assertEquals(q.toString(), "[]");
1020 +            assertTrue(Arrays.equals(q.toArray(), new Object[0]));
1021 +            assertFalse(q.iterator().hasNext());
1022 +            try {
1023 +                q.element();
1024 +                shouldThrow();
1025 +            } catch (NoSuchElementException success) {}
1026 +            try {
1027 +                q.iterator().next();
1028 +                shouldThrow();
1029 +            } catch (NoSuchElementException success) {}
1030 +            try {
1031 +                q.remove();
1032 +                shouldThrow();
1033 +            } catch (NoSuchElementException success) {}
1034 +        } catch (InterruptedException ie) {
1035 +            threadUnexpectedException(ie);
1036 +        }
1037 +    }
1038 +
1039   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines