You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2010/09/30 14:29:02 UTC
svn commit: r1003037 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src:
main/java/org/apache/axiom/util/stax/dialect/
test/java/org/apache/axiom/util/stax/dialect/
Author: veithen
Date: Thu Sep 30 12:29:02 2010
New Revision: 1003037
URL: http://svn.apache.org/viewvc?rev=1003037&view=rev
Log:
Improved compatibility with Woodstox 4.0.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetAttributeNamespaceWithNoPrefixTestCase.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespacePrefixDefaultNamespaceTestCase.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespaceURIWithNullNamespaceTestCase.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/WoodstoxStreamReaderWrapper.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/WoodstoxStreamReaderWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/WoodstoxStreamReaderWrapper.java?rev=1003037&r1=1003036&r2=1003037&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/WoodstoxStreamReaderWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/WoodstoxStreamReaderWrapper.java Thu Sep 30 12:29:02 2010
@@ -82,6 +82,30 @@ class WoodstoxStreamReaderWrapper extend
return prefix == null || prefix.length() == 0 ? null : prefix;
}
+ public String getNamespaceURI() {
+ // Woodstox 4.0 may return "" instead of null
+ String uri = super.getNamespaceURI();
+ return uri == null || uri.length() == 0 ? null : uri;
+ }
+
+ public String getNamespaceURI(String prefix) {
+ // Woodstox 4.0 may return "" instead of null
+ String uri = super.getNamespaceURI(prefix);
+ return uri == null || uri.length() == 0 ? null : uri;
+ }
+
+ public String getNamespacePrefix(int index) {
+ // Woodstox 4.0 may return "" instead of null
+ String prefix = super.getNamespacePrefix(index);
+ return prefix == null || prefix.length() == 0 ? null : prefix;
+ }
+
+ public String getAttributeNamespace(int index) {
+ // Woodstox 4.0 may return "" instead of null
+ String uri = super.getAttributeNamespace(index);
+ return uri == null || uri.length() == 0 ? null : uri;
+ }
+
public XMLStreamReader getParent() {
return super.getParent();
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java?rev=1003037&r1=1003036&r2=1003037&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java Thu Sep 30 12:29:02 2010
@@ -47,6 +47,7 @@ public class DialectTest extends TestSui
addDialectTest(new DisallowDoctypeDeclWithExternalSubsetTestCase());
addDialectTest(new DisallowDoctypeDeclWithInternalSubsetTestCase());
addDialectTest(new EnableCDataReportingTestCase());
+ addDialectTest(new GetAttributeNamespaceWithNoPrefixTestCase());
addDialectTest(new GetCharacterEncodingSchemeTestCase());
addDialectTest(new GetEncodingExternalTestCase());
addDialectTest(new GetEncodingFromDetectionTestCase("UTF-8", "UTF-8"));
@@ -91,6 +92,7 @@ public class DialectTest extends TestSui
for (int i=0; i<conformanceTestFiles.length; i++) {
addDialectTest(new GetNamespaceContextTestCase(conformanceTestFiles[i]));
}
+ addDialectTest(new GetNamespacePrefixDefaultNamespaceTestCase());
addDialectTest(new GetNamespaceURIIllegalStateExceptionTestCase(XMLStreamConstants.START_ELEMENT, false));
addDialectTest(new GetNamespaceURIIllegalStateExceptionTestCase(XMLStreamConstants.END_ELEMENT, false));
addDialectTest(new GetNamespaceURIIllegalStateExceptionTestCase(XMLStreamConstants.PROCESSING_INSTRUCTION, true));
@@ -102,6 +104,7 @@ public class DialectTest extends TestSui
addDialectTest(new GetNamespaceURIIllegalStateExceptionTestCase(XMLStreamConstants.ENTITY_REFERENCE, true));
addDialectTest(new GetNamespaceURIIllegalStateExceptionTestCase(XMLStreamConstants.DTD, true));
addDialectTest(new GetNamespaceURIIllegalStateExceptionTestCase(XMLStreamConstants.CDATA, true));
+ addDialectTest(new GetNamespaceURIWithNullNamespaceTestCase());
addDialectTest(new GetPrefixIllegalStateExceptionTestCase(XMLStreamConstants.START_ELEMENT, false));
addDialectTest(new GetPrefixIllegalStateExceptionTestCase(XMLStreamConstants.END_ELEMENT, false));
addDialectTest(new GetPrefixIllegalStateExceptionTestCase(XMLStreamConstants.PROCESSING_INSTRUCTION, true));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetAttributeNamespaceWithNoPrefixTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetAttributeNamespaceWithNoPrefixTestCase.java?rev=1003037&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetAttributeNamespaceWithNoPrefixTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetAttributeNamespaceWithNoPrefixTestCase.java Thu Sep 30 12:29:02 2010
@@ -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.stax.dialect;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class GetAttributeNamespaceWithNoPrefixTestCase extends DialectTestCase {
+ protected void runTest() throws Throwable {
+ XMLInputFactory factory = newNormalizedXMLInputFactory();
+ XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(
+ "<root attr=\"test\"><child xmlns=\"urn:ns\" attr=\"test\"/></root>"));
+ int eventType;
+ while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
+ if (eventType == XMLStreamReader.START_ELEMENT) {
+ for (int i=0; i<reader.getAttributeCount(); i++) {
+ assertNull(reader.getAttributeNamespace(i));
+ }
+ }
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetAttributeNamespaceWithNoPrefixTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespacePrefixDefaultNamespaceTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespacePrefixDefaultNamespaceTestCase.java?rev=1003037&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespacePrefixDefaultNamespaceTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespacePrefixDefaultNamespaceTestCase.java Thu Sep 30 12:29:02 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.stax.dialect;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class GetNamespacePrefixDefaultNamespaceTestCase extends DialectTestCase {
+ protected void runTest() throws Throwable {
+ XMLInputFactory factory = newNormalizedXMLInputFactory();
+ XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(
+ "<root xmlns=\"urn:ns\"/>"));
+ reader.next();
+ assertNull(reader.getNamespacePrefix(0));
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespacePrefixDefaultNamespaceTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespaceURIWithNullNamespaceTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespaceURIWithNullNamespaceTestCase.java?rev=1003037&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespaceURIWithNullNamespaceTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespaceURIWithNullNamespaceTestCase.java Thu Sep 30 12:29:02 2010
@@ -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.stax.dialect;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class GetNamespaceURIWithNullNamespaceTestCase extends DialectTestCase {
+ protected void runTest() throws Throwable {
+ XMLInputFactory factory = newNormalizedXMLInputFactory();
+ XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(
+ "<root><child xmlns=\"\"/></root>"));
+ int eventType;
+ while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
+ if (eventType == XMLStreamReader.START_ELEMENT) {
+ assertNull(reader.getNamespaceURI());
+ assertNull(reader.getNamespaceURI(""));
+ }
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/GetNamespaceURIWithNullNamespaceTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native