poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1840386 - in /poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util: TestDocumentHelper.java TestSAXHelper.java
Date Sat, 08 Sep 2018 22:28:02 GMT
Author: fanningpj
Date: Sat Sep  8 22:28:02 2018
New Revision: 1840386

URL: http://svn.apache.org/viewvc?rev=1840386&view=rev
Log:
handle test issues when running with old xerces

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestSAXHelper.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java?rev=1840386&r1=1840385&r2=1840386&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java Sat Sep
 8 22:28:02 2018
@@ -37,8 +37,12 @@ public class TestDocumentHelper {
 
     @Test
     public void testDocumentBuilderFactory() throws Exception {
-        assertTrue(DocumentHelper.documentBuilderFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
-        assertFalse(DocumentHelper.documentBuilderFactory.getFeature(POIXMLConstants.FEATURE_LOAD_DTD_GRAMMAR));
-        assertFalse(DocumentHelper.documentBuilderFactory.getFeature(POIXMLConstants.FEATURE_LOAD_EXTERNAL_DTD));
+        try {
+            assertTrue(DocumentHelper.documentBuilderFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
+            assertFalse(DocumentHelper.documentBuilderFactory.getFeature(POIXMLConstants.FEATURE_LOAD_DTD_GRAMMAR));
+            assertFalse(DocumentHelper.documentBuilderFactory.getFeature(POIXMLConstants.FEATURE_LOAD_EXTERNAL_DTD));
+        } catch(AbstractMethodError e) {
+            // ignore exceptions from old parsers that don't support this API (https://bz.apache.org/bugzilla/show_bug.cgi?id=62692)
+        }
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestSAXHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestSAXHelper.java?rev=1840386&r1=1840385&r2=1840386&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestSAXHelper.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestSAXHelper.java Sat Sep  8
22:28:02 2018
@@ -24,6 +24,7 @@ import javax.xml.XMLConstants;
 
 import org.junit.Test;
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.XMLReader;
 
 public class TestSAXHelper {
@@ -31,14 +32,18 @@ public class TestSAXHelper {
     public void testXMLReader() throws Exception {
         XMLReader reader = SAXHelper.newXMLReader();
         assertNotSame(reader, SAXHelper.newXMLReader());
-        assertTrue(reader.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
-        assertFalse(reader.getFeature(POIXMLConstants.FEATURE_LOAD_DTD_GRAMMAR));
-        assertFalse(reader.getFeature(POIXMLConstants.FEATURE_LOAD_EXTERNAL_DTD));
-        assertEquals(SAXHelper.IGNORING_ENTITY_RESOLVER, reader.getEntityResolver());
-        assertNotNull(reader.getProperty(POIXMLConstants.PROPERTY_ENTITY_EXPANSION_LIMIT));
-        assertEquals("1", reader.getProperty(POIXMLConstants.PROPERTY_ENTITY_EXPANSION_LIMIT));
-        assertNotNull(reader.getProperty(POIXMLConstants.PROPERTY_SECURITY_MANAGER));
-
+        try {
+            assertTrue(reader.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
+            assertFalse(reader.getFeature(POIXMLConstants.FEATURE_LOAD_DTD_GRAMMAR));
+            assertFalse(reader.getFeature(POIXMLConstants.FEATURE_LOAD_EXTERNAL_DTD));
+            assertEquals(SAXHelper.IGNORING_ENTITY_RESOLVER, reader.getEntityResolver());
+            assertNotNull(reader.getProperty(POIXMLConstants.PROPERTY_ENTITY_EXPANSION_LIMIT));
+            assertEquals("1", reader.getProperty(POIXMLConstants.PROPERTY_ENTITY_EXPANSION_LIMIT));
+            assertNotNull(reader.getProperty(POIXMLConstants.PROPERTY_SECURITY_MANAGER));
+        } catch(SAXNotRecognizedException e) {
+            // ignore exceptions from old parsers that don't support these features
+            // (https://bz.apache.org/bugzilla/show_bug.cgi?id=62692)
+        }
         reader.parse(new InputSource(new ByteArrayInputStream("<xml></xml>".getBytes("UTF-8"))));
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message