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 2017/09/08 13:34:38 UTC
[8/9] camel git commit: mend
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/8be7fb49
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8be7fb49
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8be7fb49
Branch: refs/heads/camel-2.19.x
Commit: 8be7fb49da42baade931a5949b30c7d7fe4e2681
Parents: 7b8bb3d
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Sep 8 15:15:53 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Sep 8 15:33:37 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/8be7fb49/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/8be7fb49/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/8be7fb49/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");
+ }
+ });
+ }
+ };
+ }
+
+}