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.70 by jsr166, Sun Nov 21 19:04:45 2010 UTC vs.
Revision 1.74 by jsr166, Tue Mar 15 19:47:06 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
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 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 787 | Line 789 | public class JSR166TestCase extends Test
789              }};
790      }
791  
792 +    public Runnable awaiter(final CountDownLatch latch) {
793 +        return new CheckedRunnable() {
794 +            public void realRun() throws InterruptedException {
795 +                latch.await();
796 +            }};
797 +    }
798 +
799      public static class NPETask implements Callable<String> {
800          public String call() { throw new NullPointerException(); }
801      }
# Line 1007 | Line 1016 | public class JSR166TestCase extends Test
1016          }
1017      }
1018  
1019 +    public void checkEmpty(BlockingQueue q) {
1020 +        try {
1021 +            assertTrue(q.isEmpty());
1022 +            assertEquals(0, q.size());
1023 +            assertNull(q.peek());
1024 +            assertNull(q.poll());
1025 +            assertNull(q.poll(0, MILLISECONDS));
1026 +            assertEquals(q.toString(), "[]");
1027 +            assertTrue(Arrays.equals(q.toArray(), new Object[0]));
1028 +            assertFalse(q.iterator().hasNext());
1029 +            try {
1030 +                q.element();
1031 +                shouldThrow();
1032 +            } catch (NoSuchElementException success) {}
1033 +            try {
1034 +                q.iterator().next();
1035 +                shouldThrow();
1036 +            } catch (NoSuchElementException success) {}
1037 +            try {
1038 +                q.remove();
1039 +                shouldThrow();
1040 +            } catch (NoSuchElementException success) {}
1041 +        } catch (InterruptedException ie) {
1042 +            threadUnexpectedException(ie);
1043 +        }
1044 +    }
1045 +
1046   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines