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 2014/04/22 04:42:23 UTC

[2/2] git commit: Added some unit tests for testing the SocketTimeoutException

Added some unit tests for testing the SocketTimeoutException


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fdc3b321
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fdc3b321
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fdc3b321

Branch: refs/heads/master
Commit: fdc3b32133686a124623c7de1d8ca47a374c8d0a
Parents: 96a9e37
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Apr 22 10:41:34 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Apr 22 10:41:34 2014 +0800

----------------------------------------------------------------------
 .../apache/camel/component/cxf/CxfTimeoutTest.java  | 14 ++++++++++++++
 .../component/cxf/cxfConduitTimeOutContext.xml      | 16 ++++++++++++++++
 2 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fdc3b321/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
index 42f3042..f8cc0e8 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
@@ -25,6 +25,7 @@ import javax.xml.ws.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.spring.CamelSpringTestSupport;
 import org.apache.hello_world_soap_http.Greeter;
 import org.junit.BeforeClass;
@@ -65,6 +66,19 @@ public class CxfTimeoutTest extends CamelSpringTestSupport {
         sendTimeOutMessage("cxf://bean:springEndpoint");
     }
     
+    @Test
+    public void testInvokingFromCamelRoute() throws Exception {
+        sendTimeOutMessage("direct:start");
+    }
+    
+    @Test
+    public void testDoCatchWithTimeOutException() throws Exception {
+        MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
+        error.expectedMessageCount(1);
+        sendTimeOutMessage("direct:doCatch");
+        error.assertIsSatisfied();
+    }
+    
     protected void sendTimeOutMessage(String endpointUri) throws Exception {
         Exchange reply = sendJaxWsMessage(endpointUri);
         Exception e = reply.getException();

http://git-wip-us.apache.org/repos/asf/camel/blob/fdc3b321/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
index c06533e..60b0de9 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
@@ -44,6 +44,22 @@
         <from uri="direct:start"/>
         <to uri="cxf:bean:springEndpoint"/>
      </route>
+
+	<route>
+		<from uri="direct:doCatch" />
+		<doTry>
+			<to uri="cxf:bean:springEndpoint" />
+			<doCatch>
+				<!-- and catch all other exceptions they are handled by default (ie handled 
+					= true) -->
+				<exception>java.lang.Exception</exception>
+				<handled>
+					<constant>false</constant>
+				</handled>
+				<to uri="mock:error" />
+			</doCatch>
+		</doTry>
+	</route>
    </camelContext>
 
    <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>