You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/03/14 03:19:01 UTC
svn commit: r636956 - in /activemq/camel/trunk/components/camel-cxf/src:
main/java/org/apache/camel/component/cxf/
main/java/org/apache/camel/component/cxf/interceptors/
test/java/org/apache/camel/component/cxf/
Author: ningjiang
Date: Thu Mar 13 19:19:00 2008
New Revision: 636956
URL: http://svn.apache.org/viewvc?rev=636956&view=rev
Log:
CAMEL-384 patch applied with thanks to Marc
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadCustomizedExceptionTest.java
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java?rev=636956&r1=636955&r2=636956&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java Thu Mar 13 19:19:00 2008
@@ -166,7 +166,11 @@
Object result = null;
if (cxfExchange.isFailed()) {
Exception ex= (Exception)cxfExchange.getFault().getBody();
- throw new Fault(ex);
+ if (ex instanceof Fault ) {
+ throw (Fault)ex;
+ } else {
+ throw new Fault(ex);
+ }
} else {
result = cxfExchange.getOut().getBody();
}
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java?rev=636956&r1=636955&r2=636956&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java Thu Mar 13 19:19:00 2008
@@ -40,7 +40,11 @@
// check the fault from the message
Exception ex = message.getContent(Exception.class);
if (ex != null) {
- throw new Fault(ex);
+ if (ex instanceof Fault ) {
+ throw (Fault)ex;
+ } else {
+ throw new Fault(ex);
+ }
}
XMLStreamWriter out = message.getContent(XMLStreamWriter.class);
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java?rev=636956&r1=636955&r2=636956&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/RawMessageContentRedirectInterceptor.java Thu Mar 13 19:19:00 2008
@@ -34,7 +34,11 @@
// check the fault from the message
Exception ex = message.getContent(Exception.class);
if (ex != null) {
- throw new Fault(ex);
+ if (ex instanceof Fault ) {
+ throw (Fault)ex;
+ } else {
+ throw new Fault(ex);
+ }
}
InputStream is = message.getContent(InputStream.class);
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java?rev=636956&r1=636955&r2=636956&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java Thu Mar 13 19:19:00 2008
@@ -16,6 +16,10 @@
*/
package org.apache.camel.component.cxf;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
import org.apache.camel.CamelContext;
import org.apache.camel.CamelException;
import org.apache.camel.ContextTestSupport;
@@ -26,18 +30,20 @@
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.endpoint.ServerImpl;
import org.apache.cxf.frontend.ClientFactoryBean;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
public class CxfCustmerizedExceptionTest extends ContextTestSupport {
+
protected static final String ROUTER_ADDRESS = "http://localhost:9002/router";
protected static final String SERVICE_CLASS = "serviceClass=org.apache.camel.component.cxf.HelloService";
protected static String ROUTER_ENDPOINT_URI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS;
private static final String EXCEPTION_MESSAGE = "This is an exception test message";
-
+ private static final String DETAIL_TEXT = "This is a detail text node";
private Bus bus;
@@ -63,9 +69,13 @@
from(ROUTER_ENDPOINT_URI).process(new Processor() {
public void process(Exchange exchange) throws Exception {
Message message = exchange.getFault();
- message.setBody(new CamelException(EXCEPTION_MESSAGE));
+ SoapFault fault = new SoapFault(EXCEPTION_MESSAGE, SoapFault.FAULT_CODE_CLIENT);
+ Element detail = fault.getOrCreateDetail();
+ Document doc = detail.getOwnerDocument();
+ Text tn = doc.createTextNode(DETAIL_TEXT);
+ detail.appendChild(tn);
+ message.setBody(fault);
}
-
});
}
};
@@ -90,6 +100,10 @@
fail("Except to get an exception here");
} catch (Exception e) {
assertEquals("Except to get right exception message", e.getMessage(), EXCEPTION_MESSAGE);
+ assertEquals("Except to get right exception message", EXCEPTION_MESSAGE, e.getMessage());
+ assertTrue("Exception is not instance of SoapFault", e instanceof SoapFault);
+ assertEquals("Except to get right detail message", DETAIL_TEXT, ((SoapFault)e).getDetail().getTextContent());
+ assertEquals("Except to get right fault-code", SoapFault.FAULT_CODE_CLIENT, ((SoapFault)e).getFaultCode());
}
}
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadCustomizedExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadCustomizedExceptionTest.java?rev=636956&r1=636955&r2=636956&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadCustomizedExceptionTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadCustomizedExceptionTest.java Thu Mar 13 19:19:00 2008
@@ -23,7 +23,7 @@
public class CxfPayLoadCustomizedExceptionTest extends CxfCustmerizedExceptionTest {
@Override
protected void setUp() throws Exception {
- ROUTER_ENDPOINT_URI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS + "&DataFormat=MESSAGE";
+ ROUTER_ENDPOINT_URI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS + "&DataFormat=PAYLOAD";
super.setUp();
}