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/26 19:04:14 UTC
svn commit: r1438929 - in /webservices/axiom/trunk/modules:
axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/ axiom-t...
Author: veithen
Date: Sat Jan 26 18:04:14 2013
New Revision: 1438929
URL: http://svn.apache.org/viewvc?rev=1438929&view=rev
Log:
Corrected a problem with the initial fix for AXIOM-392.
Modified:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementHelper.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/SOAPFaultChild.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/fault/TestChildOrder.java
Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementHelper.java?rev=1438929&r1=1438928&r2=1438929&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementHelper.java (original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementHelper.java Sat Jan 26 18:04:14 2013
@@ -174,7 +174,7 @@ public class OMElementHelper {
}
// isAfter indicates if the new child should be inserted after the current child
boolean isAfter = false;
- for (int i=0; i<pos-1; i++) {
+ for (int i=0; i<pos; i++) {
if (sequence[i].isInstance(child)) {
isAfter = true;
break;
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1438929&r1=1438928&r2=1438929&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Sat Jan 26 18:04:14 2013
@@ -164,7 +164,11 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.factory.TestGetMetaFactory(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.factory.TestGetNamespace(metaFactory, spec));
for (int i=0; i<serializationStrategies.length; i++) {
- addTest(new org.apache.axiom.ts.soap.fault.TestChildOrder(metaFactory, spec, serializationStrategies[i]));
+ SerializationStrategy ss = serializationStrategies[i];
+ addTest(new org.apache.axiom.ts.soap.fault.TestChildOrder(metaFactory, spec,
+ new SOAPFaultChild[] { SOAPFaultChild.REASON, SOAPFaultChild.CODE }, ss));
+ addTest(new org.apache.axiom.ts.soap.fault.TestChildOrder(metaFactory, spec,
+ new SOAPFaultChild[] { SOAPFaultChild.CODE, SOAPFaultChild.REASON, SOAPFaultChild.DETAIL, SOAPFaultChild.REASON }, ss));
}
addTest(new org.apache.axiom.ts.soap.fault.TestGetCode(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.fault.TestGetCodeWithParser(metaFactory, spec));
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/SOAPFaultChild.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/SOAPFaultChild.java?rev=1438929&r1=1438928&r2=1438929&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/SOAPFaultChild.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/SOAPFaultChild.java Sat Jan 26 18:04:14 2013
@@ -23,12 +23,20 @@ import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.soap.SOAPFaultReason;
+import org.apache.axiom.soap.SOAPFaultRole;
import org.apache.axiom.ts.AxiomTestCase;
import org.apache.axiom.ts.soap.SOAPSpec;
import org.apache.axiom.ts.strategy.Strategy;
public interface SOAPFaultChild extends Strategy {
SOAPFaultChild CODE = new SOAPFaultChild() {
+ public Class getType() {
+ return SOAPFaultCode.class;
+ }
+
public void addTestProperties(AxiomTestCase testCase) {
testCase.addTestProperty("type", "SOAPFaultCode");
}
@@ -37,6 +45,10 @@ public interface SOAPFaultChild extends
return spec.getFaultCodeQName();
}
+ public int getOrder() {
+ return 1;
+ }
+
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultCode();
}
@@ -44,9 +56,17 @@ public interface SOAPFaultChild extends
public OMElement create(SOAPFactory factory, SOAPFault parent) {
return factory.createSOAPFaultCode(parent);
}
+
+ public void set(SOAPFault fault, OMElement element) {
+ fault.setCode((SOAPFaultCode)element);
+ }
};
SOAPFaultChild REASON = new SOAPFaultChild() {
+ public Class getType() {
+ return SOAPFaultReason.class;
+ }
+
public void addTestProperties(AxiomTestCase testCase) {
testCase.addTestProperty("type", "SOAPFaultReason");
}
@@ -55,6 +75,10 @@ public interface SOAPFaultChild extends
return spec.getFaultReasonQName();
}
+ public int getOrder() {
+ return 2;
+ }
+
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultReason();
}
@@ -62,9 +86,17 @@ public interface SOAPFaultChild extends
public OMElement create(SOAPFactory factory, SOAPFault parent) {
return factory.createSOAPFaultReason(parent);
}
+
+ public void set(SOAPFault fault, OMElement element) {
+ fault.setReason((SOAPFaultReason)element);
+ }
};
SOAPFaultChild ROLE = new SOAPFaultChild() {
+ public Class getType() {
+ return SOAPFaultRole.class;
+ }
+
public void addTestProperties(AxiomTestCase testCase) {
testCase.addTestProperty("type", "SOAPFaultRole");
}
@@ -73,6 +105,10 @@ public interface SOAPFaultChild extends
return spec.getFaultRoleQName();
}
+ public int getOrder() {
+ return 3;
+ }
+
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultRole();
}
@@ -80,9 +116,17 @@ public interface SOAPFaultChild extends
public OMElement create(SOAPFactory factory, SOAPFault parent) {
return factory.createSOAPFaultRole(parent);
}
+
+ public void set(SOAPFault fault, OMElement element) {
+ fault.setRole((SOAPFaultRole)element);
+ }
};
SOAPFaultChild DETAIL = new SOAPFaultChild() {
+ public Class getType() {
+ return SOAPFaultDetail.class;
+ }
+
public void addTestProperties(AxiomTestCase testCase) {
testCase.addTestProperty("type", "SOAPFaultDetail");
}
@@ -91,6 +135,10 @@ public interface SOAPFaultChild extends
return spec.getFaultDetailQName();
}
+ public int getOrder() {
+ return 4;
+ }
+
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultDetail();
}
@@ -98,9 +146,16 @@ public interface SOAPFaultChild extends
public OMElement create(SOAPFactory factory, SOAPFault parent) {
return factory.createSOAPFaultDetail(parent);
}
+
+ public void set(SOAPFault fault, OMElement element) {
+ fault.setDetail((SOAPFaultDetail)element);
+ }
};
+ Class getType();
QName getQName(SOAPSpec spec);
+ int getOrder();
OMElement create(SOAPFactory factory);
OMElement create(SOAPFactory factory, SOAPFault parent);
+ void set(SOAPFault fault, OMElement element);
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/fault/TestChildOrder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/fault/TestChildOrder.java?rev=1438929&r1=1438928&r2=1438929&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/fault/TestChildOrder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/fault/TestChildOrder.java Sat Jan 26 18:04:14 2013
@@ -18,7 +18,12 @@
*/
package org.apache.axiom.ts.soap.fault;
-import javax.xml.namespace.QName;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.axiom.om.OMMetaFactory;
@@ -27,10 +32,11 @@ import org.apache.axiom.soap.SOAPFaultCo
import org.apache.axiom.soap.SOAPFaultReason;
import org.apache.axiom.ts.soap.SOAPSpec;
import org.apache.axiom.ts.soap.SOAPTestCase;
+import org.apache.axiom.ts.soap.factory.SOAPFaultChild;
import org.apache.axiom.ts.strategy.serialization.SerializationStrategy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
/**
* Tests that the children added using methods such as {@link SOAPFault#setCode(SOAPFaultCode)} and
@@ -40,31 +46,51 @@ import org.w3c.dom.NodeList;
* Regression test for <a href="https://issues.apache.org/jira/browse/AXIOM-392">AXIOM-392</a>.
*/
public class TestChildOrder extends SOAPTestCase {
+ private final SOAPFaultChild[] inputOrder;
private final SerializationStrategy serializationStrategy;
- public TestChildOrder(OMMetaFactory metaFactory, SOAPSpec spec, SerializationStrategy serializationStrategy) {
+ public TestChildOrder(OMMetaFactory metaFactory, SOAPSpec spec, SOAPFaultChild[] inputOrder, SerializationStrategy serializationStrategy) {
super(metaFactory, spec);
+ this.inputOrder = inputOrder;
this.serializationStrategy = serializationStrategy;
+ StringBuilder buffer = new StringBuilder();
+ for (int i=0; i<inputOrder.length; i++) {
+ if (i>0) {
+ buffer.append(',');
+ }
+ buffer.append(inputOrder[i].getType().getSimpleName());
+ }
+ addTestProperty("inputOrder", buffer.toString());
serializationStrategy.addTestProperties(this);
}
protected void runTest() throws Throwable {
SOAPFault fault = soapFactory.createSOAPFault();
- // Add fault code and reason in the "wrong" order
- SOAPFaultReason reason = soapFactory.createSOAPFaultReason();
- reason.setText("Invalid credentials");
- fault.setReason(reason);
- SOAPFaultCode code = soapFactory.createSOAPFaultCode();
- code.setText(new QName(soapFactory.getNamespace().getNamespaceURI(), "Client"));
- fault.setCode(code);
+ // Add the elements in the specified order.
+ for (int i=0; i<inputOrder.length; i++) {
+ SOAPFaultChild type = inputOrder[i];
+ type.set(fault, type.create(soapFactory));
+ }
+ // Calculate the order in which we expect to see the children. Note that a given type
+ // may be added multiple times. Therefore we need to use a Set.
+ SortedSet outputOrder = new TreeSet(new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((SOAPFaultChild)o1).getOrder() - ((SOAPFaultChild)o2).getOrder();
+ }
+ });
+ outputOrder.addAll(Arrays.asList(inputOrder));
+ // Check the result using the given serialization strategy
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
- // Check the result using the given serialization strategy
Document document = dbf.newDocumentBuilder().parse(serializationStrategy.serialize(fault).getInputSource());
Element domFault = document.getDocumentElement();
- NodeList children = domFault.getChildNodes();
- assertEquals(2, children.getLength());
- assertEquals(spec.getFaultCodeQName().getLocalPart(), children.item(0).getLocalName());
- assertEquals(spec.getFaultReasonQName().getLocalPart(), children.item(1).getLocalName());
+ Node child = domFault.getFirstChild();
+ for (Iterator it = outputOrder.iterator(); it.hasNext(); ) {
+ SOAPFaultChild type = (SOAPFaultChild)it.next();
+ assertNotNull(child);
+ assertEquals(type.getQName(spec).getLocalPart(), child.getLocalName());
+ child = child.getNextSibling();
+ }
+ assertNull(child);
}
}