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/07/07 07:41:26 UTC

[1/3] camel git commit: CAMEL-11520 URL-encode hipchat room names

Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x dd9e89637 -> a6c3c86a8
  refs/heads/camel-2.19.x 09e8a0a8e -> c16ab4d04
  refs/heads/master 59fbba739 -> 175635f4a


CAMEL-11520 URL-encode hipchat room names

This allows messages to be sent to room names containing spaces or other URL-unsafe characters.

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

Branch: refs/heads/master
Commit: 175635f4adf4d3b1521bd7c6ea2add4b04b89f1c
Parents: 59fbba7
Author: Andy Bell <an...@gmail.com>
Authored: Thu Jul 6 23:37:38 2017 +0100
Committer: Andy Bell <an...@gmail.com>
Committed: Thu Jul 6 23:37:38 2017 +0100

----------------------------------------------------------------------
 .../camel/component/hipchat/HipchatProducer.java   |  5 ++++-
 .../HipchatProducerIntegrationTest.java            | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/175635f4/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
index 0a580ff..7df991b 100644
--- a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
+++ b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
@@ -27,6 +27,7 @@ import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.http.StatusLine;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -37,6 +38,8 @@ import org.apache.http.impl.client.HttpClients;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.util.UnsafeUriCharactersEncoder.encodeHttpURI;
+
 /**
  * The Hipchat producer to send message to a user and/or a room.
  */
@@ -71,7 +74,7 @@ public class HipchatProducer extends DefaultProducer {
             jsonParam.put(HipchatApiConstants.API_MESSAGE_COLOR, backGroundColor);
         }
         LOG.info("Sending message to room: " + room + ", " + MAPPER.writeValueAsString(jsonParam));
-        StatusLine statusLine = post(urlPath, jsonParam);
+        StatusLine statusLine = post(encodeHttpURI(urlPath), jsonParam);
         LOG.debug("Response status for send room message: " + statusLine);
         return statusLine;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/175635f4/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
index 071c0a1..7dfbe24 100644
--- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
+++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
@@ -72,6 +72,23 @@ public class HipchatProducerIntegrationTest extends CamelTestSupport {
 
     }
 
