Author: ningjiang
Date: Wed Feb 11 05:18:20 2009
New Revision: 743229

URL: http://svn.apache.org/viewvc?rev=743229&view=rev
Log:
CAMEL-1330 added a unit test for testing the response code 

Modified:
    camel/trunk/components/camel-cxf/pom.xml
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java

Modified: camel/trunk/components/camel-cxf/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=743229&r1=743228&r2=743229&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Wed Feb 11 05:18:20 2009
@@ -101,6 +101,12 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
       <groupId>commons-httpclient</groupId>
       <artifactId>commons-httpclient</artifactId>
       <version>3.1</version>

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java?rev=743229&r1=743228&r2=743229&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
 Wed Feb 11 05:18:20 2009
@@ -21,6 +21,8 @@
 import javax.xml.ws.Service;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.hello_world_soap_http.Greeter;
@@ -36,7 +38,13 @@
                                                 "SOAPService");
     private final QName routerPortName = new 
QName("http://apache.org/hello_world_soap_http";,
                                                 "RouterPort");
-
+    
+    private final String testDocLitFaultBody = 
+        "<soap:Envelope 
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\";>"
+        + "<soap:Body><testDocLitFault 
xmlns=\"http://apache.org/hello_world_soap_http/types\";>"
+        + "<faultType>NoSuchCodeLitFault</faultType></testDocLitFault>"
+        + "</soap:Body></soap:Envelope>";
+    
     @Override
     protected void setUp() throws Exception {
         applicationContext = createApplicationContext();
@@ -48,6 +56,7 @@
 
     @Override
     protected void tearDown() throws Exception {
+        
         if (applicationContext != null) {
             applicationContext.destroy();
         }
@@ -89,6 +98,16 @@
 
     }
     
+    public void testRoutingSOAPFault() throws Exception {
+        try {
+            template.sendBody("http://localhost:9003/CamelContext/RouterPort";, 
testDocLitFaultBody);
+            fail("Should get an exception here.");
+        } catch (RuntimeCamelException exception) {
+            assertTrue("It should get the response error", 
exception.getCause() instanceof HttpOperationFailedException);
+            assertEquals("Get a wrong response code", 
((HttpOperationFailedException)exception.getCause()).getStatusCode(), 500);
+        }
+    }
+    
     @Override
     protected CamelContext createCamelContext() throws Exception {
         return SpringCamelContext.springCamelContext(applicationContext);


Reply via email to