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.204 by jsr166, Sat Oct 15 18:51:12 2016 UTC vs.
Revision 1.212 by jsr166, Fri Dec 9 04:24:07 2016 UTC

# Line 9 | Line 9
9   /*
10   * @test
11   * @summary JSR-166 tck tests
12 < * @modules java.management
12 > * @modules java.base/java.util.concurrent:open
13 > *          java.management
14   * @build *
15   * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase
16   * @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase
# Line 41 | Line 42 | import java.security.ProtectionDomain;
42   import java.security.SecurityPermission;
43   import java.util.ArrayList;
44   import java.util.Arrays;
45 + import java.util.Collection;
46   import java.util.Collections;
47   import java.util.Date;
48   import java.util.Enumeration;
# Line 447 | Line 449 | public class JSR166TestCase extends Test
449              AbstractQueuedLongSynchronizerTest.suite(),
450              ArrayBlockingQueueTest.suite(),
451              ArrayDequeTest.suite(),
452 +            ArrayListTest.suite(),
453              AtomicBooleanTest.suite(),
454              AtomicIntegerArrayTest.suite(),
455              AtomicIntegerFieldUpdaterTest.suite(),
# Line 498 | Line 501 | public class JSR166TestCase extends Test
501              TreeMapTest.suite(),
502              TreeSetTest.suite(),
503              TreeSubMapTest.suite(),
504 <            TreeSubSetTest.suite());
504 >            TreeSubSetTest.suite(),
505 >            VectorTest.suite());
506  
507          // Java8+ test classes
508          if (atLeastJava8()) {
509              String[] java8TestClassNames = {
510 +                "ArrayDeque8Test",
511                  "Atomic8Test",
512                  "CompletableFutureTest",
513                  "ConcurrentHashMap8Test",
# Line 1824 | Line 1829 | public class JSR166TestCase extends Test
1829          }
1830      }
1831  
1832 +    void assertImmutable(final Object o) {
1833 +        if (o instanceof Collection) {
1834 +            assertThrows(
1835 +                UnsupportedOperationException.class,
1836 +                new Runnable() { public void run() {
1837 +                        ((Collection) o).add(null);}});
1838 +        }
1839 +    }
1840 +
1841      @SuppressWarnings("unchecked")
1842      <T> T serialClone(T o) {
1843          try {
1844              ObjectInputStream ois = new ObjectInputStream
1845                  (new ByteArrayInputStream(serialBytes(o)));
1846              T clone = (T) ois.readObject();
1847 +            if (o == clone) assertImmutable(o);
1848              assertSame(o.getClass(), clone.getClass());
1849              return clone;
1850          } catch (Throwable fail) {
# Line 1838 | Line 1853 | public class JSR166TestCase extends Test
1853          }
1854      }
1855  
1856 +    /**
1857 +     * A version of serialClone that leaves error handling (for
1858 +     * e.g. NotSerializableException) up to the caller.
1859 +     */
1860 +    @SuppressWarnings("unchecked")
1861 +    <T> T serialClonePossiblyFailing(T o)
1862 +        throws ReflectiveOperationException, java.io.IOException {
1863 +        ByteArrayOutputStream bos = new ByteArrayOutputStream();
1864 +        ObjectOutputStream oos = new ObjectOutputStream(bos);
1865 +        oos.writeObject(o);
1866 +        oos.flush();
1867 +        oos.close();
1868 +        ObjectInputStream ois = new ObjectInputStream
1869 +            (new ByteArrayInputStream(bos.toByteArray()));
1870 +        T clone = (T) ois.readObject();
1871 +        if (o == clone) assertImmutable(o);
1872 +        assertSame(o.getClass(), clone.getClass());
1873 +        return clone;
1874 +    }
1875 +
1876 +    /**
1877 +     * If o implements Cloneable and has a public clone method,
1878 +     * returns a clone of o, else null.
1879 +     */
1880 +    @SuppressWarnings("unchecked")
1881 +    <T> T cloneableClone(T o) {
1882 +        if (!(o instanceof Cloneable)) return null;
1883 +        final T clone;
1884 +        try {
1885 +            clone = (T) o.getClass().getMethod("clone").invoke(o);
1886 +        } catch (NoSuchMethodException ok) {
1887 +            return null;
1888 +        } catch (ReflectiveOperationException unexpected) {
1889 +            throw new Error(unexpected);
1890 +        }
1891 +        assertNotSame(o, clone); // not 100% guaranteed by spec
1892 +        assertSame(o.getClass(), clone.getClass());
1893 +        return clone;
1894 +    }
1895 +
1896      public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
1897                               Runnable... throwingActions) {
1898          for (Runnable throwingAction : throwingActions) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines