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/01/30 11:52:25 UTC

[1/3] camel git commit: Regen code

Repository: camel
Updated Branches:
  refs/heads/master 49723675f -> 8892e34f3


Regen code


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

Branch: refs/heads/master
Commit: 8892e34f30fd68d4c65d4bff59fe174677fedd50
Parents: 6899bca
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jan 30 12:49:49 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jan 30 12:49:54 2017 +0100

----------------------------------------------------------------------
 components/readme.adoc         | 15 +++++++++++++++
 docs/user-manual/en/SUMMARY.md |  5 +++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8892e34f/components/readme.adoc
----------------------------------------------------------------------
diff --git a/components/readme.adoc b/components/readme.adoc
index fccd05c..7641b5c 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -204,12 +204,27 @@ Components
 | link:camel-google-drive/src/main/docs/google-drive-component.adoc[Google Drive] (camel-google-drive) +
 `google-drive:apiName/methodName` | The google-drive component provides access to Google Drive file storage service.
 
+| link:camel-gae/src/main/docs/gauth-component.adoc[Google GAuth] (camel-gae) +
+`gauth:name` | The gauth component is used by web applications to implement a Google-specific OAuth consumer.
+
+| link:camel-gae/src/main/docs/ghttp-component.adoc[Google HTTP] (camel-gae) +
+`ghttp:httpUri` | The ghttp component provides HTTP connectivity to the GAE.
+
+| link:camel-gae/src/main/docs/glogin-component.adoc[Google Login] (camel-gae) +
+`glogin:hostName` | The glogin component is used by Camel applications outside Google App Engine (GAE) for programmatic login to GAE applications.
+
+| link:camel-gae/src/main/docs/gmail-component.adoc[Google mail] (camel-gae) +
+`gmail:sender` | The gmail component is used for sending emails to GAE.
+
 | link:camel-google-mail/src/main/docs/google-mail-component.adoc[Google Mail] (camel-google-mail) +
 `google-mail:apiName/methodName` | The google-mail component provides access to Google Mail.
 
 | link:camel-google-pubsub/src/main/docs/google-pubsub-component.adoc[Google Pubsub] (camel-google-pubsub) +
 `google-pubsub:projectId:destinationName` | Messaging client for Google Cloud Platform PubSub Service: https://cloud.google.com/pubsub/
 
+| link:camel-gae/src/main/docs/gtask-component.adoc[Google Task] (camel-gae) +
+`gtask:queueName` | The gtask component is used for sending messages to GAE task queue service.
+
 | link:camel-gora/src/main/docs/gora-component.adoc[Gora] (camel-gora) +
 `gora:name` | The gora component allows you to work with NoSQL databases using the Apache Gora framework.
 

http://git-wip-us.apache.org/repos/asf/camel/blob/8892e34f/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index d93d575..05129ca 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -190,8 +190,13 @@
 	* [GitHub](github-component.adoc)
 	* [Google Calendar](google-calendar-component.adoc)
 	* [Google Drive](google-drive-component.adoc)
+	* [Google GAuth](gauth-component.adoc)
+	* [Google HTTP](ghttp-component.adoc)
+	* [Google Login](glogin-component.adoc)
+	* [Google mail](gmail-component.adoc)
 	* [Google Mail](google-mail-component.adoc)
 	* [Google Pubsub](google-pubsub-component.adoc)
+	* [Google Task](gtask-component.adoc)
 	* [Gora](gora-component.adoc)
 	* [Grape](grape-component.adoc)
 	* [Guava EventBus](guava-eventbus-component.adoc)


[3/3] camel git commit: CAMEL-10759 RabbitMQ Component binding args

Posted by da...@apache.org.
CAMEL-10759 RabbitMQ Component binding args

Introduced 3 new Endpoint URI properties 
- exchangeArgs
- queueArgs
- bindingArgs

