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 2013/01/20 10:06:43 UTC
svn commit: r1435803 - 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/
axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/ axiom-testsuite...
Author: veithen
Date: Sun Jan 20 09:06:43 2013
New Revision: 1435803
URL: http://svn.apache.org/viewvc?rev=1435803&view=rev
Log:
Added a SOAPEnvelope#getOrCreateHeader method (which is more in line with what one usually wants to do).
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeader.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java
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/SOAPEnvelopeImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java?rev=1435803&r1=1435802&r2=1435803&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java Sun Jan 20 09:06:43 2013
@@ -35,6 +35,15 @@ public interface SOAPEnvelope extends OM
SOAPHeader getHeader();
/**
+ * Returns the existing {@link SOAPHeader} object for this envelope or creates a new one if
+ * there is none. Similarly to {@link #getHeader()}, this method avoids building the
+ * {@link SOAPBody}.
+ *
+ * @return the existing or newly created {@link SOAPHeader} object for this envelope
+ */
+ SOAPHeader getOrCreateHeader();
+
+ /**
* Returns the <CODE>SOAPBody</CODE> object associated with this <CODE>SOAPEnvelope</CODE>
* object. <P> This SOAPBody will just be a container for all the BodyElements in the
* <CODE>OMMessage</CODE> </P>
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=1435803&r1=1435802&r2=1435803&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 Sun Jan 20 09:06:43 2013
@@ -63,8 +63,14 @@ public interface SOAPFactory extends OMF
SOAPEnvelope createSOAPEnvelope(OMNamespace ns);
/**
+ * Create a {@link SOAPHeader} as a child of the given {@link SOAPEnvelope}.
+ * <p>
+ * Note that for most use cases, it is preferable to use
+ * {@link SOAPEnvelope#getOrCreateHeader()} instead of this method.
+ *
* @param envelope
- * @return Returns SOAPHeader.
+ * the parent of the {@link SOAPHeader}
+ * @return the newly created {@link SOAPHeader}
*/
SOAPHeader createSOAPHeader(SOAPEnvelope envelope) throws SOAPProcessingException;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java?rev=1435803&r1=1435802&r2=1435803&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java Sun Jan 20 09:06:43 2013
@@ -72,6 +72,11 @@ public class SOAPEnvelopeImpl extends SO
return (SOAPHeader) header;
}
+ public SOAPHeader getOrCreateHeader() {
+ SOAPHeader header = getHeader();
+ return header != null ? header : ((SOAPFactory)factory).createSOAPHeader(this);
+ }
+
/**
* Check that a node is allowed as a child of a SOAP envelope.
*
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?rev=1435803&r1=1435802&r2=1435803&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java Sun Jan 20 09:06:43 2013
@@ -88,6 +88,11 @@ public class SOAPEnvelopeImpl extends SO
return null;
}
+ public SOAPHeader getOrCreateHeader() {
+ SOAPHeader header = getHeader();
+ return header != null ? header : ((SOAPFactory)factory).createSOAPHeader(this);
+ }
+
/**
* Check that a node is allowed as a child of a SOAP envelope.
*
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1435803&r1=1435802&r2=1435803&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Sun Jan 20 09:06:43 2013
@@ -124,6 +124,8 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeader(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeaderWithParser(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeaderWithParserNoHeader(metaFactory, spec));
+ addTest(new org.apache.axiom.ts.soap.envelope.TestGetOrCreateHeader(metaFactory, spec));
+ addTest(new org.apache.axiom.ts.soap.envelope.TestGetOrCreateHeaderWithParserNoHeader(metaFactory, spec));
for (int i=0; i<generalQNames.length; i++) {
QName qname = generalQNames[i];
addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNS(metaFactory, spec, qname));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeader.java?rev=1435803&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeader.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeader.java Sun Jan 20 09:06:43 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.soap.envelope;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+public class TestGetOrCreateHeader extends SOAPTestCase {
+ public TestGetOrCreateHeader(OMMetaFactory metaFactory, SOAPSpec spec) {
+ super(metaFactory, spec);
+ }
+
+ protected void runTest() throws Throwable {
+ SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
+ SOAPHeader header = (SOAPHeader)envelope.getFirstOMChild();
+ assertSame(header, envelope.getOrCreateHeader());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeader.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java?rev=1435803&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java Sun Jan 20 09:06:43 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.soap.envelope;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests the behavior of {@link SOAPEnvelope#getOrCreateHeader()} on a message that has no header.
+ * It checks that the call creates a new {@link SOAPHeader} and that it doesn't build the
+ * {@link SOAPBody}.
+ */
+public class TestGetOrCreateHeaderWithParserNoHeader extends SOAPTestCase {
+ public TestGetOrCreateHeaderWithParserNoHeader(OMMetaFactory metaFactory, SOAPSpec spec) {
+ super(metaFactory, spec);
+ }
+
+ protected void runTest() throws Throwable {
+ SOAPEnvelope envelope = getTestMessage(MESSAGE_WITHOUT_HEADER);
+ SOAPHeader header = envelope.getOrCreateHeader();
+ assertNotNull(header);
+ assertSame(envelope.getFirstElement(), header);
+ assertFalse(envelope.getBody().isComplete());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java
------------------------------------------------------------------------------
svn:eol-style = native