camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1395073 - in /camel/branches/camel-2.9.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/...
Date Sat, 06 Oct 2012 14:25:52 GMT
Author: ningjiang
Date: Sat Oct  6 14:25:51 2012
New Revision: 1395073

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

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

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

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

Modified: camel/branches/camel-2.9.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=1395073&r1=1395072&r2=1395073&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
Sat Oct  6 14:25:51 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.9.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java?rev=1395073&r1=1395072&r2=1395073&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
Sat Oct  6 14:25:51 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.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java?rev=1395073&r1=1395072&r2=1395073&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
Sat Oct  6 14:25:51 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.9.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.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java?rev=1395073&r1=1395072&r2=1395073&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
Sat Oct  6 14:25:51 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



Mime
View raw message