mend CAMEL-11624: rest-dsl producer should use upper-case HTTP verb.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4146690b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4146690b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4146690b Branch: refs/heads/master Commit: 4146690bfb2c721c64cc39ed01ec66f72b93b157 Parents: 85f143e Author: Claus Ibsen <davscl...@apache.org> Authored: Fri Sep 8 15:15:53 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Sep 8 15:32:58 2017 +0200 ---------------------------------------------------------------------- .../RestNettyProducerVerbUpperCaseTest.java | 63 +++++++++++++++++++ .../RestletRestProducerVerbUpperCaseTest.java | 63 +++++++++++++++++++ .../RestUndertowProducerVerbUpperCaseTest.java | 64 ++++++++++++++++++++ 3 files changed, 190 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4146690b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyProducerVerbUpperCaseTest.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyProducerVerbUpperCaseTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyProducerVerbUpperCaseTest.java new file mode 100644 index 0000000..c46c487 --- /dev/null +++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/rest/RestNettyProducerVerbUpperCaseTest.java @@ -0,0 +1,63 @@ +/** + * 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.netty4.http.rest; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.netty4.http.BaseNettyTest; +import org.junit.Test; + +public class RestNettyProducerVerbUpperCaseTest extends BaseNettyTest { + + @Test + public void testVerbUpperCase() throws Exception { + String out = fluentTemplate.withHeader("id", "123").to("direct:start").request(String.class); + assertNotNull(out); + assertEquals("123;Donald Duck", out); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + // configure to use netty on localhost with the given port + restConfiguration().component("netty4-http").host("localhost").port(getPort()); + + from("direct:start") + .to("rest:get:users/{id}/basic"); + + // use the rest DSL to define the rest services + rest("/users/") + .get("{id}/basic") + .route() + .to("mock:input") + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + String method = exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class); + assertEquals("GET", method); + + String id = exchange.getIn().getHeader("id", String.class); + exchange.getOut().setBody(id + ";Donald Duck"); + } + }); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/4146690b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRestProducerVerbUpperCaseTest.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRestProducerVerbUpperCaseTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRestProducerVerbUpperCaseTest.java new file mode 100644 index 0000000..0c1ba23 --- /dev/null +++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRestProducerVerbUpperCaseTest.java @@ -0,0 +1,63 @@ +/** + * 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; + +/** + * @version + */ +public class RestletRestProducerVerbUpperCaseTest extends RestletTestSupport { + + @Test + public void testVerbUpperCase() throws Exception { + String out = fluentTemplate.withHeader("id", "123").to("direct:start").request(String.class); + assertEquals("123;Donald Duck", out); + } + + @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("restlet").host("localhost").port(portNum); + + from("direct:start") + .to("rest:get:users/{id}/basic"); + + // use the rest DSL to define the rest services + rest("/users/") + .get("{id}/basic") + .route() + .to("mock:input") + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + String method = exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class); + assertEquals("GET", method); + + String id = exchange.getIn().getHeader("id", String.class); + exchange.getOut().setBody(id + ";Donald Duck"); + } + }); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/4146690b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerVerbUpperCaseTest.java ---------------------------------------------------------------------- diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerVerbUpperCaseTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerVerbUpperCaseTest.java new file mode 100644 index 0000000..6cbac2f --- /dev/null +++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerVerbUpperCaseTest.java @@ -0,0 +1,64 @@ +/** + * 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.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.undertow.BaseUndertowTest; +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("CAME-11765") +public class RestUndertowProducerVerbUpperCaseTest extends BaseUndertowTest { + + @Test + public void testVerbUpperCase() throws Exception { + String out = fluentTemplate.withHeader("id", "123").to("direct:start").request(String.class); + assertEquals("123;Donald Duck", out); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + // configure to use undertow on localhost with the given port + restConfiguration().component("undertow").host("localhost").port(getPort()); + + from("direct:start") + .to("rest:get:users/{id}/basic"); + + // use the rest DSL to define the rest services + rest("/users/") + .get("{id}/basic") + .route() + .to("mock:input") + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + String method = exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class); + assertEquals("GET", method); + + String id = exchange.getIn().getHeader("id", String.class); + exchange.getOut().setBody(id + ";Donald Duck"); + } + }); + } + }; + } + +}