Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x c8b677e86 -> c40c1b064
  refs/heads/camel-2.13.x e177e4175 -> 38391554e
  refs/heads/master bdf3021d0 -> a59414d37


CAMEL-7347: camel-netty-http should return 404 instead 503 if resource not 
found.


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

Branch: refs/heads/master
Commit: a59414d3751a6ba0946dcc60193c6d32db92a115
Parents: bdf3021
Author: Claus Ibsen <davscl...@apache.org>
Authored: Mon Apr 7 11:18:06 2014 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Apr 7 11:18:06 2014 +0200

----------------------------------------------------------------------
 .../http/handlers/HttpServerMultiplexChannelHandler.java |  6 +++---
 .../http/NettyHttpTwoRoutesMatchOnUriPrefixTest.java     | 11 ++++++++++-
 .../netty/http/NettyHttpTwoRoutesStopOneRouteTest.java   |  4 ++--
 3 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a59414d3/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
index 3351fd8..e00abd4 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -38,7 +38,7 @@ import org.jboss.netty.handler.codec.http.HttpResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static 
org.jboss.netty.handler.codec.http.HttpResponseStatus.SERVICE_UNAVAILABLE;
+import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND;
 import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
 
 /**
@@ -102,8 +102,8 @@ public class HttpServerMultiplexChannelHandler extends 
SimpleChannelUpstreamHand
             ctx.setAttachment(handler);
             handler.messageReceived(ctx, messageEvent);
         } else {
-            // this service is not available, so send empty response back
-            HttpResponse response = new DefaultHttpResponse(HTTP_1_1, 
SERVICE_UNAVAILABLE);
+            // this resource is not found, so send empty response back
+            HttpResponse response = new DefaultHttpResponse(HTTP_1_1, 
NOT_FOUND);
             response.setHeader(Exchange.CONTENT_TYPE, "text/plain");
             response.setHeader(Exchange.CONTENT_LENGTH, 0);
             response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));

http://git-wip-us.apache.org/repos/asf/camel/blob/a59414d3/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesMatchOnUriPrefixTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesMatchOnUriPrefixTest.java
 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesMatchOnUriPrefixTest.java
index 382e2c9..370753f 100644
--- 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesMatchOnUriPrefixTest.java
+++ 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesMatchOnUriPrefixTest.java
@@ -36,7 +36,16 @@ public class NettyHttpTwoRoutesMatchOnUriPrefixTest extends 
BaseNettyTest {
             fail("Should have thrown exception");
         } catch (CamelExecutionException e) {
             NettyHttpOperationFailedException cause = 
assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause());
-            assertEquals(503, cause.getStatusCode());
+            assertEquals(404, cause.getStatusCode());
+        }
+
+        // .. and likewise baz is not a context-path we have mapped as input
+        try {
+            template.requestBody("netty-http:http://localhost:{{port}}/baz";, 
"Hello World", String.class);
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            NettyHttpOperationFailedException cause = 
assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause());
+            assertEquals(404, cause.getStatusCode());
         }
 
         out = template.requestBody("netty-http:http://localhost:{{port}}/bar";, 
"Hello Camel", String.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/a59414d3/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesStopOneRouteTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesStopOneRouteTest.java
 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesStopOneRouteTest.java
index 7563511..9e9dc53 100644
--- 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesStopOneRouteTest.java
+++ 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpTwoRoutesStopOneRouteTest.java
@@ -43,13 +43,13 @@ public class NettyHttpTwoRoutesStopOneRouteTest extends 
BaseNettyTest {
         getMockEndpoint("mock:foo").expectedMessageCount(0);
         getMockEndpoint("mock:bar").expectedBodiesReceived("Hello Camel");
 
-        // the foo route is stopped so this service is not available
+        // the foo route is stopped so this service is no longer there
         try {
             template.requestBody("netty-http:http://localhost:{{port}}/foo";, 
"Hello World", String.class);
             fail("Should have thrown exception");
         } catch (CamelExecutionException e) {
             NettyHttpOperationFailedException cause = 
assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause());
-            assertEquals(503, cause.getStatusCode());
+            assertEquals(404, cause.getStatusCode());
         }
 
         out = template.requestBody("netty-http:http://localhost:{{port}}/bar";, 
"Hello Camel", String.class);

Reply via email to