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 2011/03/27 19:53:45 UTC
svn commit: r1085997 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/test/java/org/apache/axiom/om/impl/
axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/
axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/ axiom-testsuite/...
Author: veithen
Date: Sun Mar 27 17:53:44 2011
New Revision: 1085997
URL: http://svn.apache.org/viewvc?rev=1085997&view=rev
Log:
AXIOM-311: Refactored the existing OMStAXWrapper unit tests.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromElement.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromParser.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCommentEvent.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetElementText.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetNamespaceContext.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderNextTag.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderOnNonRootElement.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithOMSourcedElementDescendant.java (with props)
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperTestBase.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMStAXWrapperTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMStAXWrapperTest.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1085997&r1=1085996&r2=1085997&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Sun Mar 27 17:53:44 2011
@@ -23,6 +23,8 @@ import junit.framework.TestSuite;
import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
import org.apache.axiom.ts.OMTestSuiteBuilder;
+import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement;
+import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
import org.apache.axiom.ts.om.element.TestResolveQNameWithDefaultNamespace;
import org.apache.axiom.ts.om.element.TestResolveQNameWithoutNamespace;
import org.apache.axiom.ts.om.element.TestSetTextQName;
@@ -55,6 +57,12 @@ public class OMImplementationTest extend
// TODO: DOOM's behavior differs from LLOM's behavior in this case
builder.exclude(TestCreateOMElementFromQNameWithDefaultNamespace.class);
+ // DOOM doesn't support CDATA sections
+ builder.exclude(TestGetXMLStreamReaderCDATAEventFromElement.class);
+
+ // WSCOMMONS-453
+ builder.exclude(TestGetXMLStreamReaderWithOMSourcedElementDescendant.class);
+
return builder.build();
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java?rev=1085997&r1=1085996&r2=1085997&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java Sun Mar 27 17:53:44 2011
@@ -23,6 +23,7 @@ import junit.framework.TestSuite;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
import org.apache.axiom.ts.OMTestSuiteBuilder;
+import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
import org.apache.axiom.ts.om.element.TestResolveQNameWithDefaultNamespace;
import org.apache.axiom.ts.om.element.TestResolveQNameWithoutNamespace;
import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
@@ -42,6 +43,9 @@ public class OMImplementationTest extend
builder.exclude(TestInsertSiblingAfterOnChild.class);
builder.exclude(TestInsertSiblingBeforeOnChild.class);
+ // WSCOMMONS-453
+ builder.exclude(TestGetXMLStreamReaderWithOMSourcedElementDescendant.class);
+
return builder.build();
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1085997&r1=1085996&r2=1085997&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Sun Mar 27 17:53:44 2011
@@ -77,6 +77,16 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReader(metaFactory, conformanceFiles[i], true, true));
addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReader(metaFactory, conformanceFiles[i], false, true));
}
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromParser(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCommentEvent(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderGetElementText(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderGetNamespaceContext(metaFactory, true));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderGetNamespaceContext(metaFactory, false));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderNextTag(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderOnNonRootElement(metaFactory, true));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderOnNonRootElement(metaFactory, false));
+ addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestResolveQNameWithDefaultNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestResolveQNameWithNonDefaultNamespace(metaFactory));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromElement.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromElement.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromElement.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,58 @@
+/*
+ * 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.ts.om.element;
+
+import java.util.Arrays;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetXMLStreamReaderCDATAEventFromElement extends AxiomTestCase {
+ public TestGetXMLStreamReaderCDATAEventFromElement(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory omfactory = metaFactory.getOMFactory();
+ OMElement element = omfactory.createOMElement("test", null);
+ OMText cdata = omfactory.createOMText("hello world", OMNode.CDATA_SECTION_NODE);
+ element.addChild(cdata);
+
+ // Get the XMLStreamReader for the element. This will return an OMStAXWrapper.
+ XMLStreamReader reader2 = element.getXMLStreamReader();
+ // Check the sequence of events
+ int event = reader2.next();
+ assertEquals(XMLStreamReader.START_ELEMENT, event);
+
+ while (reader2.hasNext() && event != XMLStreamReader.CDATA) {
+ event = reader2.next();
+ }
+
+ assertEquals(XMLStreamReader.CDATA, event);
+ assertEquals("hello world", reader2.getText()); // WSCOMMONS-341
+ assertTrue(Arrays.equals("hello world".toCharArray(), reader2.getTextCharacters())); // WSCOMMONS-338
+ assertEquals(XMLStreamReader.END_ELEMENT, reader2.next());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromParser.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromParser.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.ts.om.element;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.StAXParserConfiguration;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
+
+// Regression test for WSCOMMONS-338 and WSCOMMONS-341
+public class TestGetXMLStreamReaderCDATAEventFromParser extends AxiomTestCase {
+ public TestGetXMLStreamReaderCDATAEventFromParser(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ // Create an element with a CDATA section.
+ InputStream is = new ByteArrayInputStream("<test><![CDATA[hello world]]></test>".getBytes());
+ // Make sure that the parser is non coalescing (otherwise no CDATA events will be
+ // reported). This is not the default for Woodstox (see WSTX-140).
+ XMLStreamReader reader = StAXUtils.createXMLStreamReader(StAXParserConfiguration.NON_COALESCING, is);
+
+ OMElement element = metaFactory.createStAXOMBuilder(metaFactory.getOMFactory(), reader).getDocumentElement();
+
+ // Build the element so we have a full StAX tree
+ element.build();
+
+ // Get the XMLStreamReader for the element. This will return an OMStAXWrapper.
+ XMLStreamReader reader2 = element.getXMLStreamReader();
+ // Check the sequence of events
+ int event = reader2.next();
+ assertEquals(XMLStreamReader.START_ELEMENT, event);
+
+ while (reader2.hasNext() && event != XMLStreamReader.CDATA) {
+ event = reader2.next();
+ }
+
+ // Only woodstox is guaranteed to generate CDATA events if javax.xml.stream.isCoalescing=false
+ if (reader.toString().indexOf("wstx")!=-1) {
+ assertEquals(XMLStreamReader.CDATA, event);
+ assertEquals("hello world", reader2.getText()); // WSCOMMONS-341
+ assertTrue(Arrays.equals("hello world".toCharArray(), reader2.getTextCharacters())); // WSCOMMONS-338
+ assertEquals(XMLStreamReader.END_ELEMENT, reader2.next());
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCDATAEventFromParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCommentEvent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCommentEvent.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCommentEvent.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCommentEvent.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.ts.om.element;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetXMLStreamReaderCommentEvent extends AxiomTestCase {
+ public TestGetXMLStreamReaderCommentEvent(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a><!--comment text--></a>");
+ XMLStreamReader reader = element.getXMLStreamReader();
+ assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+ assertEquals(XMLStreamReader.COMMENT, reader.next());
+ assertEquals("comment text", reader.getText());
+ assertEquals("comment text", new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()));
+ StringBuffer text = new StringBuffer();
+ char[] buf = new char[5];
+ for (int sourceStart = 0; ; sourceStart += buf.length) {
+ int nCopied = reader.getTextCharacters(sourceStart, buf, 0, buf.length);
+ text.append(buf, 0, nCopied);
+ if (nCopied < buf.length) {
+ break;
+ }
+ }
+ assertEquals("comment text", text.toString());
+ element.close(false);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderCommentEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetElementText.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetElementText.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetElementText.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetElementText.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,52 @@
+/*
+ * 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.ts.om.element;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetXMLStreamReaderGetElementText extends AxiomTestCase {
+ public TestGetXMLStreamReaderGetElementText(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+
+ OMNamespace namespace = factory.createOMNamespace("http://testuri.org", "test");
+ OMElement documentElement = factory.createOMElement("DocumentElement", namespace);
+ factory.createOMText(documentElement, "this is a TEXT");
+ factory.createOMComment(documentElement, "this is a comment");
+ factory.createOMText(documentElement, "this is a TEXT block 2");
+
+ XMLStreamReader xmlStreamReader = documentElement.getXMLStreamReader();
+ //move to the Start_Element
+ while (xmlStreamReader.getEventType() != XMLStreamReader.START_ELEMENT) {
+ xmlStreamReader.next();
+ }
+
+ String elementText = xmlStreamReader.getElementText();
+ assertEquals("this is a TEXTthis is a TEXT block 2", elementText);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetElementText.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetNamespaceContext.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetNamespaceContext.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetNamespaceContext.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetNamespaceContext.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.ts.om.element;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetXMLStreamReaderGetNamespaceContext extends AxiomTestCase {
+ private final boolean cache;
+
+ public TestGetXMLStreamReaderGetNamespaceContext(OMMetaFactory metaFactory, boolean cache) {
+ super(metaFactory);
+ this.cache = cache;
+ setName(getName() + " [cache=" + cache + "]");
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a xmlns='urn:ns1' xmlns:ns2='urn:ns2'><b xmlns:ns3='urn:ns3'/></a>");
+ XMLStreamReader stream = cache ? element.getXMLStreamReader()
+ : element.getXMLStreamReaderWithoutCaching();
+ stream.next();
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
+ assertEquals("b", stream.getLocalName());
+ NamespaceContext context = stream.getNamespaceContext();
+ assertEquals("urn:ns1", context.getNamespaceURI(""));
+ assertEquals("urn:ns2", context.getNamespaceURI("ns2"));
+ assertEquals("urn:ns3", context.getNamespaceURI("ns3"));
+ assertEquals("ns2", context.getPrefix("urn:ns2"));
+ element.close(false);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderGetNamespaceContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderNextTag.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderNextTag.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderNextTag.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderNextTag.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,48 @@
+/*
+ * 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.ts.om.element;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetXMLStreamReaderNextTag extends AxiomTestCase {
+ public TestGetXMLStreamReaderNextTag(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a> <b> </b> <?pi?> <!--comment--> <c/> </a>");
+ XMLStreamReader stream = element.getXMLStreamReaderWithoutCaching();
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
+ stream.nextTag();
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.getEventType());
+ assertEquals("b", stream.getLocalName());
+ stream.nextTag();
+ assertEquals(XMLStreamReader.END_ELEMENT, stream.getEventType());
+ stream.nextTag();
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.getEventType());
+ assertEquals("c", stream.getLocalName());
+ element.close(false);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderNextTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderOnNonRootElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderOnNonRootElement.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderOnNonRootElement.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderOnNonRootElement.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.ts.om.element;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetXMLStreamReaderOnNonRootElement extends AxiomTestCase {
+ private final boolean cache;
+
+ public TestGetXMLStreamReaderOnNonRootElement(OMMetaFactory metaFactory, boolean cache) {
+ super(metaFactory);
+ this.cache = cache;
+ setName(getName() + " [cache=" + cache + "]");
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement root = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a><b><c/></b></a>");
+ OMElement child = (OMElement)root.getFirstOMChild();
+ XMLStreamReader stream = cache ? child.getXMLStreamReader()
+ : child.getXMLStreamReaderWithoutCaching();
+ assertEquals(XMLStreamReader.START_DOCUMENT, stream.getEventType());
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
+ assertEquals("b", stream.getLocalName());
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
+ assertEquals("c", stream.getLocalName());
+ assertEquals(XMLStreamReader.END_ELEMENT, stream.next());
+ assertEquals(XMLStreamReader.END_ELEMENT, stream.next());
+ assertEquals(XMLStreamReader.END_DOCUMENT, stream.next());
+ root.close(false);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderOnNonRootElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithOMSourcedElementDescendant.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithOMSourcedElementDescendant.java?rev=1085997&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithOMSourcedElementDescendant.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithOMSourcedElementDescendant.java Sun Mar 27 17:53:44 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.ts.om.element;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.CharArrayDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+
+// Test for WSCOMMONS-453
+public class TestGetXMLStreamReaderWithOMSourcedElementDescendant extends AxiomTestCase {
+ public TestGetXMLStreamReaderWithOMSourcedElementDescendant(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory omFactory = metaFactory.getOMFactory();
+ OMDataSource ds = new CharArrayDataSource("<a>test</a>".toCharArray());
+ OMElement root = omFactory.createOMElement(new QName("root"));
+ OMSourcedElement child = omFactory.createOMElement(ds, "a", null);
+ root.addChild(child);
+ assertFalse(child.isExpanded());
+ XMLStreamReader stream = root.getXMLStreamReader();
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
+ assertEquals("root", stream.getLocalName());
+ assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
+ assertEquals(XMLStreamReader.CHARACTERS, stream.next());
+ assertEquals("test", stream.getText());
+ assertEquals(XMLStreamReader.END_ELEMENT, stream.next());
+ assertEquals(XMLStreamReader.END_ELEMENT, stream.next());
+ assertEquals(XMLStreamReader.END_DOCUMENT, stream.next());
+ assertFalse(child.isExpanded());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithOMSourcedElementDescendant.java
------------------------------------------------------------------------------
svn:eol-style = native