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.272 by dl, Tue Jan 26 13:33:06 2021 UTC vs.
Revision 1.275 by dl, Tue Mar 22 21:29:24 2022 UTC

# Line 152 | Line 152 | import junit.framework.TestSuite;
152   * in one spot to rerun tests on slower platforms.
153   *
154   * Class Item is used for elements of collections and related
155 < * purposes. Many tests rely on themir keys being equal to ints. To
155 > * purposes. Many tests rely on their keys being equal to ints. To
156   * check these, methods mustEqual, mustContain, etc adapt the JUnit
157   * assert methods to intercept ints.
158   *
# Line 195 | Line 195 | import junit.framework.TestSuite;
195   * </ul>
196   */
197   public class JSR166TestCase extends TestCase {
198 +    // No longer run with custom securityManagers
199      private static final boolean useSecurityManager =
200 <        Boolean.getBoolean("jsr166.useSecurityManager");
200 >    Boolean.getBoolean("jsr166.useSecurityManager");
201  
202      protected static final boolean expensiveTests =
203          Boolean.getBoolean("jsr166.expensiveTests");
# Line 407 | Line 408 | public class JSR166TestCase extends Test
408       * Runs all unit tests in the given test suite.
409       * Actual behavior influenced by jsr166.* system properties.
410       */
411 +    @SuppressWarnings("removal")
412      static void main(Test suite, String[] args) {
413          if (useSecurityManager) {
414              System.err.println("Setting a permissive security manager");
415              Policy.setPolicy(permissivePolicy());
416 <            System.setSecurityManager(new SecurityManager());
416 >            try {
417 >                System.setSecurityManager(new SecurityManager());
418 >            } catch(Throwable ok) {  // failure OK during deprecation
419 >            }
420          }
421          for (int i = 0; i < suiteRuns; i++) {
422              TestResult result = newPithyTestRunner().doRun(suite);
# Line 452 | Line 457 | public class JSR166TestCase extends Test
457      public static final String JAVA_SPECIFICATION_VERSION;
458      static {
459          try {
460 <            JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged(
460 >            @SuppressWarnings("removal") double jcv =
461 >            java.security.AccessController.doPrivileged(
462                  new java.security.PrivilegedAction<Double>() {
463                  public Double run() {
464                      return Double.valueOf(System.getProperty("java.class.version"));}});
465 <            JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged(
465 >            JAVA_CLASS_VERSION = jcv;
466 >            @SuppressWarnings("removal") String jsv =
467 >            java.security.AccessController.doPrivileged(
468                  new java.security.PrivilegedAction<String>() {
469                  public String run() {
470                      return System.getProperty("java.specification.version");}});
471 +            JAVA_SPECIFICATION_VERSION = jsv;
472          } catch (Throwable t) {
473              throw new Error(t);
474          }
# Line 596 | Line 605 | public class JSR166TestCase extends Test
605              addNamedTestClasses(suite, java9TestClassNames);
606          }
607  
608 +        if (atLeastJava17()) {
609 +            String[] java17TestClassNames = {
610 +                "ForkJoinPool19Test",
611 +            };
612 +            addNamedTestClasses(suite, java17TestClassNames);
613 +        }
614          return suite;
615      }
616  
# Line 1054 | Line 1069 | public class JSR166TestCase extends Test
1069      void joinPool(ExecutorService pool) {
1070          try {
1071              pool.shutdown();
1072 <            if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) {
1072 >            if (!pool.awaitTermination(20 * LONG_DELAY_MS, MILLISECONDS)) {
1073                  try {
1074                      threadFail("ExecutorService " + pool +
1075                                 " did not terminate in a timely manner");
# Line 1138 | Line 1153 | public class JSR166TestCase extends Test
1153       * A debugging tool to print stack traces of most threads, as jstack does.
1154       * Uninteresting threads are filtered out.
1155       */
1156 +    @SuppressWarnings("removal")
1157      static void dumpTestThreads() {
1158          SecurityManager sm = System.getSecurityManager();
1159          if (sm != null) {
# Line 1346 | Line 1362 | public class JSR166TestCase extends Test
1362          assertTrue(c.remove(i));
1363      }
1364      static void mustNotRemove(Collection<Item> c, int i) {
1365 <        Item[] items = defaultItems;
1350 <        Item x = (i >= 0 && i < items.length) ? items[i] : new Item(i);
1351 <        assertFalse(c.remove(x));
1365 >        assertFalse(c.remove(itemFor(i)));
1366      }
1367      static void mustNotRemove(Collection<Item> c, Item i) {
1368          assertFalse(c.remove(i));
# Line 1373 | Line 1387 | public class JSR166TestCase extends Test
1387       * security manager.  We require that any security manager permit
1388       * getPolicy/setPolicy.
1389       */
1390 +    @SuppressWarnings("removal")
1391      public void runWithPermissions(Runnable r, Permission... permissions) {
1392          SecurityManager sm = System.getSecurityManager();
1393          if (sm == null) {
# Line 1388 | Line 1403 | public class JSR166TestCase extends Test
1403       * Runnable.  We require that any security manager permit
1404       * getPolicy/setPolicy.
1405       */
1406 +    @SuppressWarnings("removal")
1407      public void runWithSecurityManagerWithPermissions(Runnable r,
1408                                                        Permission... permissions) {
1409 +        if (!useSecurityManager) return;
1410          SecurityManager sm = System.getSecurityManager();
1411          if (sm == null) {
1412              Policy savedPolicy = Policy.getPolicy();
# Line 1397 | Line 1414 | public class JSR166TestCase extends Test
1414                  Policy.setPolicy(permissivePolicy());
1415                  System.setSecurityManager(new SecurityManager());
1416                  runWithSecurityManagerWithPermissions(r, permissions);
1417 +            } catch (UnsupportedOperationException ok) {
1418              } finally {
1419 <                System.setSecurityManager(null);
1420 <                Policy.setPolicy(savedPolicy);
1419 >                try {
1420 >                    System.setSecurityManager(null);
1421 >                    Policy.setPolicy(savedPolicy);
1422 >                } catch (Exception ok) {
1423 >                }
1424              }
1425          } else {
1426              Policy savedPolicy = Policy.getPolicy();
# Line 1426 | Line 1447 | public class JSR166TestCase extends Test
1447       * A security policy where new permissions can be dynamically added
1448       * or all cleared.
1449       */
1450 +    @SuppressWarnings("removal")
1451      public static class AdjustablePolicy extends java.security.Policy {
1452          Permissions perms = new Permissions();
1453          AdjustablePolicy(Permission... permissions) {
# Line 1455 | Line 1477 | public class JSR166TestCase extends Test
1477      /**
1478       * Returns a policy containing all the permissions we ever need.
1479       */
1480 +    @SuppressWarnings("removal")
1481      public static Policy permissivePolicy() {
1482          return new AdjustablePolicy
1483              // Permissions j.u.c. needs directly

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines