You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2014/06/17 09:54:46 UTC
svn commit: r1603086 - in /webservices/axiom/trunk/modules/axiom-api/src:
main/java/org/apache/axiom/util/sax/ test/java/org/apache/axiom/util/sax/
Author: veithen
Date: Tue Jun 17 07:54:46 2014
New Revision: 1603086
URL: http://svn.apache.org/r1603086
Log:
Fix broken feature support in AbstractXMLReader.
Added:
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/AbstractXMLReaderTest.java (with props)
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/TestGetSetFeature.java (with props)
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/ValidationTest.java (with props)
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/XMLReaderTestSuiteBuilder.java (with props)
Modified:
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/sax/AbstractXMLReader.java
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/sax/AbstractXMLReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/sax/AbstractXMLReader.java?rev=1603086&r1=1603085&r2=1603086&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/sax/AbstractXMLReader.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/sax/AbstractXMLReader.java Tue Jun 17 07:54:46 2014
@@ -35,10 +35,15 @@ import org.xml.sax.ext.LexicalHandler;
* the reader through protected attributes.
*/
public abstract class AbstractXMLReader implements XMLReader {
+ private static final String URI_NAMESPACES = "http://xml.org/sax/features/namespaces";
+ private static final String URI_NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
+ private static final String URI_EXTERNAL_GENERAL_ENTITIES = "http://xml.org/sax/features/external-general-entities";
+
private static final String URI_LEXICAL_HANDLER = "http://xml.org/sax/properties/lexical-handler";
protected boolean namespaces = true;
protected boolean namespacePrefixes = false;
+ protected boolean externalGeneralEntities = true;
protected ContentHandler contentHandler;
protected LexicalHandler lexicalHandler;
@@ -80,16 +85,26 @@ public abstract class AbstractXMLReader
public boolean getFeature(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
- throw new SAXNotRecognizedException(name);
+ if (URI_NAMESPACES.equals(name)) {
+ return namespaces;
+ } else if (URI_NAMESPACE_PREFIXES.equals(name)) {
+ return namespacePrefixes;
+ } else if (URI_EXTERNAL_GENERAL_ENTITIES.equals(name)) {
+ return externalGeneralEntities;
+ } else {
+ throw new SAXNotRecognizedException(name);
+ }
}
public void setFeature(String name, boolean value)
throws SAXNotRecognizedException, SAXNotSupportedException {
- if ("http://xml.org/sax/features/namespaces".equals(name)) {
+ if (URI_NAMESPACES.equals(name)) {
namespaces = value;
- } else if ("http://xml.org/sax/features/namespace-prefixes".equals(name)) {
+ } else if (URI_NAMESPACE_PREFIXES.equals(name)) {
namespacePrefixes = value;
+ } else if (URI_EXTERNAL_GENERAL_ENTITIES.equals(name)) {
+ externalGeneralEntities = value;
} else {
throw new SAXNotRecognizedException(name);
}
@@ -98,11 +113,7 @@ public abstract class AbstractXMLReader
public Object getProperty(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
- if ("http://xml.org/sax/features/namespaces".equals(name)) {
- return Boolean.valueOf(namespaces);
- } else if ("http://xml.org/sax/features/namespace-prefixes".equals(name)) {
- return Boolean.valueOf(namespacePrefixes);
- } else if (URI_LEXICAL_HANDLER.equals(name)) {
+ if (URI_LEXICAL_HANDLER.equals(name)) {
return lexicalHandler;
} else {
throw new SAXNotRecognizedException(name);
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/AbstractXMLReaderTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/AbstractXMLReaderTest.java?rev=1603086&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/AbstractXMLReaderTest.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/AbstractXMLReaderTest.java Tue Jun 17 07:54:46 2014
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.axiom.util.sax;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class AbstractXMLReaderTest extends TestCase {
+ public static TestSuite suite() throws Exception {
+ return new XMLReaderTestSuiteBuilder(new AbstractXMLReader() {
+ public void parse(String systemId) throws IOException, SAXException {
+ }
+
+ public void parse(InputSource input) throws IOException, SAXException {
+ }
+ }).build();
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/AbstractXMLReaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/TestGetSetFeature.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/TestGetSetFeature.java?rev=1603086&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/TestGetSetFeature.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/TestGetSetFeature.java Tue Jun 17 07:54:46 2014
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.axiom.util.sax;
+
+import org.apache.axiom.testutils.suite.MatrixTestCase;
+import org.xml.sax.XMLReader;
+
+public class TestGetSetFeature extends MatrixTestCase {
+ private final XMLReader xmlReader;
+ private final String feature;
+
+ public TestGetSetFeature(XMLReader xmlReader, String feature) {
+ this.xmlReader = xmlReader;
+ this.feature = feature;
+ addTestParameter("feature", feature);
+ }
+
+ protected void runTest() throws Throwable {
+ xmlReader.setFeature(feature, true);
+ assertTrue(xmlReader.getFeature(feature));
+ xmlReader.setFeature(feature, false);
+ assertFalse(xmlReader.getFeature(feature));
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/TestGetSetFeature.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/ValidationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/ValidationTest.java?rev=1603086&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/ValidationTest.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/ValidationTest.java Tue Jun 17 07:54:46 2014
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.axiom.util.sax;
+
+import javax.xml.parsers.SAXParserFactory;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class ValidationTest extends TestCase {
+ public static TestSuite suite() throws Exception {
+ return new XMLReaderTestSuiteBuilder(SAXParserFactory.newInstance().newSAXParser().getXMLReader()).build();
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/ValidationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/XMLReaderTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/XMLReaderTestSuiteBuilder.java?rev=1603086&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/XMLReaderTestSuiteBuilder.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/XMLReaderTestSuiteBuilder.java Tue Jun 17 07:54:46 2014
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.axiom.util.sax;
+
+import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
+import org.xml.sax.XMLReader;
+
+public class XMLReaderTestSuiteBuilder extends MatrixTestSuiteBuilder {
+ private final XMLReader xmlReader;
+
+ public XMLReaderTestSuiteBuilder(XMLReader xmlReader) {
+ this.xmlReader = xmlReader;
+ }
+
+ protected void addTests() {
+ addTest(new TestGetSetFeature(xmlReader, "http://xml.org/sax/features/namespaces"));
+ addTest(new TestGetSetFeature(xmlReader, "http://xml.org/sax/features/namespace-prefixes"));
+ addTest(new TestGetSetFeature(xmlReader, "http://xml.org/sax/features/external-general-entities"));
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/sax/XMLReaderTestSuiteBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native