camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] camel git commit: CAMEL-11277: camel-restlet - Should include component name in from endpoint uri
Date Sun, 14 May 2017 10:15:01 GMT
CAMEL-11277: camel-restlet - Should include component name in from endpoint uri


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

Branch: refs/heads/master
Commit: 62fc367eebcaefc3a063754bcbe1fdab40054b28
Parents: 1bc88ce
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun May 14 11:51:58 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun May 14 11:51:58 2017 +0200

----------------------------------------------------------------------
 .../camel/component/restlet/RestletComponent.java       | 11 ++++++++++-
 .../restlet/RestletEndpointUpdateEndpointUriTest.java   | 12 ++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/62fc367e/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
index 0660f69..e40eef1 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
@@ -130,9 +130,18 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements
R
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
+
+        // grab uri and remove all query parameters as we need to rebuild it a bit special
+        String endpointUri = uri;
+        if (endpointUri.indexOf('?') > 0) {
+            endpointUri = endpointUri.substring(0, endpointUri.indexOf('?'));
+        }
+        // normalize so the uri is as expected
+        endpointUri = URISupport.normalizeUri(endpointUri);
+
         // decode %7B -> {
         // decode %7D -> }
-        String endpointUri = remaining.replaceAll("%7B", "{").replaceAll("%7D", "}");
+        endpointUri = endpointUri.replaceAll("%7B", "{").replaceAll("%7D", "}");
 
         // include restlet methods in the uri (use GET as default)
         String restletMethods = getAndRemoveParameter(parameters, "restletMethods", String.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/62fc367e/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java
index 17ab41a..76cb16e 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletEndpointUpdateEndpointUriTest.java
@@ -36,27 +36,27 @@ public class RestletEndpointUpdateEndpointUriTest extends CamelTestSupport
{
         RestletComponent component = context.getComponent("restlet", RestletComponent.class);
 
         Endpoint endpoint = component.createEndpoint("restlet:http://localhost:9090/users/user");
-        assertEquals("The restlet endpoint didn't update it's URI properly", "http://localhost:9090/users/user?restletMethod=GET",
+        assertEquals("The restlet endpoint didn't update it's URI properly", "restlet://http://localhost:9090/users/user?restletMethod=GET",
                      endpoint.getEndpointUri());
 
         endpoint = component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethod=post");
-        assertEquals("The restlet endpoint didn't update it's URI properly", "http://localhost:9090/users/user?restletMethod=POST",
+        assertEquals("The restlet endpoint didn't update it's URI properly", "restlet://http://localhost:9090/users/user?restletMethod=POST",
                      endpoint.getEndpointUri());
 
         endpoint = component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=post");
-        assertEquals("The restlet endpoint didn't update it's URI properly", "http://localhost:9090/users/user?restletMethods=POST",
+        assertEquals("The restlet endpoint didn't update it's URI properly", "restlet://http://localhost:9090/users/user?restletMethods=POST",
                      endpoint.getEndpointUri());
 
         endpoint = component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=lock,head");
-        assertEquals("The restlet endpoint didn't update it's URI properly", "http://localhost:9090/users/user?restletMethods=LOCK,HEAD",
+        assertEquals("The restlet endpoint didn't update it's URI properly", "restlet://http://localhost:9090/users/user?restletMethods=LOCK,HEAD",
                      endpoint.getEndpointUri());
 
         endpoint = component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=proppatch,mkcol,propfind");
-        assertEquals("The restlet endpoint didn't update it's URI properly", "http://localhost:9090/users/user?restletMethods=PROPPATCH,MKCOL,PROPFIND",
+        assertEquals("The restlet endpoint didn't update it's URI properly", "restlet://http://localhost:9090/users/user?restletMethods=PROPPATCH,MKCOL,PROPFIND",
                      endpoint.getEndpointUri());
 
         endpoint = component.createEndpoint("restlet:http://localhost:9090/users/user?restletMethods=delete,copy,options,connect");
-        assertEquals("The restlet endpoint didn't update it's URI properly", "http://localhost:9090/users/user?restletMethods=DELETE,COPY,OPTIONS,CONNECT",
+        assertEquals("The restlet endpoint didn't update it's URI properly", "restlet://http://localhost:9090/users/user?restletMethods=DELETE,COPY,OPTIONS,CONNECT",
                      endpoint.getEndpointUri());
     }
 


Mime
View raw message