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 2018/12/20 13:44:22 UTC

[camel] branch master updated (2a2661e -> ffe6853)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 2a2661e  CAMEL-13021: Remove camel-example-swagger-xml
     new e1d4657  CAMEL-13022: camel-restlet - sending PATCH operation should include body
     new ffe6853  Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/restlet/DefaultRestletBinding.java   |  4 ++--
 .../camel/component/restlet/RestletEndpoint.java   |  2 +-
 .../camel/component/restlet/RestletProducer.java   |  3 ++-
 ...Get2Test.java => RestletProducerPatchTest.java} | 23 ++++++++--------------
 4 files changed, 13 insertions(+), 19 deletions(-)
 copy components/camel-restlet/src/test/java/org/apache/camel/component/restlet/{RestletProducerGet2Test.java => RestletProducerPatchTest.java} (66%)


[camel] 01/02: CAMEL-13022: camel-restlet - sending PATCH operation should include body

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e1d4657cfba6583a9d3690979c6994a3b61cb387
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 20 14:38:07 2018 +0100

    CAMEL-13022: camel-restlet - sending PATCH operation should include body
---
 .../component/restlet/DefaultRestletBinding.java   |  4 +-
 .../restlet/RestletProducerPatchTest.java          | 50 ++++++++++++++++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
index 5fd4912..290f13d 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
@@ -286,8 +286,8 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
             request.setEntity(form.getWebRepresentation());
             LOG.debug("Populate Restlet {} request from exchange body as form using media type {}", method, mediaType);
         } else {
-            // include body if PUT or POST
-            if (request.getMethod().equals(Method.PUT) || request.getMethod().equals(Method.POST)) {
+            // include body if PUT, POST or PATCH
+            if (request.getMethod().equals(Method.PUT) || request.getMethod().equals(Method.POST) || request.getMethod().equals(Method.PATCH)) {
                 Representation body = createRepresentationFromBody(exchange, mediaType);
                 request.setEntity(body);
                 LOG.debug("Populate Restlet {} request from exchange body: {} using media type {}", method, body, mediaType);
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerPatchTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerPatchTest.java
new file mode 100644
index 0000000..2099501
--- /dev/null
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerPatchTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.restlet;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class RestletProducerPatchTest extends RestletTestSupport {
+
+    @Test
+    public void testRestletProducerPatch() throws Exception {
+        String out = template.requestBodyAndHeader("direct:patch", "Donald Duck", "id", 123, String.class);
+        assertEquals("123;Donald Duck", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:patch").to("restlet:http://localhost:" + portNum + "/users/{id}/basic?restletMethod=PATCH");
+
+                from("restlet:http://localhost:" + portNum + "/users/{id}/basic?restletMethods=PATCH")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            String id = exchange.getIn().getHeader("id", String.class);
+                            Object body = exchange.getIn().getBody();
+                            exchange.getOut().setBody(id + ";" + body);
+                        }
+                    });
+            }
+        };
+    }
+}


[camel] 02/02: Fixed CS

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ffe68538185d0f237e6189a457590d0c2d253700
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 20 14:39:04 2018 +0100

    Fixed CS
---
 .../main/java/org/apache/camel/component/restlet/RestletEndpoint.java  | 2 +-
 .../main/java/org/apache/camel/component/restlet/RestletProducer.java  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
index 6286eda..331c402 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
@@ -27,13 +27,13 @@ import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.http.common.cookie.CookieHandler;
-import org.apache.camel.support.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
 import org.apache.camel.support.jsse.SSLContextParameters;
 import org.restlet.data.Method;
 
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
index abcf669d..d2b8f5d 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
@@ -34,8 +34,9 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.support.DefaultAsyncProducer;
-import org.apache.camel.util.URISupport;
 import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.util.URISupport;
+
 import org.restlet.Client;
 import org.restlet.Context;
 import org.restlet.Request;