Author: dkulp
Date: Wed Feb 17 18:33:26 2010
New Revision: 911138
URL: http://svn.apache.org/viewvc?rev=911138&view=rev
Log:
[CXF-2384] Better testcase and fix for this
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=911138&r1=911137&r2=911138&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Wed Feb 17 18:33:26 2010
@@ -19,6 +19,7 @@
package org.apache.cxf.jaxws;
+import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.Map;
import java.util.concurrent.Future;
@@ -54,6 +55,7 @@
import org.apache.cxf.endpoint.ClientCallback;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.interceptor.AttachmentOutInterceptor;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxws.context.WrappedMessageContext;
import org.apache.cxf.jaxws.interceptors.MessageModeInInterceptor;
import org.apache.cxf.jaxws.interceptors.MessageModeOutInterceptor;
@@ -217,6 +219,10 @@
}
}
private RuntimeException mapException(Exception ex) {
+ if (ex instanceof Fault && ex.getCause() instanceof IOException) {
+ throw new WebServiceException(ex.getMessage(), ex.getCause());
+ }
+
if (getBinding() instanceof HTTPBinding) {
HTTPException exception = new
HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
exception.initCause(ex);
Modified:
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=911138&r1=911137&r2=911138&view=diff
==============================================================================
---
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
(original)
+++
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Wed Feb 17 18:33:26 2010
@@ -39,6 +39,8 @@
import javax.xml.ws.Endpoint;
import javax.xml.ws.Response;
import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPFaultException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -52,8 +54,10 @@
import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.DispatchImpl;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.apache.hello_world_soap_http.BadRecordLitFault;
import org.apache.hello_world_soap_http.GreeterImpl;
@@ -113,6 +117,45 @@
Thread.sleep(20);
}
}
+ @Test
+ public void testTimeout() throws Exception {
+ //CXF-2384
+ URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+ assertNotNull(wsdl);
+
+ //pick one of the other service/ports that would have an address
+ //without a service running
+ QName otherServiceName = new
QName("http://apache.org/hello_world_soap_http",
+ "SOAPProviderService");
+ QName otherPortName = new
QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
+
+
+ SOAPService service = new SOAPService(wsdl, otherServiceName);
+ assertNotNull(service);
+
+ Dispatch<SOAPMessage> disp = service
+ .createDispatch(otherPortName, SOAPMessage.class,
Service.Mode.MESSAGE);
+
+ DispatchImpl dispImpl = (DispatchImpl)disp;
+ HTTPConduit cond = (HTTPConduit)dispImpl.getClient().getConduit();
+ cond.getClient().setConnectionTimeout(500);
+
+ InputStream is =
getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
+ SOAPMessage soapReqMsg =
MessageFactory.newInstance().createMessage(null, is);
+ assertNotNull(soapReqMsg);
+
+ try {
+ disp.invoke(soapReqMsg);
+ fail("Should have faulted");
+ } catch (SOAPFaultException ex) {
+ fail("should not be a SOAPFaultException");
+ } catch (WebServiceException ex) {
+ //expected
+ assertTrue(ex.getCause().getClass().getName(),
+ ex.getCause() instanceof java.net.ConnectException);
+ }
+
+ }
@Test
public void testSOAPMessage() throws Exception {