jdk/test/java/util/concurrent/tck/JSR166TestCase.java
changeset 43545 fdecd1d14d53
parent 42927 1d31e540bfcb
child 44039 058585425bb7
equal deleted inserted replaced
43544:457673db6798 43545:fdecd1d14d53
    44 /*
    44 /*
    45  * @test
    45  * @test
    46  * @summary JSR-166 tck tests (whitebox tests allowed)
    46  * @summary JSR-166 tck tests (whitebox tests allowed)
    47  * @build *
    47  * @build *
    48  * @modules java.base/java.util.concurrent:open
    48  * @modules java.base/java.util.concurrent:open
       
    49  *          java.base/java.lang:open
    49  *          java.management
    50  *          java.management
    50  * @run junit/othervm/timeout=1000
    51  * @run junit/othervm/timeout=1000
    51  *      -Djsr166.testImplementationDetails=true
    52  *      -Djsr166.testImplementationDetails=true
    52  *      JSR166TestCase
    53  *      JSR166TestCase
    53  * @run junit/othervm/timeout=1000
    54  * @run junit/othervm/timeout=1000
    56  *      JSR166TestCase
    57  *      JSR166TestCase
    57  * @run junit/othervm/timeout=1000
    58  * @run junit/othervm/timeout=1000
    58  *      -Djsr166.testImplementationDetails=true
    59  *      -Djsr166.testImplementationDetails=true
    59  *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=1
    60  *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=1
    60  *      -Djava.util.secureRandomSeed=true
    61  *      -Djava.util.secureRandomSeed=true
       
    62  *      JSR166TestCase
       
    63  * @run junit/othervm/timeout=1000/policy=tck.policy
       
    64  *      -Djsr166.testImplementationDetails=true
    61  *      JSR166TestCase
    65  *      JSR166TestCase
    62  */
    66  */
    63 
    67 
    64 import static java.util.concurrent.TimeUnit.MILLISECONDS;
    68 import static java.util.concurrent.TimeUnit.MILLISECONDS;
    65 import static java.util.concurrent.TimeUnit.MINUTES;
    69 import static java.util.concurrent.TimeUnit.MINUTES;
   582                 "AtomicLong9Test",
   586                 "AtomicLong9Test",
   583                 "AtomicLongArray9Test",
   587                 "AtomicLongArray9Test",
   584                 "AtomicReference9Test",
   588                 "AtomicReference9Test",
   585                 "AtomicReferenceArray9Test",
   589                 "AtomicReferenceArray9Test",
   586                 "ExecutorCompletionService9Test",
   590                 "ExecutorCompletionService9Test",
       
   591                 "ForkJoinPool9Test",
   587             };
   592             };
   588             addNamedTestClasses(suite, java9TestClassNames);
   593             addNamedTestClasses(suite, java9TestClassNames);
   589         }
   594         }
   590 
   595 
   591         return suite;
   596         return suite;
   592     }
   597     }
   593 
   598 
   594     /** Returns list of junit-style test method names in given class. */
   599     /** Returns list of junit-style test method names in given class. */
   595     public static ArrayList<String> testMethodNames(Class<?> testClass) {
   600     public static ArrayList<String> testMethodNames(Class<?> testClass) {
   596         Method[] methods = testClass.getDeclaredMethods();
   601         Method[] methods = testClass.getDeclaredMethods();
   597         ArrayList<String> names = new ArrayList<String>(methods.length);
   602         ArrayList<String> names = new ArrayList<>(methods.length);
   598         for (Method method : methods) {
   603         for (Method method : methods) {
   599             if (method.getName().startsWith("test")
   604             if (method.getName().startsWith("test")
   600                 && Modifier.isPublic(method.getModifiers())
   605                 && Modifier.isPublic(method.getModifiers())
   601                 // method.getParameterCount() requires jdk8+
   606                 // method.getParameterCount() requires jdk8+
   602                 && method.getParameterTypes().length == 0) {
   607                 && method.getParameterTypes().length == 0) {
   698 
   703 
   699     /**
   704     /**
   700      * The first exception encountered if any threadAssertXXX method fails.
   705      * The first exception encountered if any threadAssertXXX method fails.
   701      */
   706      */
   702     private final AtomicReference<Throwable> threadFailure
   707     private final AtomicReference<Throwable> threadFailure
   703         = new AtomicReference<Throwable>(null);
   708         = new AtomicReference<>(null);
   704 
   709 
   705     /**
   710     /**
   706      * Records an exception so that it can be rethrown later in the test
   711      * Records an exception so that it can be rethrown later in the test
   707      * harness thread, triggering a test case failure.  Only the first
   712      * harness thread, triggering a test case failure.  Only the first
   708      * failure is recorded; subsequent calls to this method from within
   713      * failure is recorded; subsequent calls to this method from within
  1260         public boolean implies(ProtectionDomain pd, Permission p) {
  1265         public boolean implies(ProtectionDomain pd, Permission p) {
  1261             return perms.implies(p);
  1266             return perms.implies(p);
  1262         }
  1267         }
  1263         public void refresh() {}
  1268         public void refresh() {}
  1264         public String toString() {
  1269         public String toString() {
  1265             List<Permission> ps = new ArrayList<Permission>();
  1270             List<Permission> ps = new ArrayList<>();
  1266             for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();)
  1271             for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();)
  1267                 ps.add(e.nextElement());
  1272                 ps.add(e.nextElement());
  1268             return "AdjustablePolicy with permissions " + ps;
  1273             return "AdjustablePolicy with permissions " + ps;
  1269         }
  1274         }
  1270     }
  1275     }