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
The following commit(s) were added to refs/heads/master by this push: new 8079044 CAMEL-12436: Fix Undertow to extract body message from PATCH request 8079044 is described below commit 80790444bda66076e72467d4704a3f8286c7d714 Author: Tomas Turek <ttu...@redhat.com> AuthorDate: Wed Apr 11 16:35:46 2018 +0200 CAMEL-12436: Fix Undertow to extract body message from PATCH request --- .../undertow/DefaultUndertowHttpBinding.java | 2 +- .../rest/RestUndertowProducerPatchTest.java | 58 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java index 91bd852..ae1f6fe 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java @@ -124,7 +124,7 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding { } else { //extract body by myself if undertow parser didn't handle and the method is allowed to have one //body is extracted as byte[] then auto TypeConverter kicks in - if (Methods.POST.equals(httpExchange.getRequestMethod()) || Methods.PUT.equals(httpExchange.getRequestMethod())) { + if (Methods.POST.equals(httpExchange.getRequestMethod()) || Methods.PUT.equals(httpExchange.getRequestMethod()) || Methods.PATCH.equals(httpExchange.getRequestMethod())) { result.setBody(readFromChannel(httpExchange.getRequestChannel())); } else { result.setBody(null); diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerPatchTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerPatchTest.java new file mode 100644 index 0000000..bfbd59f --- /dev/null +++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerPatchTest.java @@ -0,0 +1,58 @@ +/** + * 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.undertow.rest; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.component.undertow.BaseUndertowTest; +import org.junit.Test; + +public class RestUndertowProducerPatchTest extends BaseUndertowTest { + + @Test + public void testUndertowProducerPatch() throws Exception { + String body = "Donald Duck"; + String id = "123"; + + MockEndpoint mock = getMockEndpoint("mock:input"); + mock.message(0).body().isEqualTo(body); + mock.message(0).header("id").isEqualTo(id); + + fluentTemplate.withBody(body).withHeader("id", id).to("direct:start").send(); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + // configure to use localhost with the given port + restConfiguration().component("undertow").host("localhost").port(getPort()); + + from("direct:start") + .to("rest:patch:users/{id}"); + + // use the rest DSL to define the rest services + rest("/users/") + .patch("{id}") + .to("mock:input"); + } + }; + } +} -- To stop receiving notification emails like this one, please contact davscl...@apache.org.