Author: veithen Date: Tue Dec 16 03:37:36 2008 New Revision: 727025 URL: http://svn.apache.org/viewvc?rev=727025&view=rev Log: Fixed a problem in OMSourcedElementImpl#setDataSource which didn't discard the builder when setting a new data source on an already expanded element. This caused troubles in getNextOMSibling(). Also added a test case for this.
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=727025&r1=727024&r2=727025&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Tue Dec 16 03:37:36 2008 @@ -1060,6 +1060,7 @@ this.dataSource = dataSource; setComplete(false); isExpanded = false; + super.setBuilder(null); if (isLossyPrefix(dataSource)) { // Create a deferred namespace that forces an expand to get the prefix definedNamespace = new DeferredNamespace(definedNamespace.getNamespaceURI()); Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java?rev=727025&r1=727024&r2=727025&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java Tue Dec 16 03:37:36 2008 @@ -1037,6 +1037,18 @@ child.getAttributeValue(new QName("type"))); } + public void testSetDataSourceOnAlreadyExpandedElement() { + // Make sure the OMSourcedElement is expanded + element.getFirstOMChild(); + assertTrue(element.isExpanded()); + // Now set a new data source + element.setDataSource(new TestDataSource(testDocument2)); + assertFalse(element.isExpanded()); + // getNextOMSibling should not expand the element + assertNull(element.getNextOMSibling()); + assertFalse(element.isExpanded()); + } + private static class TestDataSource implements OMDataSource { // The data source is a ByteArrayInputStream so that we can verify that the datasource // is only accessed once. Currently there is no way to identify a destructive vs. non-destructive OMDataSource.