Skip to content

Commit

Permalink
Ignore another test for Java 21
Browse files Browse the repository at this point in the history
Security controllers are no longer supported, so don't test them
  • Loading branch information
gbrail committed Jun 9, 2024
1 parent c95cacc commit c9ea2d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.security.ProtectionDomain;
import java.security.URIParameter;
import java.util.Enumeration;

import org.hamcrest.CoreMatchers;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mozilla.javascript.ClassShutter;
Expand All @@ -36,6 +39,7 @@ static void setupSecurityManager() {}
/** Setup the security */
@BeforeClass
public static void setup() throws Exception {
Assume.assumeThat("Skipping test for Java 21", Utils.isJavaVersionAtLeast(21), CoreMatchers.is(false));
URL url = SecurityControllerTest.class.getResource("grant-all-java.policy");
if (url != null) {
System.setProperty("java.security.policy", url.toString());
Expand Down Expand Up @@ -69,6 +73,9 @@ private static ProtectionDomain createProtectionDomain(Policy policy, String csS

@Test
public void barAccess() {
// Security managers are out in Java 21, so skip.
Assume.assumeThat("Skipping test for Java 21", Utils.isJavaVersionAtLeast(21), CoreMatchers.is(false));

// f.create produces "SomeClass extends ArrayList<String> implements
// SomeInterface"
// we may access array methods, like 'size' defined by ArrayList,
Expand Down
6 changes: 6 additions & 0 deletions tests/src/test/java/org/mozilla/javascript/tests/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,10 @@ public static int[] getTestOptLevels() {
}
return DEFAULT_OPT_LEVELS;
}

public static boolean isJavaVersionAtLeast(int desiredVersion) {
String[] v = System.getProperty("java.version").split("\\.");
int version = Integer.parseInt(v[0]);
return version >= desiredVersion;
}
}

0 comments on commit c9ea2d6

Please sign in to comment.