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.209 by jsr166, Sun Nov 6 05:00:55 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 1828 | Line 1846 | public class JSR166TestCase extends Test
1846          }
1847      }
1848  
1849 <    void assertImmutable(Object o) {
1849 >    void assertImmutable(final Object o) {
1850          if (o instanceof Collection) {
1851              assertThrows(
1852                  UnsupportedOperationException.class,
# Line 1853 | Line 1871 | public class JSR166TestCase extends Test
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       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines