From ad58216bac63c16a5aeb73049e67e898b3462de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Op=C3=A1lka?= Date: Sat, 16 Nov 2024 22:01:26 +0100 Subject: [PATCH] [WFCORE-7064] Do not set SM options in tests on JDK24+ --- .../launcher/test/LauncherTestCase.java | 18 ++++++++++++------ .../scripts/test/DomainScriptTestCase.java | 2 +- .../wildfly/scripts/test/ScriptTestCase.java | 2 ++ .../scripts/test/StandaloneScriptTestCase.java | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/testsuite/scripts/src/test/java/org/wildfly/launcher/test/LauncherTestCase.java b/testsuite/scripts/src/test/java/org/wildfly/launcher/test/LauncherTestCase.java index 97c3c197b7e..20c1c772769 100644 --- a/testsuite/scripts/src/test/java/org/wildfly/launcher/test/LauncherTestCase.java +++ b/testsuite/scripts/src/test/java/org/wildfly/launcher/test/LauncherTestCase.java @@ -45,10 +45,13 @@ public static void setup() throws Exception { @Test public void testStandaloneWithAgent() throws Exception { final StandaloneCommandBuilder builder = StandaloneCommandBuilder.of(ServerHelper.JBOSS_HOME) - .addJavaOptions(ServerHelper.DEFAULT_SERVER_JAVA_OPTS) - .setUseSecurityManager(parseProperty("security.manager")) - // Add the test logging agent to the jboss-modules arguments - .addModuleOption("-javaagent:" + ServerHelper.JBOSS_HOME.resolve("logging-agent-tests.jar") + "=" + LoggingAgent.DEBUG_ARG); + .addJavaOptions(ServerHelper.DEFAULT_SERVER_JAVA_OPTS); + // [WFCORE-7064] Setting SM is not allowed on JDK24+ + if (Runtime.version().feature() < 24) { + builder.setUseSecurityManager(parseProperty("security.manager")); + } + // Add the test logging agent to the jboss-modules arguments + builder.addModuleOption("-javaagent:" + ServerHelper.JBOSS_HOME.resolve("logging-agent-tests.jar") + "=" + LoggingAgent.DEBUG_ARG); final String localRepo = System.getProperty("maven.repo.local"); if (localRepo != null) { @@ -85,8 +88,11 @@ public void testStandaloneWithAgent() throws Exception { @Test public void testDomainServerWithAgent() throws Exception { final DomainCommandBuilder builder = DomainCommandBuilder.of(ServerHelper.JBOSS_HOME) - .addHostControllerJavaOptions(ServerHelper.DEFAULT_SERVER_JAVA_OPTS) - .setUseSecurityManager(parseProperty("security.manager")); + .addHostControllerJavaOptions(ServerHelper.DEFAULT_SERVER_JAVA_OPTS); + // [WFCORE-7064] Setting SM is not allowed on JDK24+ + if (Runtime.version().feature() < 24) { + builder.setUseSecurityManager(parseProperty("security.manager")); + } final String localRepo = System.getProperty("maven.repo.local"); if (localRepo != null) { diff --git a/testsuite/scripts/src/test/java/org/wildfly/scripts/test/DomainScriptTestCase.java b/testsuite/scripts/src/test/java/org/wildfly/scripts/test/DomainScriptTestCase.java index 1cd59f62dd4..bb63f7c825e 100644 --- a/testsuite/scripts/src/test/java/org/wildfly/scripts/test/DomainScriptTestCase.java +++ b/testsuite/scripts/src/test/java/org/wildfly/scripts/test/DomainScriptTestCase.java @@ -38,7 +38,7 @@ public DomainScriptTestCase() { @Parameterized.Parameters public static Collection data() { - return List.of(Map.of(), Map.of("SECMGR", "true")); + return List.of(Map.of(), Map.of("SECMGR", SECMGR_VALUE)); } @Override diff --git a/testsuite/scripts/src/test/java/org/wildfly/scripts/test/ScriptTestCase.java b/testsuite/scripts/src/test/java/org/wildfly/scripts/test/ScriptTestCase.java index ddbc12da401..69f558d9b11 100644 --- a/testsuite/scripts/src/test/java/org/wildfly/scripts/test/ScriptTestCase.java +++ b/testsuite/scripts/src/test/java/org/wildfly/scripts/test/ScriptTestCase.java @@ -42,6 +42,8 @@ */ public abstract class ScriptTestCase { + // [WFCORE-7064] Setting SM is not allowed on JDK24+ + static final String SECMGR_VALUE = Runtime.version().feature() < 24 ? "true" : "false"; static final Map MAVEN_JAVA_OPTS = new LinkedHashMap<>(); private final String scriptBaseName; diff --git a/testsuite/scripts/src/test/java/org/wildfly/scripts/test/StandaloneScriptTestCase.java b/testsuite/scripts/src/test/java/org/wildfly/scripts/test/StandaloneScriptTestCase.java index f9ac170f9fd..1740d2ca0bd 100644 --- a/testsuite/scripts/src/test/java/org/wildfly/scripts/test/StandaloneScriptTestCase.java +++ b/testsuite/scripts/src/test/java/org/wildfly/scripts/test/StandaloneScriptTestCase.java @@ -54,7 +54,7 @@ public static Collection data() { Map.of(), Map.of("GC_LOG", "true"), Map.of("MODULE_OPTS", "-javaagent:logging-agent-tests.jar=" + LoggingAgent.DEBUG_ARG), - Map.of("SECMGR", "true") + Map.of("SECMGR", SECMGR_VALUE) ); }