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 2012/05/18 17:58:59 UTC
svn commit: r1340145 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/soap/
axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/
axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/ axiom-imp...
Author: veithen
Date: Fri May 18 15:58:58 2012
New Revision: 1340145
URL: http://svn.apache.org/viewvc?rev=1340145&view=rev
Log:
AXIOM-399:
* Ensure that OMSourcedElements with unknown name are cloned without expanding the original element.
* Also allow creating SOAPHeaderBlocks with unknown name.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCloneOMElementUnknownName.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
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-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java Fri May 18 15:58:58 2012
@@ -92,16 +92,34 @@ public interface SOAPFactory extends OMF
OMNamespace ns) throws SOAPProcessingException;
/**
- * Create SOAPHeaderBlock that has an OMDataSource
+ * Create a {@link SOAPHeaderBlock} from an {@link OMDataSource}. The semantics of the method
+ * parameters are the same as for {@link OMFactory#createOMElement(OMDataSource)}.
+ *
+ * @param source
+ * the data source; must not be <code>null</code>
+ * @return the newly created header block
+ */
+ SOAPHeaderBlock createSOAPHeaderBlock(OMDataSource source);
+
+ /**
+ * Create a {@link SOAPHeaderBlock} from an {@link OMDataSource} with a known local name and
+ * namespace URI. The semantics of the method parameters are the same as for
+ * {@link OMFactory#createOMElement(OMDataSource, String, OMNamespace)}.
+ *
* @param localName
+ * the local part of the name of the element produced by the data source; must not be
+ * <code>null</code>
* @param ns
- * @param ds
- * @return SOAPHeaderBlock
+ * the namespace of the element produced by the data source, or <code>null</code> if
+ * the element has no namespace
+ * @param source
+ * the data source; must not be <code>null</code>
+ * @return the newly created header block
* @throws SOAPProcessingException
*/
SOAPHeaderBlock createSOAPHeaderBlock(String localName,
OMNamespace ns,
- OMDataSource ds) throws SOAPProcessingException;
+ OMDataSource source) throws SOAPProcessingException;
/**
* @param localName
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java Fri May 18 15:58:58 2012
@@ -132,6 +132,10 @@ public abstract class DOMSOAPFactory ext
throw new UnsupportedOperationException("TODO");
}
+ public SOAPHeaderBlock createSOAPHeaderBlock(OMDataSource source) {
+ throw new UnsupportedOperationException("TODO");
+ }
+
public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMDataSource ds) throws SOAPProcessingException {
throw new UnsupportedOperationException("TODO");
}
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=1340145&r1=1340144&r2=1340145&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 Fri May 18 15:58:58 2012
@@ -690,14 +690,21 @@ public class OMSourcedElementImpl extend
return super.clone(options, targetParent);
}
// Otherwise create a target OMSE with the copied DataSource
- OMSourcedElement targetOMSE;
+ OMSourcedElementImpl targetOMSE;
if (options.isPreserveModel()) {
- targetOMSE = createClone(options, targetDS, getLocalName(), getNamespace());
+ targetOMSE = (OMSourcedElementImpl)createClone(options, targetDS);
} else {
- targetOMSE = factory.createOMElement(targetDS,
- getLocalName(),
- getNamespace());
+ targetOMSE = (OMSourcedElementImpl)factory.createOMElement(targetDS);
}
+
+ targetOMSE.localName = localName;
+ targetOMSE.definedNamespaceSet = definedNamespaceSet;
+ if (definedNamespace instanceof DeferredNamespace) {
+ targetOMSE.definedNamespace = targetOMSE.new DeferredNamespace(definedNamespace.getNamespaceURI());
+ } else {
+ targetOMSE.definedNamespace = definedNamespace;
+ }
+
if (targetParent != null) {
targetParent.addChild(targetOMSE);
}
@@ -708,8 +715,8 @@ public class OMSourcedElementImpl extend
return super.createClone(options, targetParent);
}
- protected OMSourcedElement createClone(OMCloneOptions options, OMDataSource ds, String localName, OMNamespace ns) {
- return factory.createOMElement(ds, localName, ns);
+ protected OMSourcedElement createClone(OMCloneOptions options, OMDataSource ds) {
+ return factory.createOMElement(ds);
}
public void setLineNumber(int lineNumber) {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java Fri May 18 15:58:58 2012
@@ -51,6 +51,10 @@ public abstract class SOAPHeaderBlockImp
super(localName, ns, factory);
}
+ public SOAPHeaderBlockImpl(SOAPFactory factory, OMDataSource source) {
+ super(factory, source);
+ }
+
public SOAPHeaderBlockImpl(String localName, OMNamespace ns, SOAPFactory factory,
OMDataSource ds) {
super(localName, ns, factory, ds);
@@ -171,8 +175,8 @@ public abstract class SOAPHeaderBlockImp
return clone;
}
- protected OMSourcedElement createClone(OMCloneOptions options, OMDataSource ds, String localName, OMNamespace ns) {
- SOAPHeaderBlock clone = ((SOAPFactory)factory).createSOAPHeaderBlock(localName, ns, ds);
+ protected OMSourcedElement createClone(OMCloneOptions options, OMDataSource ds) {
+ SOAPHeaderBlock clone = ((SOAPFactory)factory).createSOAPHeaderBlock(ds);
copyData(options, clone);
return clone;
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java Fri May 18 15:58:58 2012
@@ -108,6 +108,10 @@ public class SOAP11Factory extends OMLin
return new SOAP11HeaderBlockImpl(localName, ns, this);
}
+ public SOAPHeaderBlock createSOAPHeaderBlock(OMDataSource source) {
+ return new SOAP11HeaderBlockImpl(this, source);
+ }
+
public SOAPHeaderBlock createSOAPHeaderBlock(String localName,
OMNamespace ns,
OMDataSource ds)
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java Fri May 18 15:58:58 2012
@@ -39,6 +39,10 @@ public class SOAP11HeaderBlockImpl exten
super(localName, ns, factory);
}
+ public SOAP11HeaderBlockImpl(SOAPFactory factory, OMDataSource source) {
+ super(factory, source);
+ }
+
public SOAP11HeaderBlockImpl(String localName, OMNamespace ns,
SOAPFactory factory,
OMDataSource ds) {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java Fri May 18 15:58:58 2012
@@ -170,6 +170,10 @@ public class SOAP12Factory extends OMLin
return new SOAP12FaultValueImpl(parent, builder, this);
}
+ public SOAPHeaderBlock createSOAPHeaderBlock(OMDataSource source) {
+ return new SOAP12HeaderBlockImpl(this, source);
+ }
+
public SOAPHeaderBlock createSOAPHeaderBlock(String localName,
OMNamespace ns) throws SOAPProcessingException {
return new SOAP12HeaderBlockImpl(localName, ns, this);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java Fri May 18 15:58:58 2012
@@ -39,6 +39,10 @@ public class SOAP12HeaderBlockImpl exten
super(localName, ns, factory);
}
+ public SOAP12HeaderBlockImpl(SOAPFactory factory, OMDataSource source) {
+ super(factory, source);
+ }
+
public SOAP12HeaderBlockImpl(String localName, OMNamespace ns,
SOAPFactory factory, OMDataSource ds) {
super(localName, ns, factory, ds);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1340145&r1=1340144&r2=1340145&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Fri May 18 15:58:58 2012
@@ -351,6 +351,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.sourcedelement.TestCharArrayDS(metaFactory));
addTest(new org.apache.axiom.ts.om.sourcedelement.TestCloneOMElementNonDestructive(metaFactory, true));
addTest(new org.apache.axiom.ts.om.sourcedelement.TestCloneOMElementNonDestructive(metaFactory, false));
+ addTest(new org.apache.axiom.ts.om.sourcedelement.TestCloneOMElementUnknownName(metaFactory));
addTest(new org.apache.axiom.ts.om.sourcedelement.TestComplete(metaFactory));
addTest(new org.apache.axiom.ts.om.sourcedelement.TestExpand(metaFactory));
addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceNormalized(metaFactory));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCloneOMElementUnknownName.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCloneOMElementUnknownName.java?rev=1340145&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCloneOMElementUnknownName.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCloneOMElementUnknownName.java Fri May 18 15:58:58 2012
@@ -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.sourcedelement;
+
+import org.apache.axiom.om.OMCloneOptions;
+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.OMNamespace;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.ByteArrayDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {@link OMElement#cloneOMElement(OMCloneOptions)} on an
+ * {@link OMSourcedElement} backed by a non destructive {@link OMDataSource} if the name of the
+ * element is unknown and the {@link OMCloneOptions#setCopyOMDataSources(boolean)} option is
+ * enabled. In this case, the call to {@link OMElement#cloneOMElement(OMCloneOptions)} should
+ * not cause expansion of the original {@link OMSourcedElement}.
+ */
+public class TestCloneOMElementUnknownName extends AxiomTestCase {
+ public TestCloneOMElementUnknownName(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMDataSource ds = new ByteArrayDataSource("<p:element xmlns:p='urn:ns'>test</p:element>".getBytes("utf-8"), "utf-8");
+ OMSourcedElement element = factory.createOMElement(ds);
+ OMCloneOptions options = new OMCloneOptions();
+ options.setCopyOMDataSources(true);
+ OMElement clone = element.cloneOMElement(options);
+ assertTrue(clone instanceof OMSourcedElement);
+ assertFalse(element.isExpanded());
+ OMNamespace expectedNS = factory.createOMNamespace("urn:ns", "p");
+ assertEquals("element", element.getLocalName());
+ assertEquals("element", clone.getLocalName());
+ assertEquals(expectedNS, element.getNamespace());
+ assertEquals(expectedNS, clone.getNamespace());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCloneOMElementUnknownName.java
------------------------------------------------------------------------------
svn:eol-style = native