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.199 by jsr166, Sat Aug 6 16:24:05 2016 UTC vs.
Revision 1.214 by jsr166, Fri Dec 9 07:26:04 2016 UTC

# Line 8 | Line 8
8  
9   /*
10   * @test
11 < * @summary JSR-166 tck tests
11 > * @summary JSR-166 tck tests (conformance testing mode)
12 > * @build *
13   * @modules java.management
14 + * @run junit/othervm/timeout=1000 JSR166TestCase
15 + */
16 +
17 + /*
18 + * @test
19 + * @summary JSR-166 tck tests (whitebox tests allowed)
20   * @build *
21 < * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase
22 < * @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase
23 < * @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -Djava.util.secureRandomSeed=true JSR166TestCase
21 > * @modules java.base/java.util.concurrent:open
22 > *          java.management
23 > * @run junit/othervm/timeout=1000
24 > *      -Djsr166.testImplementationDetails=true
25 > *      JSR166TestCase
26 > * @run junit/othervm/timeout=1000
27 > *      -Djsr166.testImplementationDetails=true
28 > *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=0
29 > *      JSR166TestCase
30 > * @run junit/othervm/timeout=1000
31 > *      -Djsr166.testImplementationDetails=true
32 > *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=1
33 > *      -Djava.util.secureRandomSeed=true
34 > *      JSR166TestCase
35   */
36  
37   import static java.util.concurrent.TimeUnit.MILLISECONDS;
# Line 41 | Line 59 | import java.security.ProtectionDomain;
59   import java.security.SecurityPermission;
60   import java.util.ArrayList;
61   import java.util.Arrays;
62 + import java.util.Collection;
63 + import java.util.Collections;
64   import java.util.Date;
65   import java.util.Enumeration;
66   import java.util.Iterator;
# Line 62 | Line 82 | import java.util.concurrent.RejectedExec
82   import java.util.concurrent.Semaphore;
83   import java.util.concurrent.SynchronousQueue;
84   import java.util.concurrent.ThreadFactory;
85 + import java.util.concurrent.ThreadLocalRandom;
86   import java.util.concurrent.ThreadPoolExecutor;
87   import java.util.concurrent.TimeoutException;
88   import java.util.concurrent.atomic.AtomicBoolean;
# Line 445 | Line 466 | public class JSR166TestCase extends Test
466              AbstractQueuedLongSynchronizerTest.suite(),
467              ArrayBlockingQueueTest.suite(),
468              ArrayDequeTest.suite(),
469 +            ArrayListTest.suite(),
470              AtomicBooleanTest.suite(),
471              AtomicIntegerArrayTest.suite(),
472              AtomicIntegerFieldUpdaterTest.suite(),
# Line 467 | Line 489 | public class JSR166TestCase extends Test
489              CopyOnWriteArrayListTest.suite(),
490              CopyOnWriteArraySetTest.suite(),
491              CountDownLatchTest.suite(),
492 +            CountedCompleterTest.suite(),
493              CyclicBarrierTest.suite(),
494              DelayQueueTest.suite(),
495              EntryTest.suite(),
# Line 495 | Line 518 | public class JSR166TestCase extends Test
518              TreeMapTest.suite(),
519              TreeSetTest.suite(),
520              TreeSubMapTest.suite(),
521 <            TreeSubSetTest.suite());
521 >            TreeSubSetTest.suite(),
522 >            VectorTest.suite());
523  
524          // Java8+ test classes
525          if (atLeastJava8()) {
526              String[] java8TestClassNames = {
527 +                "ArrayDeque8Test",
528                  "Atomic8Test",
529                  "CompletableFutureTest",
530                  "ConcurrentHashMap8Test",
531 <                "CountedCompleterTest",
531 >                "CountedCompleter8Test",
532                  "DoubleAccumulatorTest",
533                  "DoubleAdderTest",
534                  "ForkJoinPool8Test",
# Line 1003 | Line 1028 | public class JSR166TestCase extends Test
1028          ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
1029          System.err.println("------ stacktrace dump start ------");
1030          for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
1031 <            String name = info.getThreadName();
1031 >            final String name = info.getThreadName();
1032 >            String lockName;
1033              if ("Signal Dispatcher".equals(name))
1034                  continue;
1035              if ("Reference Handler".equals(name)
1036 <                && info.getLockName().startsWith("java.lang.ref.Reference$Lock"))
1036 >                && (lockName = info.getLockName()) != null
1037 >                && lockName.startsWith("java.lang.ref.Reference$Lock"))
1038                  continue;
1039              if ("Finalizer".equals(name)
1040 <                && info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock"))
1040 >                && (lockName = info.getLockName()) != null
1041 >                && lockName.startsWith("java.lang.ref.ReferenceQueue$Lock"))
1042                  continue;
1043              if ("checkForWedgedTest".equals(name))
1044                  continue;
# Line 1235 | Line 1263 | public class JSR166TestCase extends Test
1263       * Sleeps until the given time has elapsed.
1264       * Throws AssertionFailedError if interrupted.
1265       */
1266 <    void sleep(long millis) {
1266 >    static void sleep(long millis) {
1267          try {
1268              delay(millis);
1269          } catch (InterruptedException fail) {
# Line 1754 | Line 1782 | public class JSR166TestCase extends Test
1782       * A CyclicBarrier that uses timed await and fails with
1783       * AssertionFailedErrors instead of throwing checked exceptions.
1784       */
1785 <    public class CheckedBarrier extends CyclicBarrier {
1785 >    public static class CheckedBarrier extends CyclicBarrier {
1786          public CheckedBarrier(int parties) { super(parties); }
1787  
1788          public int await() {
# Line 1818 | Line 1846 | public class JSR166TestCase extends Test
1846          }
1847      }
1848  
1849 +    void assertImmutable(final Object o) {
1850 +        if (o instanceof Collection) {
1851 +            assertThrows(
1852 +                UnsupportedOperationException.class,
1853 +                new Runnable() { public void run() {
1854 +                        ((Collection) o).add(null);}});
1855 +        }
1856 +    }
1857 +
1858      @SuppressWarnings("unchecked")
1859      <T> T serialClone(T o) {
1860          try {
1861              ObjectInputStream ois = new ObjectInputStream
1862                  (new ByteArrayInputStream(serialBytes(o)));
1863              T clone = (T) ois.readObject();
1864 +            if (o == clone) assertImmutable(o);
1865              assertSame(o.getClass(), clone.getClass());
1866              return clone;
1867          } catch (Throwable fail) {
# Line 1832 | Line 1870 | public class JSR166TestCase extends Test
1870          }
1871      }
1872  
1873 +    /**
1874 +     * A version of serialClone that leaves error handling (for
1875 +     * e.g. NotSerializableException) up to the caller.
1876 +     */
1877 +    @SuppressWarnings("unchecked")
1878 +    <T> T serialClonePossiblyFailing(T o)
1879 +        throws ReflectiveOperationException, java.io.IOException {
1880 +        ByteArrayOutputStream bos = new ByteArrayOutputStream();
1881 +        ObjectOutputStream oos = new ObjectOutputStream(bos);
1882 +        oos.writeObject(o);
1883 +        oos.flush();
1884 +        oos.close();
1885 +        ObjectInputStream ois = new ObjectInputStream
1886 +            (new ByteArrayInputStream(bos.toByteArray()));
1887 +        T clone = (T) ois.readObject();
1888 +        if (o == clone) assertImmutable(o);
1889 +        assertSame(o.getClass(), clone.getClass());
1890 +        return clone;
1891 +    }
1892 +
1893 +    /**
1894 +     * If o implements Cloneable and has a public clone method,
1895 +     * returns a clone of o, else null.
1896 +     */
1897 +    @SuppressWarnings("unchecked")
1898 +    <T> T cloneableClone(T o) {
1899 +        if (!(o instanceof Cloneable)) return null;
1900 +        final T clone;
1901 +        try {
1902 +            clone = (T) o.getClass().getMethod("clone").invoke(o);
1903 +        } catch (NoSuchMethodException ok) {
1904 +            return null;
1905 +        } catch (ReflectiveOperationException unexpected) {
1906 +            throw new Error(unexpected);
1907 +        }
1908 +        assertNotSame(o, clone); // not 100% guaranteed by spec
1909 +        assertSame(o.getClass(), clone.getClass());
1910 +        return clone;
1911 +    }
1912 +
1913      public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
1914                               Runnable... throwingActions) {
1915          for (Runnable throwingAction : throwingActions) {
# Line 1875 | Line 1953 | public class JSR166TestCase extends Test
1953                                 1000L, MILLISECONDS,
1954                                 new SynchronousQueue<Runnable>());
1955  
1956 +    static <T> void shuffle(T[] array) {
1957 +        Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current());
1958 +    }
1959   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines