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.209 by jsr166, Sun Nov 6 05:00:55 2016 UTC

# Line 41 | Line 41 | import java.security.ProtectionDomain;
41   import java.security.SecurityPermission;
42   import java.util.ArrayList;
43   import java.util.Arrays;
44 + import java.util.Collection;
45 + import java.util.Collections;
46   import java.util.Date;
47   import java.util.Enumeration;
48   import java.util.Iterator;
# Line 62 | Line 64 | import java.util.concurrent.RejectedExec
64   import java.util.concurrent.Semaphore;
65   import java.util.concurrent.SynchronousQueue;
66   import java.util.concurrent.ThreadFactory;
67 + import java.util.concurrent.ThreadLocalRandom;
68   import java.util.concurrent.ThreadPoolExecutor;
69   import java.util.concurrent.TimeoutException;
70   import java.util.concurrent.atomic.AtomicBoolean;
# Line 445 | Line 448 | public class JSR166TestCase extends Test
448              AbstractQueuedLongSynchronizerTest.suite(),
449              ArrayBlockingQueueTest.suite(),
450              ArrayDequeTest.suite(),
451 +            ArrayListTest.suite(),
452              AtomicBooleanTest.suite(),
453              AtomicIntegerArrayTest.suite(),
454              AtomicIntegerFieldUpdaterTest.suite(),
# Line 467 | Line 471 | public class JSR166TestCase extends Test
471              CopyOnWriteArrayListTest.suite(),
472              CopyOnWriteArraySetTest.suite(),
473              CountDownLatchTest.suite(),
474 +            CountedCompleterTest.suite(),
475              CyclicBarrierTest.suite(),
476              DelayQueueTest.suite(),
477              EntryTest.suite(),
# Line 495 | Line 500 | public class JSR166TestCase extends Test
500              TreeMapTest.suite(),
501              TreeSetTest.suite(),
502              TreeSubMapTest.suite(),
503 <            TreeSubSetTest.suite());
503 >            TreeSubSetTest.suite(),
504 >            VectorTest.suite());
505  
506          // Java8+ test classes
507          if (atLeastJava8()) {
508              String[] java8TestClassNames = {
509 +                "ArrayDeque8Test",
510                  "Atomic8Test",
511                  "CompletableFutureTest",
512                  "ConcurrentHashMap8Test",
513 <                "CountedCompleterTest",
513 >                "CountedCompleter8Test",
514                  "DoubleAccumulatorTest",
515                  "DoubleAdderTest",
516                  "ForkJoinPool8Test",
# Line 1003 | Line 1010 | public class JSR166TestCase extends Test
1010          ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
1011          System.err.println("------ stacktrace dump start ------");
1012          for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
1013 <            String name = info.getThreadName();
1013 >            final String name = info.getThreadName();
1014 >            String lockName;
1015              if ("Signal Dispatcher".equals(name))
1016                  continue;
1017              if ("Reference Handler".equals(name)
1018 <                && info.getLockName().startsWith("java.lang.ref.Reference$Lock"))
1018 >                && (lockName = info.getLockName()) != null
1019 >                && lockName.startsWith("java.lang.ref.Reference$Lock"))
1020                  continue;
1021              if ("Finalizer".equals(name)
1022 <                && info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock"))
1022 >                && (lockName = info.getLockName()) != null
1023 >                && lockName.startsWith("java.lang.ref.ReferenceQueue$Lock"))
1024                  continue;
1025              if ("checkForWedgedTest".equals(name))
1026                  continue;
# Line 1235 | Line 1245 | public class JSR166TestCase extends Test
1245       * Sleeps until the given time has elapsed.
1246       * Throws AssertionFailedError if interrupted.
1247       */
1248 <    void sleep(long millis) {
1248 >    static void sleep(long millis) {
1249          try {
1250              delay(millis);
1251          } catch (InterruptedException fail) {
# Line 1754 | Line 1764 | public class JSR166TestCase extends Test
1764       * A CyclicBarrier that uses timed await and fails with
1765       * AssertionFailedErrors instead of throwing checked exceptions.
1766       */
1767 <    public class CheckedBarrier extends CyclicBarrier {
1767 >    public static class CheckedBarrier extends CyclicBarrier {
1768          public CheckedBarrier(int parties) { super(parties); }
1769  
1770          public int await() {
# Line 1818 | Line 1828 | public class JSR166TestCase extends Test
1828          }
1829      }
1830  
1831 +    void assertImmutable(Object o) {
1832 +        if (o instanceof Collection) {
1833 +            assertThrows(
1834 +                UnsupportedOperationException.class,
1835 +                new Runnable() { public void run() {
1836 +                        ((Collection) o).add(null);}});
1837 +        }
1838 +    }
1839 +
1840      @SuppressWarnings("unchecked")
1841      <T> T serialClone(T o) {
1842          try {
1843              ObjectInputStream ois = new ObjectInputStream
1844                  (new ByteArrayInputStream(serialBytes(o)));
1845              T clone = (T) ois.readObject();
1846 +            if (o == clone) assertImmutable(o);
1847              assertSame(o.getClass(), clone.getClass());
1848              return clone;
1849          } catch (Throwable fail) {
# Line 1832 | Line 1852 | public class JSR166TestCase extends Test
1852          }
1853      }
1854  
1855 +    /**
1856 +     * If o implements Cloneable and has a public clone method,
1857 +     * returns a clone of o, else null.
1858 +     */
1859 +    @SuppressWarnings("unchecked")
1860 +    <T> T cloneableClone(T o) {
1861 +        if (!(o instanceof Cloneable)) return null;
1862 +        final T clone;
1863 +        try {
1864 +            clone = (T) o.getClass().getMethod("clone").invoke(o);
1865 +        } catch (NoSuchMethodException ok) {
1866 +            return null;
1867 +        } catch (ReflectiveOperationException unexpected) {
1868 +            throw new Error(unexpected);
1869 +        }
1870 +        assertNotSame(o, clone); // not 100% guaranteed by spec
1871 +        assertSame(o.getClass(), clone.getClass());
1872 +        return clone;
1873 +    }
1874 +
1875      public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
1876                               Runnable... throwingActions) {
1877          for (Runnable throwingAction : throwingActions) {
# Line 1875 | Line 1915 | public class JSR166TestCase extends Test
1915                                 1000L, MILLISECONDS,
1916                                 new SynchronousQueue<Runnable>());
1917  
1918 +    static <T> void shuffle(T[] array) {
1919 +        Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current());
1920 +    }
1921   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines