You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/07/31 09:22:07 UTC
[1/3] git commit: CAMEL-7650: camel-restlet should return error code
405 (method not allowed) if the http request is using a verb that is not
allowed.
Repository: camel
Updated Branches:
refs/heads/camel-2.12.x 4e3a0e5d0 -> 563d143d4
refs/heads/camel-2.13.x 8fe7d068b -> cd2484282
refs/heads/master 7db64fcd7 -> 1a2f25966
CAMEL-7650: camel-restlet should return error code 405 (method not allowed) if the http request is using a verb that is not allowed.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1a2f2596
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1a2f2596
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1a2f2596
Branch: refs/heads/master
Commit: 1a2f25966783ed5046f692eaafb70893458557fd
Parents: 7db64fc
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 31 09:20:58 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 31 09:20:58 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/restlet/MethodBasedRouter.java | 4 ++--
.../restlet/RestletMultiMethodsEndpointTest.java | 10 ++++++++++
.../camel/component/restlet/RestletRouteBuilderTest.java | 10 ++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1a2f2596/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
index 2e5a139..ea9bf16 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
@@ -53,8 +53,8 @@ class MethodBasedRouter extends Restlet {
if (target != null) {
target.handle(request, response);
} else {
- LOG.debug("No route for request method: {}", method);
- response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
+ LOG.debug("MethodRouter ({}) method not allowed: {}", uriPattern, method);
+ response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/1a2f2596/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
index 165cb27..7ed9c07 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
@@ -20,10 +20,12 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.junit.Test;
+import org.restlet.data.Status;
/**
* This unit test verifies a single route can service multiple methods.
@@ -53,6 +55,14 @@ public class RestletMultiMethodsEndpointTest extends RestletTestSupport {
assertHttpResponse(response, 200, "text/plain", "GET");
}
+ @Test
+ public void testDeleteMethod() throws Exception {
+ HttpResponse response = doExecute(new HttpDelete("http://localhost:" + portNum + "/users/homer"));
+
+ // delete is not allowed so we return 405
+ assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED.getCode(), response.getStatusLine().getStatusCode());
+ }
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/1a2f2596/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
index 03a06c7..afb9ef5 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
@@ -131,6 +131,16 @@ public class RestletRouteBuilderTest extends RestletTestSupport {
Response response = client.handle(new Request(Method.POST,
"http://localhost:" + portNum + "/orders/99991/6"));
// expect error status as no Restlet consumer to handle POST method
+ assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED, response.getStatus());
+ assertNotNull(response.getEntity().getText());
+ }
+
+ @Test
+ public void testNotFound() throws IOException {
+ Client client = new Client(Protocol.HTTP);
+ Response response = client.handle(new Request(Method.POST,
+ "http://localhost:" + portNum + "/unknown"));
+ // expect error status as no Restlet consumer to handle POST method
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
assertNotNull(response.getEntity().getText());
}
[3/3] git commit: CAMEL-7650: camel-restlet should return error code
405 (method not allowed) if the http request is using a verb that is not
allowed.
Posted by da...@apache.org.
CAMEL-7650: camel-restlet should return error code 405 (method not allowed) if the http request is using a verb that is not allowed.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/563d143d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/563d143d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/563d143d
Branch: refs/heads/camel-2.12.x
Commit: 563d143d451e762f49a4ca694857cb584adf6ec7
Parents: 4e3a0e5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 31 09:20:58 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 31 09:21:52 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/restlet/MethodBasedRouter.java | 4 ++--
.../restlet/RestletMultiMethodsEndpointTest.java | 10 ++++++++++
.../camel/component/restlet/RestletRouteBuilderTest.java | 10 ++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/563d143d/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
index 2e5a139..ea9bf16 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
@@ -53,8 +53,8 @@ class MethodBasedRouter extends Restlet {
if (target != null) {
target.handle(request, response);
} else {
- LOG.debug("No route for request method: {}", method);
- response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
+ LOG.debug("MethodRouter ({}) method not allowed: {}", uriPattern, method);
+ response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/563d143d/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
index 165cb27..7ed9c07 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
@@ -20,10 +20,12 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.junit.Test;
+import org.restlet.data.Status;
/**
* This unit test verifies a single route can service multiple methods.
@@ -53,6 +55,14 @@ public class RestletMultiMethodsEndpointTest extends RestletTestSupport {
assertHttpResponse(response, 200, "text/plain", "GET");
}
+ @Test
+ public void testDeleteMethod() throws Exception {
+ HttpResponse response = doExecute(new HttpDelete("http://localhost:" + portNum + "/users/homer"));
+
+ // delete is not allowed so we return 405
+ assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED.getCode(), response.getStatusLine().getStatusCode());
+ }
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/563d143d/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
index 03a06c7..afb9ef5 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
@@ -131,6 +131,16 @@ public class RestletRouteBuilderTest extends RestletTestSupport {
Response response = client.handle(new Request(Method.POST,
"http://localhost:" + portNum + "/orders/99991/6"));
// expect error status as no Restlet consumer to handle POST method
+ assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED, response.getStatus());
+ assertNotNull(response.getEntity().getText());
+ }
+
+ @Test
+ public void testNotFound() throws IOException {
+ Client client = new Client(Protocol.HTTP);
+ Response response = client.handle(new Request(Method.POST,
+ "http://localhost:" + portNum + "/unknown"));
+ // expect error status as no Restlet consumer to handle POST method
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
assertNotNull(response.getEntity().getText());
}
[2/3] git commit: CAMEL-7650: camel-restlet should return error code
405 (method not allowed) if the http request is using a verb that is not
allowed.
Posted by da...@apache.org.
CAMEL-7650: camel-restlet should return error code 405 (method not allowed) if the http request is using a verb that is not allowed.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cd248428
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cd248428
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cd248428
Branch: refs/heads/camel-2.13.x
Commit: cd2484282f85ccc23bdef981c98e891fbabcc1f9
Parents: 8fe7d06
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 31 09:20:58 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 31 09:21:30 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/restlet/MethodBasedRouter.java | 4 ++--
.../restlet/RestletMultiMethodsEndpointTest.java | 10 ++++++++++
.../camel/component/restlet/RestletRouteBuilderTest.java | 10 ++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/cd248428/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
index 2e5a139..ea9bf16 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
@@ -53,8 +53,8 @@ class MethodBasedRouter extends Restlet {
if (target != null) {
target.handle(request, response);
} else {
- LOG.debug("No route for request method: {}", method);
- response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
+ LOG.debug("MethodRouter ({}) method not allowed: {}", uriPattern, method);
+ response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/cd248428/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
index 165cb27..7ed9c07 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletMultiMethodsEndpointTest.java
@@ -20,10 +20,12 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.junit.Test;
+import org.restlet.data.Status;
/**
* This unit test verifies a single route can service multiple methods.
@@ -53,6 +55,14 @@ public class RestletMultiMethodsEndpointTest extends RestletTestSupport {
assertHttpResponse(response, 200, "text/plain", "GET");
}
+ @Test
+ public void testDeleteMethod() throws Exception {
+ HttpResponse response = doExecute(new HttpDelete("http://localhost:" + portNum + "/users/homer"));
+
+ // delete is not allowed so we return 405
+ assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED.getCode(), response.getStatusLine().getStatusCode());
+ }
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/cd248428/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
index 03a06c7..afb9ef5 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
@@ -131,6 +131,16 @@ public class RestletRouteBuilderTest extends RestletTestSupport {
Response response = client.handle(new Request(Method.POST,
"http://localhost:" + portNum + "/orders/99991/6"));
// expect error status as no Restlet consumer to handle POST method
+ assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED, response.getStatus());
+ assertNotNull(response.getEntity().getText());
+ }
+
+ @Test
+ public void testNotFound() throws IOException {
+ Client client = new Client(Protocol.HTTP);
+ Response response = client.handle(new Request(Method.POST,
+ "http://localhost:" + portNum + "/unknown"));
+ // expect error status as no Restlet consumer to handle POST method
assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
assertNotNull(response.getEntity().getText());
}