camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject git commit: CAMEL-6240: Http4 component does not support PATCH
Date Tue, 01 Oct 2013 17:52:38 GMT
Updated Branches:
  refs/heads/camel-2.12.x e896204c2 -> 2b93029b3


CAMEL-6240: Http4 component does not support PATCH


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

Branch: refs/heads/camel-2.12.x
Commit: 2b93029b3932bb0c6c6d45101eafff3ab103baaf
Parents: e896204
Author: cmueller <cmueller@apache.org>
Authored: Tue Oct 1 19:34:49 2013 +0200
Committer: cmueller <cmueller@apache.org>
Committed: Tue Oct 1 19:51:32 2013 +0200

----------------------------------------------------------------------
 .../camel/component/http4/HttpMethods.java      |  2 +
 .../camel/component/http4/BaseHttpTest.java     |  2 +-
 .../camel/component/http4/HttpMethodsTest.java  | 44 ++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2b93029b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethods.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethods.java
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethods.java
index be5a498..780ca50 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethods.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethods.java
@@ -24,6 +24,7 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
 import org.apache.http.client.methods.HttpOptions;
+import org.apache.http.client.methods.HttpPatch;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.client.methods.HttpRequestBase;
@@ -32,6 +33,7 @@ import org.apache.http.client.methods.HttpTrace;
 public enum HttpMethods implements Expression {
 
     GET(HttpGet.class),
+    PATCH(HttpPatch.class),
     POST(HttpPost.class),
     PUT(HttpPut.class),
     DELETE(HttpDelete.class),

http://git-wip-us.apache.org/repos/asf/camel/blob/2b93029b/components/camel-http4/src/test/java/org/apache/camel/component/http4/BaseHttpTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/BaseHttpTest.java
b/components/camel-http4/src/test/java/org/apache/camel/component/http4/BaseHttpTest.java
index 9bb3bdd..1fd8d1c 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/BaseHttpTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/BaseHttpTest.java
@@ -31,8 +31,8 @@ public abstract class BaseHttpTest extends HttpServerTestSupport {
     protected void assertExchange(Exchange exchange) {
         assertNotNull(exchange);
 
+        assertTrue(exchange.hasOut());
         Message out = exchange.getOut();
-        assertNotNull(out);
         assertHeaders(out.getHeaders());
         assertBody(out.getBody(String.class));
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/2b93029b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpMethodsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpMethodsTest.java
b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpMethodsTest.java
index 13e2f25..6870a56 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpMethodsTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpMethodsTest.java
@@ -16,10 +16,13 @@
  */
 package org.apache.camel.component.http4;
 
+import java.util.Map;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.component.http4.handler.BasicValidationHandler;
+import org.apache.http.HttpStatus;
 import org.junit.Test;
 
 /**
@@ -41,6 +44,47 @@ public class HttpMethodsTest extends BaseHttpTest {
     }
 
     @Test
+    public void httpPatch() throws Exception {
+        localServer.register("/", new BasicValidationHandler("PATCH", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "/?throwExceptionOnFailure=false", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_METHOD, "PATCH");
+            }
+        });
+
+        assertNotNull(exchange);
+        assertTrue(exchange.hasOut());
+
+        Message out = exchange.getOut();
+        Map<String, Object> headers = out.getHeaders();
+        assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, headers.get(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("26", headers.get("Content-Length"));
+        assertNotNull("Should have Content-Type header", headers.get("Content-Type"));
+        assertEquals("PATCH method not supported", out.getBody(String.class));
+    }
+
+    @Test
+    public void httpPatchWithBody() throws Exception {
+        localServer.register("/", new BasicValidationHandler("PATCH", null, "rocks camel?",
getExpectedContent()));
+
+        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "/?throwExceptionOnFailure=false", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("rocks camel?");
+            }
+        });
+
+        assertNotNull(exchange);
+        assertTrue(exchange.hasOut());
+
+        Message out = exchange.getOut();
+        Map<String, Object> headers = out.getHeaders();
+        assertEquals(HttpStatus.SC_METHOD_FAILURE, headers.get(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("0", headers.get("Content-Length"));
+        assertEquals("", out.getBody(String.class));
+    }
+
+    @Test
     public void httpPost() throws Exception {
         localServer.register("/", new BasicValidationHandler("POST", null, null, getExpectedContent()));
 


Mime
View raw message