As an easier way to specifiy rabbitmq properties at declare time.
Meanwhile deprecated the ArgsConfigurer class whilst maintaining backwards compatibility. It's actually possible to use both styles of arg declaration because the Maps are combined. 

Introduced a new integration test for the bindingArgs which tests a headers exchange correctly routing to a queue. Updated the previous integration test RabbitMQInOutIntTest to use the new style of arg when setting the "x-expires" property on the queue.

Finally added a small example of how to declare a headers exchange using new feature. 

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

Branch: refs/heads/master
Commit: c22d808a21c256acdc0f05594d8d53de005a9138
Parents: 4972367
Author: Paul Watson <pa...@pdwtech.com>
Authored: Sun Jan 29 22:55:52 2017 +0000
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jan 30 12:49:54 2017 +0100

----------------------------------------------------------------------
 .../src/main/docs/rabbitmq-component.adoc       | 24 ++++++-
 .../component/rabbitmq/ArgsConfigurer.java      | 11 +++
 .../rabbitmq/RabbitMQDeclareSupport.java        | 18 +++--
 .../component/rabbitmq/RabbitMQEndpoint.java    | 40 +++++++++++
 .../rabbitmq/AbstractRabbitMQIntTest.java       | 43 ++++++++++++
 .../rabbitmq/RabbitMQConsumerIntTest.java       | 72 ++++++++++++++------
 .../rabbitmq/RabbitMQEndpointTest.java          | 39 ++++++++++-
 .../rabbitmq/RabbitMQInOutIntTest.java          | 10 +--
 .../rabbitmq/RabbitMQProducerIntTest.java       | 14 +---
 9 files changed, 224 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
index cf8a122..8a7b4df 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
@@ -45,7 +45,7 @@ The RabbitMQ component has no options.
 
 
 // endpoint options: START
-The RabbitMQ component supports 56 endpoint options which are listed below:
+The RabbitMQ component supports 59 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2,1,1m,1m,5",options="header"]
@@ -90,10 +90,13 @@ The RabbitMQ component supports 56 endpoint options which are listed below:
 | publisherAcknowledgementsTimeout | producer |  | long | The amount of time in milliseconds to wait for a basic.ack response from RabbitMQ server
 | addresses | advanced |  | Address[] | If this option is set camel-rabbitmq will try to create connection based on the setting of option addresses. The addresses value is a string which looks like server1:12345 server2:12345
 | automaticRecoveryEnabled | advanced |  | Boolean | Enables connection automatic recovery (uses connection implementation that performs automatic recovery when connection shutdown is not initiated by the application)
+| bindingArgs | advanced |  | Map | Key/value args for configuring the queue binding parameters when declare=true
 | clientProperties | advanced |  | Map | Connection client properties (client info used in negotiating with the server)
 | connectionFactory | advanced |  | ConnectionFactory | To use a custom RabbitMQ connection factory. When this option is set all connection options (connectionTimeout requestedChannelMax...) set on URI are not used
+| exchangeArgs | advanced |  | Map | Key/value args for configuring the exchange parameters when declare=true
 | exchangeArgsConfigurer | advanced |  | ArgsConfigurer | Set the configurer for setting the exchange args in Channel.exchangeDeclare
 | networkRecoveryInterval | advanced |  | Integer | Network recovery interval in milliseconds (interval used when recovering from network failure)
+| queueArgs | advanced |  | Map | Key/value args for configuring the queue parameters when declare=true
 | queueArgsConfigurer | advanced |  | ArgsConfigurer | Set the configurer for setting the queue args in Channel.queueDeclare
 | requestedChannelMax | advanced | 0 | int | Connection requested channel max (max number of channels offered)
 | requestedFrameMax | advanced | 0 | int | Connection requested frame max (max size of frame offered)
@@ -236,6 +239,25 @@ To send messages to an exchange called C
 ...to("rabbitmq://localhost/B")
 -------------------------------
 
