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/10/16 00:44:02 UTC
svn commit: r1183752 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/
axiom-testsuite/src/main/java/org/apache/axiom/ts/
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/
Author: veithen
Date: Sat Oct 15 22:44:02 2011
New Revision: 1183752
URL: http://svn.apache.org/viewvc?rev=1183752&view=rev
Log:
Fixed AXIOM-393.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithoutCachingPartiallyBuilt.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.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-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java?rev=1183752&r1=1183751&r2=1183752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java Sat Oct 15 22:44:02 2011
@@ -1114,6 +1114,11 @@ class SwitchingWrapper extends AbstractX
/** Method updateCompleteStatus. */
private void updateCompleteStatus() {
+ if (currentEvent == START_ELEMENT) {
+ depth++;
+ } else if (currentEvent == END_ELEMENT) {
+ depth--;
+ }
if (state == NAVIGABLE) {
if (rootNode == currentNode) {
if (isFirst) {
@@ -1125,20 +1130,8 @@ class SwitchingWrapper extends AbstractX
}
}
} else {
- if (state == SWITCHED && rootNode instanceof OMElement) {
- //this is a potential place for bugs
- //we have to test if the root node of this parser
- //has the same name for this test
- if (currentEvent == START_ELEMENT &&
- (parser.getLocalName().equals(((OMElement)rootNode).getLocalName()))) {
- ++depth;
- } else if (currentEvent == END_ELEMENT &&
- (parser.getLocalName().equals(((OMElement)rootNode).getLocalName())) ) {
- --depth;
- if (depth < 0) {
- state = COMPLETED;
- }
- }
+ if (state == SWITCHED && currentEvent == END_ELEMENT && depth == 0 && rootNode instanceof OMElement) {
+ state = COMPLETED;
}
state = (currentEvent == END_DOCUMENT)
? DOCUMENT_COMPLETE
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=1183752&r1=1183751&r2=1183752&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 Sat Oct 15 22:44:02 2011
@@ -167,6 +167,7 @@ public class OMTestSuiteBuilder extends
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.TestGetXMLStreamReaderWithoutCachingPartiallyBuilt(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestMultipleDefaultNS(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestResolveQNameWithDefaultNamespace(metaFactory));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithoutCachingPartiallyBuilt.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithoutCachingPartiallyBuilt.java?rev=1183752&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithoutCachingPartiallyBuilt.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithoutCachingPartiallyBuilt.java Sat Oct 15 22:44:02 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.StringReader;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMContainer#getXMLStreamReaderWithoutCaching()} correctly generated events for
+ * an element that has been partially built. This is a regression test for AXIOM-393.
+ */
+public class TestGetXMLStreamReaderWithoutCachingPartiallyBuilt extends AxiomTestCase {
+ public TestGetXMLStreamReaderWithoutCachingPartiallyBuilt(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ // Note: the problem described in AXIOM-393 specifically occurred with descendants
+ // having the same name as the root element
+ OMElement root = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+ new StringReader("<element><element><element/><element/></element></element>")).getDocumentElement();
+
+ // Partially build the tree
+ root.getFirstElement().getFirstElement();
+
+ XMLStreamReader reader = root.getXMLStreamReaderWithoutCaching();
+ int depth = 0;
+ while (reader.hasNext()) {
+ int event = reader.next();
+ if (event == XMLStreamReader.START_ELEMENT) {
+ depth++;
+ } else if (event == XMLStreamReader.END_ELEMENT) {
+ depth--;
+ }
+ }
+ assertEquals(0, depth);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithoutCachingPartiallyBuilt.java
------------------------------------------------------------------------------
svn:eol-style = native