This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-neethi.git


The following commit(s) were added to refs/heads/master by this push:
     new 42867c2  Improving XML processing in tests
42867c2 is described below

commit 42867c2e9a51e53d77e3f95332c929462ba859e9
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Tue Apr 21 13:31:36 2026 +0100

    Improving XML processing in tests
---
 src/test/java/org/apache/neethi/BasicTestCases.java           |  3 +++
 src/test/java/org/apache/neethi/PolicyTestCase.java           | 11 +++++++++--
 .../neethi/builders/converters/StaxToDOMConverterTest.java    |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/neethi/BasicTestCases.java 
b/src/test/java/org/apache/neethi/BasicTestCases.java
index e91596f..c11420d 100644
--- a/src/test/java/org/apache/neethi/BasicTestCases.java
+++ b/src/test/java/org/apache/neethi/BasicTestCases.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
 
+import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -133,6 +134,8 @@ public class BasicTestCases extends PolicyTestCase {
         throws ParserConfigurationException, SAXException, IOException {
         
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+        dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl";, 
true);
 
         dbf.setValidating(false);
         dbf.setIgnoringComments(false);
diff --git a/src/test/java/org/apache/neethi/PolicyTestCase.java 
b/src/test/java/org/apache/neethi/PolicyTestCase.java
index 846d9c1..f2cf94b 100644
--- a/src/test/java/org/apache/neethi/PolicyTestCase.java
+++ b/src/test/java/org/apache/neethi/PolicyTestCase.java
@@ -25,6 +25,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -81,6 +82,8 @@ public abstract class PolicyTestCase extends Assert {
         throws ParserConfigurationException, SAXException, IOException {
         InputStream in = getResource(name);
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+        dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl";, 
true);
 
         dbf.setValidating(false);
         dbf.setIgnoringComments(false);
@@ -100,14 +103,18 @@ public abstract class PolicyTestCase extends Assert {
     public XMLStreamReader getResourceAsStax(String name) 
         throws XMLStreamException, FactoryConfigurationError, 
FileNotFoundException {
         InputStream in = getResource(name);
-        return XMLInputFactory.newInstance().createXMLStreamReader(in);
+        XMLInputFactory xif = XMLInputFactory.newInstance();
+        xif.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+        return xif.createXMLStreamReader(in);
     }    
     public OMElement getResourceAsElement(String name) 
         throws XMLStreamException, FactoryConfigurationError, 
FileNotFoundException {
         InputStream in = getResource(name);
+        XMLInputFactory xif = XMLInputFactory.newInstance();
+        xif.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
         OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(
                 OMAbstractFactory.getOMFactory(),
-                
XMLInputFactory.newInstance().createXMLStreamReader(in)).getDocumentElement();
+                xif.createXMLStreamReader(in)).getDocumentElement();
         return element;
     }
 }
diff --git 
a/src/test/java/org/apache/neethi/builders/converters/StaxToDOMConverterTest.java
 
b/src/test/java/org/apache/neethi/builders/converters/StaxToDOMConverterTest.java
index 8c51e46..cc1231a 100644
--- 
a/src/test/java/org/apache/neethi/builders/converters/StaxToDOMConverterTest.java
+++ 
b/src/test/java/org/apache/neethi/builders/converters/StaxToDOMConverterTest.java
@@ -44,6 +44,7 @@ public class StaxToDOMConverterTest {
 
     private static XMLStreamReader readerFor(String xml) throws Exception {
         XMLInputFactory xif = XMLInputFactory.newInstance();
+        xif.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
         xif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
         return xif.createXMLStreamReader(new StringReader(xml));
     }

Reply via email to