Author: veithen
Date: Wed Jul 9 22:52:30 2014
New Revision: 1609335
URL: http://svn.apache.org/r1609335
Log:
Added a SAAJ test case for the method that causes problems in the current Axis2
trunk.
Added:
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/TestSetParentElement.java
(with props)
Modified:
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJImplementation.java
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuiteBuilder.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java
Modified:
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJImplementation.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJImplementation.java?rev=1609335&r1=1609334&r2=1609335&view=diff
==============================================================================
---
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJImplementation.java
(original)
+++
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJImplementation.java
Wed Jul 9 22:52:30 2014
@@ -33,7 +33,7 @@ public final class SAAJImplementation {
try {
newMessageFactoryMethod =
SAAJMetaFactory.class.getDeclaredMethod("newMessageFactory", String.class);
newMessageFactoryMethod.setAccessible(true);
- newSOAPFactoryMethod =
SAAJMetaFactory.class.getDeclaredMethod("newMessageFactory", String.class);
+ newSOAPFactoryMethod =
SAAJMetaFactory.class.getDeclaredMethod("newSOAPFactory", String.class);
newSOAPFactoryMethod.setAccessible(true);
} catch (Exception ex) {
throw new Error(ex);
Modified:
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuiteBuilder.java?rev=1609335&r1=1609334&r2=1609335&view=diff
==============================================================================
---
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuiteBuilder.java
(original)
+++
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SAAJTestSuiteBuilder.java
Wed Jul 9 22:52:30 2014
@@ -19,6 +19,7 @@
package org.apache.axiom.ts.saaj;
import javax.xml.soap.SAAJMetaFactory;
+import javax.xml.soap.SOAPConstants;
import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
import org.apache.axiom.ts.soap.SOAPSpec;
@@ -36,5 +37,8 @@ public class SAAJTestSuiteBuilder extend
addTest(new
TestExamineMustUnderstandHeaderElements(saajImplementation, SOAPSpec.SOAP12,
false));
addTest(new
TestExamineMustUnderstandHeaderElements(saajImplementation, SOAPSpec.SOAP11,
true));
addTest(new
TestExamineMustUnderstandHeaderElements(saajImplementation, SOAPSpec.SOAP12,
true));
+ addTest(new TestSetParentElement(saajImplementation,
SOAPConstants.SOAP_1_1_PROTOCOL));
+ addTest(new TestSetParentElement(saajImplementation,
SOAPConstants.SOAP_1_2_PROTOCOL));
+ addTest(new TestSetParentElement(saajImplementation,
SOAPConstants.DYNAMIC_SOAP_PROTOCOL));
}
}
Added:
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/TestSetParentElement.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/TestSetParentElement.java?rev=1609335&view=auto
==============================================================================
---
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/TestSetParentElement.java
(added)
+++
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/TestSetParentElement.java
Wed Jul 9 22:52:30 2014
@@ -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.saaj;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPFactory;
+
+import org.w3c.dom.NodeList;
+
+public class TestSetParentElement extends SAAJTestCase {
+ private final String protocol;
+
+ public TestSetParentElement(SAAJImplementation saajImplementation, String
protocol) {
+ super(saajImplementation);
+ this.protocol = protocol;
+ addTestParameter("protocol", protocol);
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ SOAPFactory factory = saajImplementation.newSOAPFactory(protocol);
+ SOAPElement parent = factory.createElement(new QName("parent"));
+ SOAPElement child1 = parent.addChildElement(new QName("child1"));
+ SOAPElement child2 =
(SOAPElement)parent.getOwnerDocument().createElementNS(null, "child2");
+ child2.setParentElement(parent);
+ NodeList children = parent.getChildNodes();
+ assertEquals(2, children.getLength());
+ assertSame(child1, children.item(0));
+ assertSame(child2, children.item(1));
+ }
+}
Propchange:
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/TestSetParentElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java?rev=1609335&r1=1609334&r2=1609335&view=diff
==============================================================================
---
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java
(original)
+++
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java
Wed Jul 9 22:52:30 2014
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerFactory;
@@ -31,6 +32,7 @@ import javax.xml.transform.stream.Stream
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -81,6 +83,14 @@ final class ConvertedTestMessage extends
}
element = (Element)element.getOwnerDocument().renameNode(element,
newName.getNamespaceURI(),
prefix == null ? newName.getLocalPart() : prefix + ":" +
newName.getLocalPart());
+ NamedNodeMap attributes = element.getAttributes();
+ for (int i=0; i<attributes.getLength(); i++) {
+ Attr attr = (Attr)attributes.item(i);
+ if
(XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attr.getNamespaceURI())
+ &&
attr.getValue().equals(SOAPSpec.SOAP12.getEnvelopeNamespaceURI())) {
+ attr.setValue(SOAPSpec.SOAP11.getEnvelopeNamespaceURI());
+ }
+ }
if (type == SOAPElementType.HEADER) {
NodeList children = element.getChildNodes();
for (int i=0; i<children.getLength(); i++) {