diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ef4fbd1..48501ff2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest ] - java: ['11', '17'] + java: ['11', '17', '21'] steps: - uses: actions/checkout@v4 diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java index a3ad004b..4c04b433 100644 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java +++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/AbstractBootableJarMojoTestCase.java @@ -27,7 +27,6 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; @@ -392,15 +391,16 @@ protected String getContent(String url) throws Exception { } protected Process startServer(Path dir, String fileName, String... args) throws Exception { + final List serverArgs = List.of(args); List cmd = new ArrayList<>(); cmd.add(getJavaCommand()); - cmd.addAll(getJvmArgs()); + cmd.addAll(getJvmArgs(serverArgs.contains("-secmgr"))); // On windows, to remove when Upgraded to WILDFLY 26.1.1 that should contain XNIO 3.8.7 // https://issues.redhat.com/browse/XNIO-404 cmd.add("-Djdk.io.File.enableADS=true"); cmd.add("-jar"); cmd.add(dir.resolve("target").resolve(fileName == null ? TEST_FILE : fileName).toAbsolutePath().toString()); - cmd.addAll(Arrays.asList(args)); + cmd.addAll(serverArgs); final Path out = TestEnvironment.createTempPath("logs", getClass().getName() + "-process.txt"); final Path parent = out.getParent(); if (parent != null && Files.notExists(parent)) { @@ -515,7 +515,7 @@ private static String getJavaCommand() { return cmd; } - private static Collection getJvmArgs() { + private static Collection getJvmArgs(final boolean securityManager) { final Collection result = new ArrayList<>(); final String defaultArgs = System.getProperty("test.jvm.args"); if (defaultArgs != null) { @@ -526,6 +526,9 @@ private static Collection getJvmArgs() { } } } + if (securityManager && TestEnvironment.javaVersion() >= 17) { + result.add("-Djava.security.manager=allow"); + } return result; } diff --git a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/TestEnvironment.java b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/TestEnvironment.java index 216b683b..3d07a2c7 100644 --- a/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/TestEnvironment.java +++ b/tests/src/test/java/org/wildfly/plugins/bootablejar/maven/goals/TestEnvironment.java @@ -33,10 +33,12 @@ class TestEnvironment { private static final int MGMT_PORT = getProperty("ts.mgmt.port", 9990); private static final String TMP_DIR = System.getProperty("java.io.tmpdir", "target"); private static final boolean IS_WINDOWS; + private static final int JAVA_VERSION; static { final String os = System.getProperty("os.name").toLowerCase(Locale.ROOT); IS_WINDOWS = os.contains("win"); + JAVA_VERSION = Integer.parseInt(System.getProperty("java.vm.specification.version")); } /** @@ -107,6 +109,15 @@ static Path createTempPath(final String... paths) { return Paths.get(TMP_DIR, paths); } + /** + * Returns the current Java version. + * + * @return the java version + */ + static int javaVersion() { + return JAVA_VERSION; + } + private static int getProperty(final String name, final int dft) { final String value = System.getProperty(name); return value == null ? dft : Integer.parseInt(value);