CAMEL-10916: Add option to turn on body on HTTP delete in http4 component

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

Branch: refs/heads/master
Commit: dfa2456ccf5a6ee36e9c5a9a43e67d0db85f5023
Parents: 7657d77
Author: Claus Ibsen <[email protected]>
Authored: Mon Mar 6 16:26:19 2017 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Mon Mar 6 16:26:19 2017 +0100

----------------------------------------------------------------------
 .../jetty/Http4DeleteWithBodyTest.java          | 58 ++++++++++++++++++++
 components/camel-netty-http/pom.xml             |  5 ++
 .../netty/http/Http4DeleteWithBodyTest.java     | 58 ++++++++++++++++++++
 3 files changed, 121 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/dfa2456c/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/Http4DeleteWithBodyTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/Http4DeleteWithBodyTest.java
 
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/Http4DeleteWithBodyTest.java
new file mode 100644
index 0000000..08d8d34
--- /dev/null
+++ 
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/Http4DeleteWithBodyTest.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.jetty;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class Http4DeleteWithBodyTest extends BaseJettyTest {
+
+    @Test
+    public void testHttp4DeleteWithBodyFalseTest() throws Exception {
+        byte[] data = "World".getBytes();
+        String out = 
template.requestBodyAndHeader("http4://localhost:{{port}}/test", data, 
Exchange.HTTP_METHOD, "DELETE", String.class);
+        assertEquals("Bye ", out);
+    }
+
+    @Test
+    public void testHttp4DeleteWithBodyTrueTest() throws Exception {
+        byte[] data = "World".getBytes();
+        String out = 
template.requestBodyAndHeader("http4://localhost:{{port}}/test?deleteWithBody=true",
 data, Exchange.HTTP_METHOD, "DELETE", String.class);
+        assertEquals("Bye World", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jetty://http://localhost:{{port}}/test";)
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws 
Exception {
+                            String method = 
exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class);
+                            assertEquals("DELETE", method);
+                        }
+                    })
+                    .transform(simple("Bye ${body}"));
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/dfa2456c/components/camel-netty-http/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/pom.xml 
b/components/camel-netty-http/pom.xml
index e0b9ab1..cab9354 100644
--- a/components/camel-netty-http/pom.xml
+++ b/components/camel-netty-http/pom.xml
@@ -53,6 +53,11 @@
                        <scope>test</scope>
                </dependency>
                <dependency>
+                       <groupId>org.apache.camel</groupId>
+                       <artifactId>camel-http4</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/dfa2456c/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/Http4DeleteWithBodyTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/Http4DeleteWithBodyTest.java
 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/Http4DeleteWithBodyTest.java
new file mode 100644
index 0000000..8f0d76b
--- /dev/null
+++ 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/Http4DeleteWithBodyTest.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.netty.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class Http4DeleteWithBodyTest extends BaseNettyTest {
+
+    @Test
+    public void testHttp4DeleteWithBodyFalseTest() throws Exception {
+        byte[] data = "World".getBytes();
+        String out = 
template.requestBodyAndHeader("http4://localhost:{{port}}/test", data, 
Exchange.HTTP_METHOD, "DELETE", String.class);
+        assertEquals("Bye ", out);
+    }
+
+    @Test
+    public void testHttp4DeleteWithBodyTrueTest() throws Exception {
+        byte[] data = "World".getBytes();
+        String out = 
template.requestBodyAndHeader("http4://localhost:{{port}}/test?deleteWithBody=true",
 data, Exchange.HTTP_METHOD, "DELETE", String.class);
+        assertEquals("Bye World", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty-http:http://0.0.0.0:{{port}}/test";)
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws 
Exception {
+                            String method = 
exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class);
+                            assertEquals("DELETE", method);
+                        }
+                    })
+                    .transform(simple("Bye ${body}"));
+            }
+        };
+    }
+
+}

Reply via email to