From 69424be83d5494baad6da963623606ad735b7f5b Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Wed, 31 Jan 2024 14:53:21 -0600 Subject: [PATCH] Fix xml file processing --- .github/workflows/gradle.yml | 5 +++-- .../tools/gradle/BaseGenerateFeaturesTest.groovy | 14 ++++++++------ .../TestAppendServerEnvWithConfigServerEnv.groovy | 6 ------ .../gradle/TestAppendServerEnvWithNoProps.groovy | 6 ------ .../gradle/TestAppendServerEnvWithOnlyProps.groovy | 6 ------ .../gradle/TestAppendServerEnvWithProps.groovy | 6 ------ .../openliberty/tools/gradle/TestCompileJSP.groovy | 2 ++ .../tools/gradle/TestLooseApplication.groovy | 2 ++ .../gradle/TestLooseApplicationWithWarTask.groovy | 2 ++ .../tools/gradle/TestLooseEarApplication.groovy | 2 ++ .../gradle/TestLooseEarApplicationEarlibs.groovy | 2 ++ .../tools/gradle/TestLooseWarWithLooseJar.groovy | 2 ++ .../tools/gradle/TestMultiModuleLooseEar.groovy | 2 ++ .../tools/gradle/TestPluginConfigFile.groovy | 2 ++ .../gradle/VerifyLooseAppTestTimeoutSuccess.groovy | 2 ++ 15 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 128e0f351..6bfdc49da 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -39,7 +39,8 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: OpenLiberty/ci.common + repository: cherylking/ci.common + ref: fixXmlFileProcessing path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -124,7 +125,7 @@ jobs: - name: Clone ci.ant, ci.common, ci.gradle repos to C drive run: | cp -r D:/a/ci.gradle/ci.gradle C:/ci.gradle - git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common + git clone https://github.com/cherylking/ci.common.git --branch fixXmlFileProcessing --single-branch C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant # Cache mvn/gradle packages - name: Cache Maven packages diff --git a/src/test/groovy/io/openliberty/tools/gradle/BaseGenerateFeaturesTest.groovy b/src/test/groovy/io/openliberty/tools/gradle/BaseGenerateFeaturesTest.groovy index 38b512a71..b3f081ee7 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/BaseGenerateFeaturesTest.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/BaseGenerateFeaturesTest.groovy @@ -215,12 +215,14 @@ class BaseGenerateFeaturesTest extends AbstractIntegrationTest { } // read configuration xml file - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - docBuilderFactory.setIgnoringComments(true); - docBuilderFactory.setCoalescing(true); - docBuilderFactory.setIgnoringElementContentWhitespace(true); - docBuilderFactory.setValidating(false); - DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder(); + DocumentBuilderFactory inputBuilderFactory = DocumentBuilderFactory.newInstance(); + inputBuilderFactory.setIgnoringComments(true); + inputBuilderFactory.setCoalescing(true); + inputBuilderFactory.setIgnoringElementContentWhitespace(true); + inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + DocumentBuilder documentBuilder = inputBuilderFactory.newDocumentBuilder(); Document doc = documentBuilder.parse(configurationFile); XPath xPath = XPathFactory.newInstance().newXPath(); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithConfigServerEnv.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithConfigServerEnv.groovy index aeba92bb0..a5cb933fc 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithConfigServerEnv.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithConfigServerEnv.groovy @@ -4,12 +4,6 @@ import org.junit.AfterClass import org.junit.BeforeClass import org.junit.Test -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - import org.junit.BeforeClass import org.junit.FixMethodOrder import org.junit.Test diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithNoProps.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithNoProps.groovy index 86ce3683e..d5a351d63 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithNoProps.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithNoProps.groovy @@ -4,12 +4,6 @@ import org.junit.AfterClass import org.junit.BeforeClass import org.junit.Test -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - import java.io.BufferedReader; import java.io.FileReader; diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithOnlyProps.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithOnlyProps.groovy index 4e3475c66..4f35d0bf6 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithOnlyProps.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithOnlyProps.groovy @@ -4,12 +4,6 @@ import org.junit.AfterClass import org.junit.BeforeClass import org.junit.Test -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - import java.io.BufferedReader; import java.io.FileReader; diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithProps.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithProps.groovy index cf3c42aa2..e0cf93741 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithProps.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestAppendServerEnvWithProps.groovy @@ -4,12 +4,6 @@ import org.junit.AfterClass import org.junit.BeforeClass import org.junit.Test -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - import java.io.BufferedReader; import java.io.FileReader; diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestCompileJSP.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestCompileJSP.groovy index cf4e27934..7ee908908 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestCompileJSP.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestCompileJSP.groovy @@ -66,6 +66,8 @@ public class TestCompileJSP extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true) inputBuilderFactory.setIgnoringElementContentWhitespace(true) inputBuilderFactory.setValidating(false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder() Document inputDoc=inputBuilder.parse(input) diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplication.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplication.groovy index a98e3d8f6..57c683342 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplication.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplication.groovy @@ -67,6 +67,8 @@ public class TestLooseApplication extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplicationWithWarTask.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplicationWithWarTask.groovy index 2a284b742..579225591 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplicationWithWarTask.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestLooseApplicationWithWarTask.groovy @@ -66,6 +66,8 @@ public class TestLooseApplicationWithWarTask extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplication.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplication.groovy index 588d67870..e3fb593f7 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplication.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplication.groovy @@ -78,6 +78,8 @@ public class TestLooseEarApplication extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplicationEarlibs.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplicationEarlibs.groovy index e58168eaa..b20546e01 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplicationEarlibs.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestLooseEarApplicationEarlibs.groovy @@ -80,6 +80,8 @@ public class TestLooseEarApplicationEarlibs extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestLooseWarWithLooseJar.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestLooseWarWithLooseJar.groovy index cbb58ea55..c7e8eccb3 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestLooseWarWithLooseJar.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestLooseWarWithLooseJar.groovy @@ -68,6 +68,8 @@ public class TestLooseWarWithLooseJar extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestMultiModuleLooseEar.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestMultiModuleLooseEar.groovy index 9938f9539..6ec6196d0 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestMultiModuleLooseEar.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestMultiModuleLooseEar.groovy @@ -77,6 +77,8 @@ public class TestMultiModuleLooseEar extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/TestPluginConfigFile.groovy b/src/test/groovy/io/openliberty/tools/gradle/TestPluginConfigFile.groovy index 1365c985a..f6fb85dc3 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/TestPluginConfigFile.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/TestPluginConfigFile.groovy @@ -68,6 +68,8 @@ public class TestPluginConfigFile extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); diff --git a/src/test/groovy/io/openliberty/tools/gradle/VerifyLooseAppTestTimeoutSuccess.groovy b/src/test/groovy/io/openliberty/tools/gradle/VerifyLooseAppTestTimeoutSuccess.groovy index 26f5e8e9c..90ed6bb94 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/VerifyLooseAppTestTimeoutSuccess.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/VerifyLooseAppTestTimeoutSuccess.groovy @@ -66,6 +66,8 @@ public class VerifyLooseAppTestTimeoutSuccess extends AbstractIntegrationTest{ inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false) + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input);