set entity expansion limit to 2048 due to failing tests
git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/trunk@1838325 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/common/org/apache/xmlbeans/impl/common/Sax2Dom.java b/src/common/org/apache/xmlbeans/impl/common/Sax2Dom.java
index 989eafc..d985e25 100644
--- a/src/common/org/apache/xmlbeans/impl/common/Sax2Dom.java
+++ b/src/common/org/apache/xmlbeans/impl/common/Sax2Dom.java
@@ -48,7 +48,7 @@
public Sax2Dom() throws ParserConfigurationException
{
- _document = DocumentHelper.newDocumentBuilder().newDocument();
+ _document = DocumentHelper.createDocument();
_root = _document;
}
@@ -65,7 +65,7 @@
}
else
{
- _document = DocumentHelper.newDocumentBuilder().newDocument();
+ _document = DocumentHelper.createDocument();
_root = _document;
}
}
diff --git a/src/common/org/apache/xmlbeans/impl/common/XMLBeansConstants.java b/src/common/org/apache/xmlbeans/impl/common/XMLBeansConstants.java
index ed49cb2..5eaacbb 100644
--- a/src/common/org/apache/xmlbeans/impl/common/XMLBeansConstants.java
+++ b/src/common/org/apache/xmlbeans/impl/common/XMLBeansConstants.java
@@ -19,19 +19,19 @@
public static final String PROPERTY_ENTITY_EXPANSION_LIMIT = "xmlbeans.entity.expansion.limit";
public static final String PROPERTY_LOAD_DTD_GRAMMAR = "xmlbeans.load.dtd.grammar";
public static final String PROPERTY_LOAD_EXTERNAL_DTD = "xmlbeans.load.external.dtd";
- public static final int DEFAULT_ENTITY_EXPANSION_LIMIT = 1;
+ public static final int DEFAULT_ENTITY_EXPANSION_LIMIT = 2048;
public static final String XML_PROPERTY_ENTITY_EXPANSION_LIMIT = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit";
public static final String XML_PROPERTY_SECURITY_MANAGER = "http://apache.org/xml/properties/security-manager";
public static final String FEATURE_LOAD_DTD_GRAMMAR = "http://apache.org/xml/features/nonvalidating/load-dtd-grammar";
public static final String FEATURE_LOAD_EXTERNAL_DTD = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
- static int getEntityExpansionLimit() {
+ public static int getEntityExpansionLimit() {
return Integer.getInteger(PROPERTY_ENTITY_EXPANSION_LIMIT, DEFAULT_ENTITY_EXPANSION_LIMIT);
}
- static boolean isLoadDtdGrammar() {
+ public static boolean isLoadDtdGrammar() {
return Boolean.getBoolean(PROPERTY_LOAD_DTD_GRAMMAR);
}
- static boolean isLoadExternalDtd() {
+ public static boolean isLoadExternalDtd() {
return Boolean.getBoolean(PROPERTY_LOAD_EXTERNAL_DTD);
}
}
diff --git a/test/src/dom/checkin/ParserTest.java b/test/src/dom/checkin/ParserTest.java
new file mode 100755
index 0000000..c3a3e9d
--- /dev/null
+++ b/test/src/dom/checkin/ParserTest.java
@@ -0,0 +1,72 @@
+/* Copyright 2018 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package dom.checkin;
+
+import javax.xml.stream.XMLInputFactory;
+
+import junit.framework.*;
+
+import org.apache.xmlbeans.impl.common.*;
+
+/**
+ * Tests for XML Parser settings
+ */
+
+public class ParserTest extends TestCase {
+
+ public void testXMLBeansConstantsDefaults() {
+ assertEquals(2048, XMLBeansConstants.getEntityExpansionLimit());
+ assertFalse(XMLBeansConstants.isLoadDtdGrammar());
+ assertFalse(XMLBeansConstants.isLoadExternalDtd());
+ }
+
+ public void testXMLBeansConstantsOverrides() {
+ try {
+ System.setProperty(XMLBeansConstants.PROPERTY_ENTITY_EXPANSION_LIMIT, "1");
+ System.setProperty(XMLBeansConstants.PROPERTY_LOAD_DTD_GRAMMAR, "true");
+ System.setProperty(XMLBeansConstants.PROPERTY_LOAD_EXTERNAL_DTD, "true");
+ assertEquals(1, XMLBeansConstants.getEntityExpansionLimit());
+ assertTrue(XMLBeansConstants.isLoadDtdGrammar());
+ assertTrue(XMLBeansConstants.isLoadExternalDtd());
+ } finally {
+ System.clearProperty(XMLBeansConstants.PROPERTY_ENTITY_EXPANSION_LIMIT);
+ System.clearProperty(XMLBeansConstants.PROPERTY_LOAD_DTD_GRAMMAR);
+ System.clearProperty(XMLBeansConstants.PROPERTY_LOAD_EXTERNAL_DTD);
+ }
+ }
+
+ public void testXmlInputFactoryPropertyDefaults() {
+ XMLInputFactory factory = StaxHelper.newXMLInputFactory();
+ assertEquals(true, factory.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE));
+ assertEquals(false, factory.getProperty(XMLInputFactory.IS_VALIDATING));
+ assertEquals(false, factory.getProperty(XMLInputFactory.SUPPORT_DTD));
+ assertEquals(false, factory.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES));
+ }
+
+ public void testXmlInputFactoryPropertyOverrides() {
+ try {
+ System.setProperty(XMLBeansConstants.PROPERTY_LOAD_DTD_GRAMMAR, "true");
+ System.setProperty(XMLBeansConstants.PROPERTY_LOAD_EXTERNAL_DTD, "true");
+ XMLInputFactory factory = StaxHelper.newXMLInputFactory();
+ assertEquals(true, factory.getProperty(XMLInputFactory.SUPPORT_DTD));
+ assertEquals(true, factory.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES));
+ } finally {
+ System.clearProperty(XMLBeansConstants.PROPERTY_LOAD_DTD_GRAMMAR);
+ System.clearProperty(XMLBeansConstants.PROPERTY_LOAD_EXTERNAL_DTD);
+ }
+ }
+}