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 2012/10/06 11:49:12 UTC

svn commit: r1394978 - in /camel/branches/camel-2.10.x: ./ components/camel-http/src/main/java/org/apache/camel/component/http/ components/camel-http4/src/main/java/org/apache/camel/component/http4/ components/camel-jetty/src/test/java/org/apache/camel...

Author: ningjiang
Date: Sat Oct  6 09:49:11 2012
New Revision: 1394978

URL: http://svn.apache.org/viewvc?rev=1394978&view=rev
Log:
CAMEL-5668 fix the soap fault response code issue with thanks to James

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
    camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
    camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
    camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1392188

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=1394978&r1=1394977&r2=1394978&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java (original)
+++ camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java Sat Oct  6 09:49:11 2012
@@ -254,6 +254,7 @@ public class DefaultHttpBinding implemen
     }
 
     public void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        message.setHeader(Exchange.HTTP_RESPONSE_CODE, 500);
         doWriteResponse(message, response, exchange);
     }
 

Modified: camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java?rev=1394978&r1=1394977&r2=1394978&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java (original)
+++ camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java Sat Oct  6 09:49:11 2012
@@ -237,6 +237,7 @@ public class DefaultHttpBinding implemen
     }
 
     public void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        message.setHeader(Exchange.HTTP_RESPONSE_CODE, 500);
         doWriteResponse(message, response, exchange);
     }
 

Modified: camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java?rev=1394978&r1=1394977&r2=1394978&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java Sat Oct  6 09:49:11 2012
@@ -19,6 +19,7 @@ package org.apache.camel.component.jetty
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.HttpOperationFailedException;
 import org.junit.Test;
 
 /**
@@ -28,8 +29,18 @@ public class HttpReturnFaultTest extends
 
     @Test
     public void testHttpFault() throws Exception {
-        String out = template.requestBody("http://localhost:{{port}}/test", "Hello World", String.class);
-        assertEquals("This is a fault", out);
+        Exchange exchange = template.request("http://localhost:{{port}}/test", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("Hello World!");
+            }
+            
+        });
+        assertTrue(exchange.isFailed());
+        HttpOperationFailedException exception = exchange.getException(HttpOperationFailedException.class);
+        assertNotNull(exception);
+        assertEquals("This is a fault", exception.getResponseBody());
+        assertEquals(500, exception.getStatusCode());
     }
 
     @Override

Modified: camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java?rev=1394978&r1=1394977&r2=1394978&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java Sat Oct  6 09:49:11 2012
@@ -19,6 +19,7 @@ package org.apache.camel.component.jetty
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
 import org.junit.Test;
 
@@ -37,8 +38,18 @@ public class JettyHttpProderReturnFaultT
         // give Jetty time to startup properly
         Thread.sleep(1000);
 
-        String out = template.requestBody("jetty://http://localhost:{{port}}/test", "Hello World", String.class);
-        assertEquals("This is a fault", out);
+        Exchange exchange = template.request("jetty://http://localhost:{{port}}/test", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("Hello World!");
+            }
+            
+        });
+        assertTrue(exchange.isFailed());
+        HttpOperationFailedException exception = exchange.getException(HttpOperationFailedException.class);
+        assertNotNull(exception);
+        assertEquals("This is a fault", exception.getResponseBody());
+        assertEquals(500, exception.getStatusCode());
     }
 
     @Override