+    @Test
+    public void sendToUriUnsafeRoomName() throws Exception {
+        result.expectedMessageCount(1);
+
+        Exchange exchange1 = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(HipchatConstants.TO_ROOM, "Camel Test");
+                exchange.getIn().setHeader(HipchatConstants.TO_USER, "@ShreyasPurohit");
+                exchange.getIn().setBody("A room with spaces");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+
+        assertResponseMessage(exchange1.getIn());
+    }
+
     private void assertResponseMessage(Message message) {
         assertEquals(204, message.getHeader(HipchatConstants.TO_ROOM_RESPONSE_STATUS, StatusLine.class).getStatusCode());
         assertEquals(204, message.getHeader(HipchatConstants.TO_USER_RESPONSE_STATUS, StatusLine.class).getStatusCode());


[3/3] camel git commit: CAMEL-11520 URL-encode hipchat room names

Posted by da...@apache.org.
CAMEL-11520 URL-encode hipchat room names

This allows messages to be sent to room names containing spaces or other URL-unsafe characters.

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

Branch: refs/heads/camel-2.18.x
Commit: a6c3c86a84ececb6fd70f31c613239b7c8b08e3f
Parents: dd9e896
Author: Andy Bell <an...@gmail.com>
Authored: Thu Jul 6 23:37:38 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 7 09:41:18 2017 +0200

----------------------------------------------------------------------
 .../camel/component/hipchat/HipchatProducer.java   |  5 ++++-
 .../HipchatProducerIntegrationTest.java            | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a6c3c86a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
index 0a580ff..7df991b 100644
--- a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
+++ b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
@@ -27,6 +27,7 @@ import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.http.StatusLine;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -37,6 +38,8 @@ import org.apache.http.impl.client.HttpClients;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.util.UnsafeUriCharactersEncoder.encodeHttpURI;
+
 /**
  * The Hipchat producer to send message to a user and/or a room.
  */
@@ -71,7 +74,7 @@ public class HipchatProducer extends DefaultProducer {
             jsonParam.put(HipchatApiConstants.API_MESSAGE_COLOR, backGroundColor);
         }
         LOG.info("Sending message to room: " + room + ", " + MAPPER.writeValueAsString(jsonParam));
-        StatusLine statusLine = post(urlPath, jsonParam);
+        StatusLine statusLine = post(encodeHttpURI(urlPath), jsonParam);
         LOG.debug("Response status for send room message: " + statusLine);
         return statusLine;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/a6c3c86a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
index 071c0a1..7dfbe24 100644
--- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
+++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
@@ -72,6 +72,23 @@ public class HipchatProducerIntegrationTest extends CamelTestSupport {
 
     }
 
+    @Test
+    public void sendToUriUnsafeRoomName() throws Exception {
+        result.expectedMessageCount(1);
+
+        Exchange exchange1 = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(HipchatConstants.TO_ROOM, "Camel Test");
+                exchange.getIn().setHeader(HipchatConstants.TO_USER, "@ShreyasPurohit");
+                exchange.getIn().setBody("A room with spaces");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+
+        assertResponseMessage(exchange1.getIn());
+    }
+
     private void assertResponseMessage(Message message) {
         assertEquals(204, message.getHeader(HipchatConstants.TO_ROOM_RESPONSE_STATUS, StatusLine.class).getStatusCode());
         assertEquals(204, message.getHeader(HipchatConstants.TO_USER_RESPONSE_STATUS, StatusLine.class).getStatusCode());


[2/3] camel git commit: CAMEL-11520 URL-encode hipchat room names

Posted by da...@apache.org.
CAMEL-11520 URL-encode hipchat room names

This allows messages to be sent to room names containing spaces or other URL-unsafe characters.

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

Branch: refs/heads/camel-2.19.x
Commit: c16ab4d04e0707a3d56e67e2b599677bda791947
Parents: 09e8a0a
Author: Andy Bell <an...@gmail.com>
Authored: Thu Jul 6 23:37:38 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 7 09:40:56 2017 +0200

----------------------------------------------------------------------
 .../camel/component/hipchat/HipchatProducer.java   |  5 ++++-
 .../HipchatProducerIntegrationTest.java            | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c16ab4d0/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
index 0a580ff..7df991b 100644
--- a/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
+++ b/components/camel-hipchat/src/main/java/org/apache/camel/component/hipchat/HipchatProducer.java
@@ -27,6 +27,7 @@ import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.http.StatusLine;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -37,6 +38,8 @@ import org.apache.http.impl.client.HttpClients;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.util.UnsafeUriCharactersEncoder.encodeHttpURI;
+
 /**
  * The Hipchat producer to send message to a user and/or a room.
  */
@@ -71,7 +74,7 @@ public class HipchatProducer extends DefaultProducer {
             jsonParam.put(HipchatApiConstants.API_MESSAGE_COLOR, backGroundColor);
         }
         LOG.info("Sending message to room: " + room + ", " + MAPPER.writeValueAsString(jsonParam));
-        StatusLine statusLine = post(urlPath, jsonParam);
+        StatusLine statusLine = post(encodeHttpURI(urlPath), jsonParam);
         LOG.debug("Response status for send room message: " + statusLine);
         return statusLine;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/c16ab4d0/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
index 071c0a1..7dfbe24 100644
--- a/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
+++ b/components/camel-hipchat/src/test/java/org/apache/camel/component/hipchat/integration/HipchatProducerIntegrationTest.java
@@ -72,6 +72,23 @@ public class HipchatProducerIntegrationTest extends CamelTestSupport {
 
     }
 
+    @Test
+    public void sendToUriUnsafeRoomName() throws Exception {
+        result.expectedMessageCount(1);
+
+        Exchange exchange1 = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(HipchatConstants.TO_ROOM, "Camel Test");
+                exchange.getIn().setHeader(HipchatConstants.TO_USER, "@ShreyasPurohit");
+                exchange.getIn().setBody("A room with spaces");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+
+        assertResponseMessage(exchange1.getIn());
+    }
+
     private void assertResponseMessage(Message message) {
         assertEquals(204, message.getHeader(HipchatConstants.TO_ROOM_RESPONSE_STATUS, StatusLine.class).getStatusCode());
         assertEquals(204, message.getHeader(HipchatConstants.TO_USER_RESPONSE_STATUS, StatusLine.class).getStatusCode());