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.202 by jsr166, Thu Sep 15 00:32:45 2016 UTC vs.
Revision 1.215 by jsr166, Sat Dec 10 18:11:05 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;
# Line 447 | 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 469 | 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 497 | 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",
535                  "ForkJoinTask8Test",
536 +                "LinkedBlockingDeque8Test",
537 +                "LinkedBlockingQueue8Test",
538                  "LongAccumulatorTest",
539                  "LongAdderTest",
540                  "SplittableRandomTest",
# Line 1005 | Line 1030 | public class JSR166TestCase extends Test
1030          ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
1031          System.err.println("------ stacktrace dump start ------");
1032          for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
1033 <            String name = info.getThreadName();
1033 >            final String name = info.getThreadName();
1034 >            String lockName;
1035              if ("Signal Dispatcher".equals(name))
1036                  continue;
1037              if ("Reference Handler".equals(name)
1038 <                && info.getLockName().startsWith("java.lang.ref.Reference$Lock"))
1038 >                && (lockName = info.getLockName()) != null
1039 >                && lockName.startsWith("java.lang.ref.Reference$Lock"))
1040                  continue;
1041              if ("Finalizer".equals(name)
1042 <                && info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock"))
1042 >                && (lockName = info.getLockName()) != null
1043 >                && lockName.startsWith("java.lang.ref.ReferenceQueue$Lock"))
1044                  continue;
1045              if ("checkForWedgedTest".equals(name))
1046                  continue;
# Line 1820 | Line 1848 | public class JSR166TestCase extends Test
1848          }
1849      }
1850  
1851 +    void assertImmutable(final Object o) {
1852 +        if (o instanceof Collection) {
1853 +            assertThrows(
1854 +                UnsupportedOperationException.class,
1855 +                new Runnable() { public void run() {
1856 +                        ((Collection) o).add(null);}});
1857 +        }
1858 +    }
1859 +
1860      @SuppressWarnings("unchecked")
1861      <T> T serialClone(T o) {
1862          try {
1863              ObjectInputStream ois = new ObjectInputStream
1864                  (new ByteArrayInputStream(serialBytes(o)));
1865              T clone = (T) ois.readObject();
1866 +            if (o == clone) assertImmutable(o);
1867              assertSame(o.getClass(), clone.getClass());
1868              return clone;
1869          } catch (Throwable fail) {
# Line 1834 | Line 1872 | public class JSR166TestCase extends Test
1872          }
1873      }
1874  
1875 +    /**
1876 +     * A version of serialClone that leaves error handling (for
1877 +     * e.g. NotSerializableException) up to the caller.
1878 +     */
1879 +    @SuppressWarnings("unchecked")
1880 +    <T> T serialClonePossiblyFailing(T o)
1881 +        throws ReflectiveOperationException, java.io.IOException {
1882 +        ByteArrayOutputStream bos = new ByteArrayOutputStream();
1883 +        ObjectOutputStream oos = new ObjectOutputStream(bos);
1884 +        oos.writeObject(o);
1885 +        oos.flush();
1886 +        oos.close();
1887 +        ObjectInputStream ois = new ObjectInputStream
1888 +            (new ByteArrayInputStream(bos.toByteArray()));
1889 +        T clone = (T) ois.readObject();
1890 +        if (o == clone) assertImmutable(o);
1891 +        assertSame(o.getClass(), clone.getClass());
1892 +        return clone;
1893 +    }
1894 +
1895 +    /**
1896 +     * If o implements Cloneable and has a public clone method,
1897 +     * returns a clone of o, else null.
1898 +     */
1899 +    @SuppressWarnings("unchecked")
1900 +    <T> T cloneableClone(T o) {
1901 +        if (!(o instanceof Cloneable)) return null;
1902 +        final T clone;
1903 +        try {
1904 +            clone = (T) o.getClass().getMethod("clone").invoke(o);
1905 +        } catch (NoSuchMethodException ok) {
1906 +            return null;
1907 +        } catch (ReflectiveOperationException unexpected) {
1908 +            throw new Error(unexpected);
1909 +        }
1910 +        assertNotSame(o, clone); // not 100% guaranteed by spec
1911 +        assertSame(o.getClass(), clone.getClass());
1912 +        return clone;
1913 +    }
1914 +
1915      public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
1916                               Runnable... throwingActions) {
1917          for (Runnable throwingAction : throwingActions) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines