Author: ningjiang
Date: Thu Apr 7 13:15:35 2011
New Revision: 1089871
URL: http://svn.apache.org/viewvc?rev=1089871&view=rev
Log:
CXF-3445 Support the faultStackTraceEnabled option in
Soap12FaultOutputInterceptor
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
(with props)
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java
(with props)
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java
(with props)
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java
(with props)
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
(with props)
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java
(with props)
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java?rev=1089871&r1=1089870&r2=1089871&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java Thu Apr
7 13:15:35 2011
@@ -36,7 +36,7 @@ import org.apache.cxf.helpers.DOMUtils;
public class Fault extends UncheckedException {
public static final QName FAULT_CODE_CLIENT = new
QName("http://cxf.apache.org/faultcode", "client");
public static final QName FAULT_CODE_SERVER = new
QName("http://cxf.apache.org/faultcode", "server");
-
+ public static final String STACKTRACE_NAMESPACE =
"http://cxf.apache.org/fault";
public static final String STACKTRACE = "stackTrace";
private Element detail;
private String message;
Modified:
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java?rev=1089871&r1=1089870&r2=1089871&view=diff
==============================================================================
---
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
(original)
+++
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
Thu Apr 7 13:15:35 2011
@@ -27,7 +27,13 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.staxutils.StaxUtils;
@@ -64,5 +70,35 @@ public abstract class AbstractSoapInterc
prefix = StaxUtils.getUniquePrefix(writer, codeNs, true);
}
return prefix;
- }
+ }
+
+ protected void prepareStackTrace(SoapMessage message, SoapFault fault)
throws Exception {
+ String config = (String)message
+
.getContextualProperty(org.apache.cxf.message.Message.FAULT_STACKTRACE_ENABLED);
+ if (config != null && Boolean.valueOf(config).booleanValue() &&
fault.getCause() != null) {
+ StringBuilder sb = new StringBuilder();
+ for (StackTraceElement ste : fault.getCause().getStackTrace()) {
+ sb.append(ste.getClassName() + "!" + ste.getMethodName() + "!"
+ ste.getFileName() + "!"
+ + ste.getLineNumber() + "\n");
+ }
+ Element detail = fault.getDetail();
+ String soapNamespace = message.getVersion().getNamespace();
+ if (detail == null) {
+ Document doc = XMLUtils.newDocument();
+ Element stackTrace = doc.createElementNS(
+ Fault.STACKTRACE_NAMESPACE, Fault.STACKTRACE);
+ stackTrace.setTextContent(sb.toString());
+ detail = doc.createElementNS(
+ soapNamespace, "detail");
+ fault.setDetail(detail);
+ detail.appendChild(stackTrace);
+ } else {
+ Element stackTrace =
+
detail.getOwnerDocument().createElementNS(Fault.STACKTRACE_NAMESPACE,
+
Fault.STACKTRACE);
+ stackTrace.setTextContent(sb.toString());
+ detail.appendChild(stackTrace);
+ }
+ }
+ }
}
Modified:
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java?rev=1089871&r1=1089870&r2=1089871&view=diff
==============================================================================
---
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
(original)
+++
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
Thu Apr 7 13:15:35 2011
@@ -25,15 +25,12 @@ import java.util.logging.Logger;
import javax.xml.stream.XMLStreamWriter;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.apache.cxf.binding.soap.Soap11;
import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.staxutils.StaxUtils;
@@ -92,29 +89,7 @@ public class Soap11FaultOutInterceptor e
writer.writeCharacters("Fault occurred while processing.");
}
writer.writeEndElement();
- String config = (String)message.getContextualProperty(
-
org.apache.cxf.message.Message.FAULT_STACKTRACE_ENABLED);
- if (config != null && Boolean.valueOf(config).booleanValue()
&& fault.getCause() != null) {
- StringBuilder sb = new StringBuilder();
- for (StackTraceElement ste :
fault.getCause().getStackTrace()) {
- sb.append(ste.getClassName() + "!" +
ste.getMethodName() + "!" + ste.getFileName()
- + "!" + ste.getLineNumber() + "\n");
- }
- Element detail = fault.getDetail();
- if (detail == null) {
- Document doc = XMLUtils.newDocument();
- Element stackTrace =
doc.createElementNS(Soap11.SOAP_NAMESPACE, Fault.STACKTRACE);
- stackTrace.setTextContent(sb.toString());
- detail = doc.createElementNS(Soap11.SOAP_NAMESPACE,
"detail");
- fault.setDetail(detail);
- detail.appendChild(stackTrace);
- } else {
- Element stackTrace =
detail.getOwnerDocument().createElementNS(
- Soap11.SOAP_NAMESPACE, Fault.STACKTRACE);
- stackTrace.setTextContent(sb.toString());
- detail.appendChild(stackTrace);
- }
- }
+ prepareStackTrace(message, fault);
if (fault.hasDetails()) {
Element detail = fault.getDetail();
Modified:
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java?rev=1089871&r1=1089870&r2=1089871&view=diff
==============================================================================
---
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
(original)
+++
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
Thu Apr 7 13:15:35 2011
@@ -112,6 +112,8 @@ public class Soap12FaultOutInterceptor e
writer.writeEndElement();
writer.writeEndElement();
+ prepareStackTrace(message, fault);
+
if (fault.hasDetails()) {
Element detail = fault.getDetail();
writer.writeStartElement(defaultPrefix, "Detail", ns);
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java?rev=1089871&r1=1089870&r2=1089871&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
Thu Apr 7 13:15:35 2011
@@ -235,7 +235,8 @@ public class ClientFaultConverter extend
private void setStackTrace(Fault fault, Message msg) {
Map<String, String> ns = new HashMap<String, String>();
XPathUtils xu = new XPathUtils(ns);
- String ss = (String) xu.getValue("/" + Fault.STACKTRACE + "/text()",
fault.getDetail(),
+ ns.put("s", Fault.STACKTRACE_NAMESPACE);
+ String ss = (String) xu.getValue("//s:" + Fault.STACKTRACE +
"/text()", fault.getDetail(),
XPathConstants.STRING);
List<StackTraceElement> stackTraceList = new
ArrayList<StackTraceElement>();
if (!StringUtils.isEmpty(ss)) {
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java?rev=1089871&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
Thu Apr 7 13:15:35 2011
@@ -0,0 +1,96 @@
+/**
+ * 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.cxf.systest.soapfault.details;
+
+import java.util.concurrent.Future;
+import java.util.logging.Logger;
+
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.greeter_control.types.FaultDetail;
+import org.apache.cxf.greeter_control.types.GreetMeResponse;
+import org.apache.cxf.greeter_control.types.PingMeResponse;
+import org.apache.cxf.greeter_control.types.SayHiResponse;
+import org.apache.cxf.interceptor.Fault;
+
+
+@WebService(serviceName = "GreeterService",
+ portName = "GreeterPort",
+ endpointInterface = "org.apache.cxf.greeter_control.Greeter",
+ targetNamespace = "http://cxf.apache.org/greeter_control")
+public class GreeterImpl11 {
+ private static final Logger LOG = LogUtils.getLogger(GreeterImpl11.class);
+
+ public String greetMe(String me) {
+ return "Hello " + me;
+ }
+
+ public String sayHi() {
+ // throw the exception out
+ Exception cause = new IllegalArgumentException("Get a wrong name
<sayHi>");
+ throw new Fault("sayHiFault", LOG, cause);
+ }
+
+ public void greetMeOneWay(String requestType) {
+ System.out.println("********* greetMeOneWay: " + requestType);
+ }
+
+ public void pingMe() throws PingMeFault {
+ FaultDetail faultDetail = new FaultDetail();
+ faultDetail.setMajor((short)2);
+ faultDetail.setMinor((short)1);
+ LOG.info("Executing operation pingMe, throwing PingMeFault exception");
+ System.out.println("Executing operation pingMe, throwing PingMeFault
exception\n");
+ throw new PingMeFault("PingMeFault raised by server", faultDetail);
+ }
+
+ public Future<?> greetMeAsync(String requestType,
AsyncHandler<GreetMeResponse> asyncHandler) {
+ return null;
+ /*not called */
+ }
+
+ public Response<GreetMeResponse> greetMeAsync(String requestType) {
+ return null;
+ /*not called */
+ }
+
+ public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
+ return null;
+ /*not called */
+ }
+
+ public Response<SayHiResponse> sayHiAsync() {
+ return null;
+ /*not called */
+ }
+
+ public Response<PingMeResponse> pingMeAsync() {
+ return null;
+ }
+
+ public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> asyncHandler) {
+ return null;
+ }
+
+}
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl11.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java?rev=1089871&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java
Thu Apr 7 13:15:35 2011
@@ -0,0 +1,56 @@
+/**
+ * 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.cxf.systest.soapfault.details;
+
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.hello_world_soap12_http.Greeter;
+import org.apache.hello_world_soap12_http.PingMeFault;
+import org.apache.hello_world_soap12_http.types.FaultDetail;
+
[email protected](portName = "SoapPort", serviceName = "SOAPService",
+ targetNamespace =
"http://apache.org/hello_world_soap12_http",
+ endpointInterface =
"org.apache.hello_world_soap12_http.Greeter",
+ wsdlLocation = "testutils/hello_world_soap12.wsdl")
+
+public class GreeterImpl12 implements Greeter {
+
+ private static final Logger LOG = LogUtils.getLogger(GreeterImpl12.class);
+
+ /* (non-Javadoc)
+ * @see org.apache.hello_world_soap12_http.Greeter#sayHi()
+ */
+ public String sayHi() {
+ // throw the exception out
+ Exception cause = new IllegalArgumentException("Get a wrong name
<sayHi>");
+ throw new Fault("sayHiFault", LOG, cause);
+ }
+
+ public void pingMe() throws PingMeFault {
+ FaultDetail faultDetail = new FaultDetail();
+ faultDetail.setMajor((short)2);
+ faultDetail.setMinor((short)1);
+ LOG.info("Executing operation pingMe, throwing PingMeFault exception");
+ System.out.println("Executing operation pingMe, throwing PingMeFault
exception\n");
+ throw new PingMeFault("PingMeFault raised by server", faultDetail);
+ }
+}
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/GreeterImpl12.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java?rev=1089871&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java
Thu Apr 7 13:15:35 2011
@@ -0,0 +1,59 @@
+/**
+ * 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.cxf.systest.soapfault.details;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server11 extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(Server11.class);
+
+
+ protected void run() {
+ Object implementor = new GreeterImpl11();
+ String address = "http://localhost:"
+ + PORT + "/SoapContext/GreeterPort";
+ // enable the options of stack trace and the exception cause message
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put("exceptionMessageCauseEnabled", "true");
+ properties.put("faultStackTraceEnabled", "true");
+ JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+ factory.setAddress(address);
+ factory.setServiceBean(implementor);
+ factory.setProperties(properties);
+ factory.create();
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ Server11 s = new Server11();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server11.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java?rev=1089871&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java
Thu Apr 7 13:15:35 2011
@@ -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.cxf.systest.soapfault.details;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server12 extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(Server12.class);
+
+
+ protected void run() {
+ Object implementor = new GreeterImpl12();
+ String address = "http://localhost:" + PORT + "/SoapContext/SoapPort";
+ // enable the options of stack trace and the exception cause message
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put("exceptionMessageCauseEnabled", "true");
+ properties.put("faultStackTraceEnabled", "true");
+ JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+ factory.setAddress(address);
+ factory.setServiceBean(implementor);
+ factory.setProperties(properties);
+ factory.create();
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ Server12 s = new Server12();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Server12.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java?rev=1089871&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
Thu Apr 7 13:15:35 2011
@@ -0,0 +1,87 @@
+/**
+ * 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.cxf.systest.soapfault.details;
+
+
+import java.net.MalformedURLException;
+
+import javax.xml.ws.soap.SOAPFaultException;
+
+
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.GreeterService;
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.greeter_control.types.FaultDetail;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Soap11ClientServerTest extends AbstractBusClientServerTestBase {
+ static final String PORT = allocatePort(Server11.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
+ launchServer(Server11.class));
+ }
+
+ @Test
+ public void testFaultMessage() throws Exception {
+ Greeter greeter = getGreeter();
+ try {
+ greeter.sayHi();
+ fail("Should throw Exception!");
+ } catch (SOAPFaultException ex) {
+ assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>",
ex.getMessage());
+ StackTraceElement[] element = ex.getCause().getStackTrace();
+
assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",
element[0].getClassName());
+ }
+ }
+
+
+ @Test
+ public void testPingMeFault() throws Exception {
+ Greeter greeter = getGreeter();
+ try {
+ greeter.pingMe();
+ fail("Should throw Exception!");
+ } catch (PingMeFault ex) {
+ FaultDetail detail = ex.getFaultInfo();
+ assertEquals((short)2, detail.getMajor());
+ assertEquals((short)1, detail.getMinor());
+ assertEquals("PingMeFault raised by server", ex.getMessage());
+ StackTraceElement[] element = ex.getStackTrace();
+ // The stack trace will be reset as it's a declare exception
+ assertEquals("org.apache.cxf.jaxws.JaxWsClientProxy",
element[0].getClassName());
+ }
+ }
+
+
+ private Greeter getGreeter() throws NumberFormatException,
MalformedURLException {
+ GreeterService service = new GreeterService();
+ assertNotNull(service);
+ Greeter greeter = service.getGreeterPort();
+ updateAddressPort(greeter, PORT);
+ return greeter;
+ }
+
+}
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap11ClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java?rev=1089871&view=auto
==============================================================================
---
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java
(added)
+++
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java
Thu Apr 7 13:15:35 2011
@@ -0,0 +1,95 @@
+/**
+ * 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.cxf.systest.soapfault.details;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.hello_world_soap12_http.Greeter;
+import org.apache.hello_world_soap12_http.PingMeFault;
+import org.apache.hello_world_soap12_http.SOAPService;
+import org.apache.hello_world_soap12_http.types.FaultDetail;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Soap12ClientServerTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = Server12.PORT;
+
+ private final QName serviceName = new
QName("http://apache.org/hello_world_soap12_http",
+ "SOAPService");
+ private final QName portName = new
QName("http://apache.org/hello_world_soap12_http", "SoapPort");
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
launchServer(Server12.class));
+ }
+
+ @Test
+ public void testFaultMessage() throws Exception {
+ Greeter greeter = getGreeter();
+ try {
+ greeter.sayHi();
+ fail("Should throw Exception!");
+ } catch (SOAPFaultException ex) {
+ assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>",
ex.getMessage());
+ StackTraceElement[] element = ex.getCause().getStackTrace();
+
assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl12",
element[0].getClassName());
+ }
+ }
+
+ @Test
+ public void testPingMeFault() throws Exception {
+ Greeter greeter = getGreeter();
+ try {
+ greeter.pingMe();
+ fail("Should throw Exception!");
+ } catch (PingMeFault ex) {
+ FaultDetail detail = ex.getFaultInfo();
+ assertEquals((short)2, detail.getMajor());
+ assertEquals((short)1, detail.getMinor());
+ assertEquals("PingMeFault raised by server", ex.getMessage());
+ StackTraceElement[] element = ex.getStackTrace();
+ // The stack trace will be reset as it's a declare exception
+ assertEquals("org.apache.cxf.jaxws.JaxWsClientProxy",
element[0].getClassName());
+ }
+ }
+
+
+ private Greeter getGreeter() throws NumberFormatException,
MalformedURLException {
+ URL wsdl = getClass().getResource("/wsdl/hello_world_soap12.wsdl");
+ assertNotNull("WSDL is null", wsdl);
+
+ SOAPService service = new SOAPService(wsdl, serviceName);
+ assertNotNull("Service is ull ", service);
+
+ Greeter g = service.getPort(portName, Greeter.class);
+ updateAddressPort(g, PORT);
+ return g;
+ }
+
+}
+
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/details/Soap12ClientServerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date