diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 51ca58b66..4313a36e5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -7,7 +7,7 @@ on: push: branches: '**' pull_request: - branches: [ main ] + branches: [ main, 1.x ] jobs: build: diff --git a/src/test/java/io/openliberty/tools/common/config/ExpansionVariableLogMessageTest.java b/src/test/java/io/openliberty/tools/common/config/ExpansionVariableLogMessageTest.java index fe176c9ff..6ceb013b7 100644 --- a/src/test/java/io/openliberty/tools/common/config/ExpansionVariableLogMessageTest.java +++ b/src/test/java/io/openliberty/tools/common/config/ExpansionVariableLogMessageTest.java @@ -49,7 +49,10 @@ private static class CapturingLogger extends TestLogger { } // server.env is placed in serverDir because SERVER_CONFIG_DIR maps there, making it visible to processServerEnv() + // A minimal server.xml is required so that ServerConfigDocument. does not NPE when it calls parseDocument(serverXMLFile). private ServerConfigDocument buildDoc(CapturingLogger log, File serverDir, String serverEnvContent) throws Exception { + Files.write(new File(serverDir, "server.xml").toPath(), + "".getBytes()); Files.write(new File(serverDir, "server.env").toPath(), serverEnvContent.getBytes()); Map dirMap = new HashMap<>(); @@ -118,11 +121,14 @@ public void testWindowsStyleBackslashesPreservedInLog() throws Exception { CapturingLogger log = new CapturingLogger(); File serverDir = tmp.newFolder("server-win"); - // Reproduces the exact scenario from issue #2076 - String envContent = "IBM_JAVA_SEMERU_HOME=C:\\MyData\\java\\ibm-semeru-certified\nJAVA_HOME=!IBM_JAVA_SEMERU_HOME!\\jdk-21.0.10+7\n"; + // Reproduces the exact scenario from issue #2076. + // Backslashes must be doubled in the .properties file format so that Properties.load() preserves them as single backslashes. + String envContent = "IBM_JAVA_SEMERU_HOME=C:\\\\MyData\\\\java\\\\ibm-semeru-certified\nJAVA_HOME=!IBM_JAVA_SEMERU_HOME!\\\\jdk-21.0.10+7\n"; buildDoc(log, serverDir, envContent).processServerEnv(); - String expectedMsg = "Resolved environment variable \"IBM_JAVA_SEMERU_HOME\" in path \"!IBM_JAVA_SEMERU_HOME!\\jdk-21.0.10+7\" to \"C:\\MyData\\java\\ibm-semeru-certified\\jdk-21.0.10+7\""; + // per-var log: shows only what IBM_JAVA_SEMERU_HOME itself resolved to, not the full concatenated value + String expectedMsg = "Resolved environment variable \"IBM_JAVA_SEMERU_HOME\" in path \"!IBM_JAVA_SEMERU_HOME!\\jdk-21.0.10+7\" to \"C:\\MyData\\java\\ibm-semeru-certified\""; + // summary log: shows the full expression after all substitutions String expectedSummary = "Resolved path \"!IBM_JAVA_SEMERU_HOME!\\jdk-21.0.10+7\" to \"C:\\MyData\\java\\ibm-semeru-certified\\jdk-21.0.10+7\""; assertTrue("Log message with backslashes not found — backslashes may have been dropped.\nActual: " + log.infoMessages, log.infoMessages.stream().anyMatch(m -> m.equals(expectedMsg))); diff --git a/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java b/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java index 3724f6b61..50f7de397 100644 --- a/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java +++ b/src/test/java/io/openliberty/tools/common/plugins/util/BaseDevUtilTest.java @@ -57,6 +57,14 @@ public DevTestUtil(File serverDirectory, File buildDir, boolean container) { container, null, null, null, 0, false, null, false, null, null, false, null, null, null, false, null, null, null, Collections.emptyMap()); } + /** + * Returns null for all container CLI commands to avoid requiring a running container engine. + */ + @Override + protected String execContainerCmdWithPrefix(String command, int timeout, boolean throwExceptionOnError) { + return null; + } + /** * Sets the container port fields without going through findLocalPort (which calls Docker). * Only meaningful when container=true.