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 2015/05/31 11:34:23 UTC
svn commit: r1682703 - in /webservices/axiom/trunk/testing:
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultcode/
soap-testsuite/src/main/java/org/apache/axiom/ts/soap/
Author: veithen
Date: Sun May 31 09:34:23 2015
New Revision: 1682703
URL: http://svn.apache.org/r1682703
Log:
Use correct fault codes in SOAP 1.1 samples.
Added:
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java (with props)
Modified:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultcode/TestGetValueAsQNameWithParser.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultcode/TestGetValueAsQNameWithParser.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultcode/TestGetValueAsQNameWithParser.java?rev=1682703&r1=1682702&r2=1682703&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultcode/TestGetValueAsQNameWithParser.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultcode/TestGetValueAsQNameWithParser.java Sun May 31 09:34:23 2015
@@ -18,8 +18,6 @@
*/
package org.apache.axiom.ts.soap.faultcode;
-import javax.xml.namespace.QName;
-
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.soap.SOAPFaultClassifier;
import org.apache.axiom.soap.SOAPFaultCode;
@@ -38,6 +36,6 @@ public class TestGetValueAsQNameWithPars
protected void runTest() throws Throwable {
SOAPFaultCode faultCode = SOAPSampleSet.SIMPLE_FAULT.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getSOAPEnvelope(metaFactory).getBody().getFault().getCode();
- assertEquals(new QName(spec.getEnvelopeNamespaceURI(), "Receiver"), faultCode.getValueAsQName());
+ assertEquals(spec.getReceiverFaultCode(), faultCode.getValueAsQName());
}
}
Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java?rev=1682703&r1=1682702&r2=1682703&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java Sun May 31 09:34:23 2015
@@ -20,6 +20,8 @@ package org.apache.axiom.ts.soap;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -37,6 +39,17 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
final class ConvertedSOAPSampleContent extends ComputedMessageContent {
+ private static Map<String,String> faultCodeMap = new HashMap<String,String>();
+
+ static {
+ faultCodeMap.put(
+ SOAPSpec.SOAP12.getSenderFaultCode().getLocalPart(),
+ SOAPSpec.SOAP11.getSenderFaultCode().getLocalPart());
+ faultCodeMap.put(
+ SOAPSpec.SOAP12.getReceiverFaultCode().getLocalPart(),
+ SOAPSpec.SOAP11.getReceiverFaultCode().getLocalPart());
+ }
+
private final SOAPSample soap12Message;
ConvertedSOAPSampleContent(SOAPSample soap12Message) {
@@ -91,9 +104,25 @@ final class ConvertedSOAPSampleContent e
}
}
} else if (type == SOAPFaultChild.CODE) {
- Element value = getChild(element, SOAPFaultChild.VALUE);
- // TODO: should translate fault code as well
- element.setTextContent(value.getTextContent());
+ final Element value = getChild(element, SOAPFaultChild.VALUE);
+ element.setTextContent(transform(value.getTextContent(), new TextTransformer() {
+ @Override
+ public String transform(String in) {
+ int idx = in.indexOf(':');
+ if (idx == -1) {
+ return in;
+ }
+ String prefix = in.substring(0, idx);
+ if (!SOAPSpec.SOAP12.getEnvelopeNamespaceURI().equals(value.lookupNamespaceURI(prefix))) {
+ return in;
+ }
+ String newCode = faultCodeMap.get(in.substring(idx+1));
+ if (newCode == null) {
+ return in;
+ }
+ return prefix + ":" + newCode;
+ }
+ }));
} else if (type == SOAPFaultChild.REASON) {
Element text = getChild(element, SOAPFaultChild.TEXT);
element.setTextContent(text.getTextContent());
@@ -160,4 +189,24 @@ final class ConvertedSOAPSampleContent e
}
return null;
}
+
+ private static boolean isWhitespace(char c) {
+ return " \r\n\t".indexOf(c) != -1;
+ }
+
+ private static String transform(String text, TextTransformer transformer) {
+ int start = 0;
+ while (isWhitespace(text.charAt(start))) {
+ if (++start == text.length()) {
+ return text;
+ }
+ }
+ int end = text.length();
+ while (isWhitespace(text.charAt(end-1))) {
+ end--;
+ }
+ return text.substring(0, start)
+ + transformer.transform(text.substring(start, end))
+ + text.substring(end);
+ }
}
Added: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java?rev=1682703&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java (added)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java Sun May 31 09:34:23 2015
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+interface TextTransformer {
+ String transform(String in);
+}
Propchange: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native