+Declaring a headers exchange and queue
+
+[source,java]
+---------------------------------------------------------------------------------
+from("rabbitmq://localhost/ex?exchangeType=headers&queue=q&bindingArgs=bindArgs")
+---------------------------------------------------------------------------------
+
+and place corresponding Map<String, Object> with the id of "bindArgs" in the Registry.
+
+For example declaring a method in spring
+
+[source,java]
+---------------------------------------------------------------------------------
+@Bean(name="bindArgs")
+public Map<String, Object> bindArgsBuilder() {
+    return Collections.singletonMap("foo", "bar");
+}
+---------------------------------------------------------------------------------
+
 ### See Also
 
 * link:configuring-camel.html[Configuring Camel]

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/ArgsConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/ArgsConfigurer.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/ArgsConfigurer.java
index 71fd212..0ed1bbb 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/ArgsConfigurer.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/ArgsConfigurer.java
@@ -18,6 +18,17 @@ package org.apache.camel.component.rabbitmq;
 
 import java.util.Map;
 
+/**
+ * @deprecated The endpoint uri properties
+ * <ul>
+ *     <li>{@link RabbitMQEndpoint#setExchangeArgs(Map)}</li>
+ *     <li>{@link RabbitMQEndpoint#setQueueArgs(Map)}</li>
+ *     <li>{@link RabbitMQEndpoint#setBindingArgs(Map)}</li>
+ * </ul>
+ *
+ * are favoured over their configurer counterparts.
+ */
+@Deprecated
 public interface ArgsConfigurer {
     
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
index 1a0c6d8..b38eae9 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQDeclareSupport.java
@@ -40,7 +40,7 @@ public class RabbitMQDeclareSupport {
         if (endpoint.getDeadLetterExchange() != null) {
             // TODO Do we need to setup the args for the DeadLetter?
             declareExchange(channel, endpoint.getDeadLetterExchange(), endpoint.getDeadLetterExchangeType(), Collections.<String, Object>emptyMap());
-            declareAndBindQueue(channel, endpoint.getDeadLetterQueue(), endpoint.getDeadLetterExchange(), endpoint.getDeadLetterRoutingKey(), null);
+            declareAndBindQueue(channel, endpoint.getDeadLetterQueue(), endpoint.getDeadLetterExchange(), endpoint.getDeadLetterRoutingKey(), null, null);
         }
     }
 
@@ -51,7 +51,7 @@ public class RabbitMQDeclareSupport {
 
         if (shouldDeclareQueue()) {
             // need to make sure the queueDeclare is same with the exchange declare
-            declareAndBindQueue(channel, endpoint.getQueue(), endpoint.getExchangeName(), endpoint.getRoutingKey(), resolvedQueueArguments());
+            declareAndBindQueue(channel, endpoint.getQueue(), endpoint.getExchangeName(), endpoint.getRoutingKey(), resolvedQueueArguments(), endpoint.getBindingArgs());
         }
     }
 
@@ -59,6 +59,7 @@ public class RabbitMQDeclareSupport {
         Map<String, Object> queueArgs = new HashMap<>();
         populateQueueArgumentsFromDeadLetterExchange(queueArgs);
         populateQueueArgumentsFromConfigurer(queueArgs);
+        queueArgs.putAll(endpoint.getQueueArgs());
         return queueArgs;
     }
 
@@ -76,6 +77,7 @@ public class RabbitMQDeclareSupport {
         if (endpoint.getExchangeArgsConfigurer() != null) {
             endpoint.getExchangeArgsConfigurer().configurArgs(exchangeArgs);
         }
+        exchangeArgs.putAll(endpoint.getExchangeArgs());
         return exchangeArgs;
     }
 
@@ -101,11 +103,17 @@ public class RabbitMQDeclareSupport {
         channel.exchangeDeclare(exchange, exchangeType, endpoint.isDurable(), endpoint.isAutoDelete(), exchangeArgs);
     }
 
-    private void declareAndBindQueue(final Channel channel, final String queue, final String exchange, final String routingKey, final Map<String, Object> arguments)
+    private void declareAndBindQueue(final Channel channel,
+                                     final String queue,
+                                     final String exchange,
+                                     final String routingKey,
+                                     final Map<String, Object> queueArgs,
+                                     final Map<String, Object> bindingArgs)
+
             throws IOException {
-        channel.queueDeclare(queue, endpoint.isDurable(), endpoint.isExclusive(), endpoint.isAutoDelete(), arguments);
+        channel.queueDeclare(queue, endpoint.isDurable(), endpoint.isExclusive(), endpoint.isAutoDelete(), queueArgs);
         if (shouldBindQueue()) {
-            channel.queueBind(queue, exchange, emptyIfNull(routingKey));
+            channel.queueBind(queue, exchange, emptyIfNull(routingKey), bindingArgs);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
index 7ac249a..60e409d 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.rabbitmq;
 
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ExecutorService;
@@ -142,6 +143,12 @@ public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint {
     @UriParam(label = "producer")
     private boolean immediate;
     @UriParam(label = "advanced")
+    private Map<String, Object> exchangeArgs = new HashMap<>();
+    @UriParam(label = "advanced")
+    private Map<String, Object> queueArgs = new HashMap<>();
+    @UriParam(label = "advanced")
+    private Map<String, Object> bindingArgs = new HashMap<>();
+    @UriParam(label = "advanced")
     private ArgsConfigurer queueArgsConfigurer;
     @UriParam(label = "advanced")
     private ArgsConfigurer exchangeArgsConfigurer;
@@ -754,6 +761,39 @@ public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint {
         this.immediate = immediate;
     }
 
+    /**
+     * Key/value args for configuring the exchange parameters when declare=true
+     */
+    public void setExchangeArgs(Map<String, Object> exchangeArgs) {
+        this.exchangeArgs = exchangeArgs;
+    }
+
+    public Map<String, Object> getExchangeArgs() {
+        return exchangeArgs;
+    }
+
+    /**
+     * Key/value args for configuring the queue parameters when declare=true
+     */
+    public void setQueueArgs(Map<String, Object> queueArgs) {
+        this.queueArgs = queueArgs;
+    }
+
+    public Map<String, Object> getQueueArgs() {
+        return queueArgs;
+    }
+
+    /**
+     * Key/value args for configuring the queue binding parameters when declare=true
+     */
+    public void setBindingArgs(Map<String, Object> bindingArgs) {
+        this.bindingArgs = bindingArgs;
+    }
+
+    public Map<String, Object> getBindingArgs() {
+        return bindingArgs;
+    }
+
     public ArgsConfigurer getQueueArgsConfigurer() {
         return queueArgsConfigurer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/AbstractRabbitMQIntTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/AbstractRabbitMQIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/AbstractRabbitMQIntTest.java
new file mode 100644
index 0000000..fdb2cb8
--- /dev/null
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/AbstractRabbitMQIntTest.java
@@ -0,0 +1,43 @@
+/**
+ * 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.rabbitmq;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+import com.rabbitmq.client.Connection;
+import com.rabbitmq.client.ConnectionFactory;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public abstract class AbstractRabbitMQIntTest extends CamelTestSupport {
+
+    /**
+     * Helper method for creating a rabbitmq connection to the test instance of the
+     * rabbitmq server.
+     * @return
+     * @throws IOException
+     * @throws TimeoutException
+     */
+    protected Connection connection() throws IOException, TimeoutException {
+        ConnectionFactory factory = new ConnectionFactory();
+        factory.setHost("localhost");
+        factory.setPort(5672);
+        factory.setUsername("cameltest");
+        factory.setPassword("cameltest");
+        factory.setVirtualHost("/");
+        return factory.newConnection();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java
index 91cefb2..842f0d0 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java
@@ -18,7 +18,10 @@ package org.apache.camel.component.rabbitmq;
 
 import java.io.IOException;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.TimeoutException;
 
 import com.rabbitmq.client.AMQP;
@@ -30,12 +33,18 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class RabbitMQConsumerIntTest extends CamelTestSupport {
+public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
 
     private static final String EXCHANGE = "ex1";
+    private static final String HEADERS_EXCHANGE = "ex2";
+    private static final String QUEUE = "q1";
+    private static final String HEADER_KEY = "foo";
+    private static final String HEADER_VALUE = "bar";
+    private static final String MSG = "hello world";
 
     @EndpointInject(uri = "rabbitmq:localhost:5672/" + EXCHANGE + "?username=cameltest&password=cameltest")
     private Endpoint from;
@@ -43,6 +52,9 @@ public class RabbitMQConsumerIntTest extends CamelTestSupport {
     @EndpointInject(uri = "mock:result")
     private MockEndpoint to;
 
+    @EndpointInject(uri = "rabbitmq:localhost:5672/" + HEADERS_EXCHANGE + "?username=cameltest&password=cameltest&exchangeType=headers&queue=" + QUEUE + "&bindingArgs=#bindArgs")
+    private Endpoint headersExchangeWithQueue;
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -50,29 +62,32 @@ public class RabbitMQConsumerIntTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 from(from).to(to);
+                from(headersExchangeWithQueue).to(to);
             }
         };
     }
 
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+
+        Map<String, Object> bindingArgs = new HashMap<>();
+        jndi.bind("bindArgs", bindingArgs);
+
+        return jndi;
+    }
+
     @Test
     public void sentMessageIsReceived() throws InterruptedException, IOException, TimeoutException {
 
         to.expectedMessageCount(1);
         to.expectedHeaderReceived(RabbitMQConstants.REPLY_TO, "myReply");
 
-        ConnectionFactory factory = new ConnectionFactory();
-        factory.setHost("localhost");
-        factory.setPort(5672);
-        factory.setUsername("cameltest");
-        factory.setPassword("cameltest");
-        factory.setVirtualHost("/");
-        Connection conn = factory.newConnection();
-
         AMQP.BasicProperties.Builder properties = new AMQP.BasicProperties.Builder();
         properties.replyTo("myReply");
 
-        Channel channel = conn.createChannel();
-        channel.basicPublish(EXCHANGE, "", properties.build(), "hello world".getBytes());
+        Channel channel = connection().createChannel();
+        channel.basicPublish(EXCHANGE, "", properties.build(), MSG.getBytes());
 
         to.assertIsSatisfied();
     }
@@ -84,19 +99,36 @@ public class RabbitMQConsumerIntTest extends CamelTestSupport {
         to.expectedMessageCount(1);
         to.expectedHeaderReceived(RabbitMQConstants.TIMESTAMP, timestamp);
 
-        ConnectionFactory factory = new ConnectionFactory();
-        factory.setHost("localhost");
-        factory.setPort(5672);
-        factory.setUsername("cameltest");
-        factory.setPassword("cameltest");
-        factory.setVirtualHost("/");
-        Connection conn = factory.newConnection();
 
         AMQP.BasicProperties.Builder properties = new AMQP.BasicProperties.Builder();
         properties.timestamp(timestamp);
 
-        Channel channel = conn.createChannel();
-        channel.basicPublish(EXCHANGE, "", properties.build(), "hello world".getBytes());
+        Channel channel = connection().createChannel();
+        channel.basicPublish(EXCHANGE, "", properties.build(), MSG.getBytes());
+
+        to.assertIsSatisfied();
+    }
+
+    /**
+     * Tests the proper rabbit binding arguments are in place when the headersExchangeWithQueue is created.
+     * Should only receive messages with the header [foo=bar]
+     */
+    @Test
+    public void sentMessageIsReceivedWithHeadersRouting() throws InterruptedException, IOException, TimeoutException {
+        //should only be one message that makes it through because only
+        //one has the correct header set
+        to.expectedMessageCount(1);
+
+        AMQP.BasicProperties.Builder properties = new AMQP.BasicProperties.Builder();
+        properties.headers(Collections.singletonMap(HEADER_KEY, HEADER_VALUE));
+
+        AMQP.BasicProperties.Builder nonMatchingProperties = new AMQP.BasicProperties.Builder();
+        nonMatchingProperties.headers(Collections.singletonMap(HEADER_KEY, "wrong-value"));
+
+        Channel channel = connection().createChannel();
+        channel.basicPublish(HEADERS_EXCHANGE, "", properties.build(), MSG.getBytes());
+        channel.basicPublish(HEADERS_EXCHANGE, "", null, MSG.getBytes());
+        channel.basicPublish(HEADERS_EXCHANGE, "", nonMatchingProperties.build(), MSG.getBytes());
 
         to.assertIsSatisfied();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
index d6c083c..648019f 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java
@@ -51,8 +51,14 @@ public class RabbitMQEndpointTest extends CamelTestSupport {
             public void configurArgs(Map<String, Object> args) {
                 // do nothing here
             }
-            
+
         });
+
+        HashMap<String, Object> args = new HashMap<>();
+        args.put("foo", "bar");
+        registry.bind("args", args);
+
+
         return registry;
     }
 
@@ -159,10 +165,39 @@ public class RabbitMQEndpointTest extends CamelTestSupport {
     }
 
     @Test
-    public void testArgConfigurer() throws Exception {
+    public void testQueueArgsConfigurer() throws Exception {
         RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?queueArgsConfigurer=#argsConfigurer", RabbitMQEndpoint.class);
         assertNotNull("We should get the queueArgsConfigurer here.", endpoint.getQueueArgsConfigurer());
         assertNull("We should not get the exchangeArgsConfigurer here.", endpoint.getExchangeArgsConfigurer());
+        assertTrue("We should not get the bindingArgsConfigurer here.", endpoint.getBindingArgs().isEmpty());
+    }
+
+    @Test
+    public void testBindingArgs() throws Exception {
+        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?bindingArgs=#args", RabbitMQEndpoint.class);
+        assertEquals("We should get the bindingArgsConfigurer here.", 1, endpoint.getBindingArgs().size());
+        assertNull("We should not get the queueArgsConfigurer here.", endpoint.getQueueArgsConfigurer());
+        assertNull("We should not get the exchangeArgsConfigurer here.", endpoint.getExchangeArgsConfigurer());
+    }
+
+    @Test
+    public void testQueueArgs() throws Exception {
+        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?queueArgs=#args", RabbitMQEndpoint.class);
+        assertEquals("We should get the queueArgs here.", 1, endpoint.getQueueArgs().size());
+        assertTrue("We should not get the binding args here.", endpoint.getBindingArgs().isEmpty());
+        assertTrue("We should not get the exchange args here.", endpoint.getExchangeArgs().isEmpty());
+        assertNull("We should not get the exchangeArgsConfigurer here.", endpoint.getExchangeArgsConfigurer());
+        assertNull("We should not get the queueArgsConfigurer here.", endpoint.getQueueArgsConfigurer());
+    }
+
+    @Test
+    public void testExchangeArgs() throws Exception {
+        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?exchangeArgs=#args", RabbitMQEndpoint.class);
+        assertEquals("We should get the exchangeArgs here.", 1, endpoint.getExchangeArgs().size());
+        assertTrue("We should not get the binding args here.", endpoint.getBindingArgs().isEmpty());
+        assertTrue("We should not get the queue args here.", endpoint.getQueueArgs().isEmpty());
+        assertNull("We should not get the exchangeArgsConfigurer here.", endpoint.getExchangeArgsConfigurer());
+        assertNull("We should not get the queueArgsConfigurer here.", endpoint.getQueueArgsConfigurer());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQInOutIntTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQInOutIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQInOutIntTest.java
index bdd7119..4a956ef 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQInOutIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQInOutIntTest.java
@@ -64,7 +64,7 @@ public class RabbitMQInOutIntTest extends CamelTestSupport {
     @EndpointInject(uri = "rabbitmq:localhost:5672/" + EXCHANGE_NO_ACK + "?threadPoolSize=1&exchangeType=direct&username=cameltest&password=cameltest"
             + "&autoAck=false&autoDelete=false&durable=false&queue=q5&routingKey=" + ROUTING_KEY
             + "&transferException=true&requestTimeout=" + TIMEOUT_MS
-            + "&queueArgsConfigurer=#queueArgs")
+            + "&queueArgs=#queueArgs")
     private Endpoint noAutoAckEndpoint;
 
     @EndpointInject(uri = "mock:result")
@@ -74,12 +74,8 @@ public class RabbitMQInOutIntTest extends CamelTestSupport {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        ArgsConfigurer queueArgs = new ArgsConfigurer() {
-            @Override
-            public void configurArgs(Map<String, Object> args) {
-                args.put("x-expires", 60000);
-            }
-        };
+        HashMap<String, Object> queueArgs = new HashMap<>();
+        queueArgs.put("x-expires", 60000);
         jndi.bind("queueArgs", queueArgs);
 
         return jndi;

http://git-wip-us.apache.org/repos/asf/camel/blob/c22d808a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java
index 5be1be1..a4f3550 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java
@@ -36,7 +36,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-public class RabbitMQProducerIntTest extends CamelTestSupport {
+public class RabbitMQProducerIntTest extends AbstractRabbitMQIntTest {
     private static final String EXCHANGE = "ex1";
     private static final String ROUTE = "route1";
     private static final String BASIC_URI_FORMAT = "rabbitmq:localhost:5672/%s?routingKey=%s&username=cameltest&password=cameltest&skipQueueDeclare=true";
@@ -86,7 +86,7 @@ public class RabbitMQProducerIntTest extends CamelTestSupport {
 
     @Before
     public void setUpRabbitMQ() throws Exception {
-        connection = createTestConnection();
+        connection = connection();
         channel = connection.createChannel();
         channel.queueDeclare("sammyq", false, false, true, null);
         channel.queueBind("sammyq", EXCHANGE, ROUTE);
@@ -162,16 +162,6 @@ public class RabbitMQProducerIntTest extends CamelTestSupport {
         assertThatBodiesReceivedIn(received);
     }
 
-    private Connection createTestConnection() throws IOException, TimeoutException {
-        ConnectionFactory factory = new ConnectionFactory();
-        factory.setHost("localhost");
-        factory.setPort(5672);
-        factory.setUsername("cameltest");
-        factory.setPassword("cameltest");
-        factory.setVirtualHost("/");
-        return factory.newConnection();
-    }
-
     private class ArrayPopulatingConsumer extends DefaultConsumer {
         private final List<String> received;
 


[2/3] camel git commit: CAMEL-10759 Typo in documentation

Posted by da...@apache.org.
CAMEL-10759 Typo in documentation 



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

Branch: refs/heads/master
Commit: 6899bca535db2fb8275edf06edef7dd35e6d7893
Parents: c22d808
Author: Paul Watson <pa...@pdwtech.com>
Authored: Mon Jan 30 09:56:30 2017 +0000
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jan 30 12:49:54 2017 +0100

----------------------------------------------------------------------
 components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6899bca5/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
index 8a7b4df..84480cd 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
@@ -243,7 +243,7 @@ Declaring a headers exchange and queue
 
 [source,java]
 ---------------------------------------------------------------------------------
-from("rabbitmq://localhost/ex?exchangeType=headers&queue=q&bindingArgs=bindArgs")
+from("rabbitmq://localhost/ex?exchangeType=headers&queue=q&bindingArgs=#bindArgs")
 ---------------------------------------------------------------------------------
 
 and place corresponding Map<String, Object> with the id of "bindArgs" in the Registry.