You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/01/27 08:10:55 UTC

[camel] branch master updated: Fix camel-rabbitmq integration test

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b7d22d  Fix camel-rabbitmq integration test
1b7d22d is described below

commit 1b7d22dab6b03fa40767c71927ea3afa079bd372
Author: Denis Istomin <is...@gmail.com>
AuthorDate: Sun Jan 26 18:35:55 2020 +0500

    Fix camel-rabbitmq integration test
---
 components/camel-rabbitmq/pom.xml                      |  5 +++++
 .../src/main/docs/rabbitmq-component.adoc              |  4 +++-
 .../component/rabbitmq/RabbitMQConsumerIntTest.java    | 18 +++++++++++++++---
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/components/camel-rabbitmq/pom.xml b/components/camel-rabbitmq/pom.xml
index c70f19c..8a21b63 100644
--- a/components/camel-rabbitmq/pom.xml
+++ b/components/camel-rabbitmq/pom.xml
@@ -105,6 +105,11 @@
             <artifactId>log4j-slf4j-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
index b3af8f9..0a39cd0 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
@@ -446,7 +446,9 @@ For example declaring a method in Spring
 ----
 @Bean(name = "bindArgs")
 public Map<String, Object> bindArgsBuilder() {
-    return Collections.singletonMap("foo", "bar");
+    return new HashMap<String, Object>() {{
+        put("binding.foo", "bar");
+    }};
 }
 ----
 
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 34035ca..d042814 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
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import com.rabbitmq.client.AMQP;
@@ -31,6 +32,7 @@ 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.awaitility.Awaitility;
 import org.junit.Test;
 
 public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
@@ -53,7 +55,11 @@ public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
     private Endpoint headersExchangeWithQueueDefiniedInline;
     
     @BindToRegistry("args")
-    private Map<String, Object> bindingArgs = new HashMap<>();
+    private Map<String, Object> bindingArgs = new HashMap<String, Object>() {
+        {
+            put("binding.foo", "bar");
+        }
+    };
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -121,8 +127,8 @@ public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
      */
     @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
+        // Should only be one message that makes it through,
+        // because only one has the correct header set
         to.expectedMessageCount(1);
 
         Channel channel = connection().createChannel();
@@ -130,6 +136,12 @@ public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
         channel.basicPublish(HEADERS_EXCHANGE, "", null, MSG.getBytes());
         channel.basicPublish(HEADERS_EXCHANGE, "", propertiesWithHeader("foo", "bra"), MSG.getBytes());
 
+        // Only one message should be received, waiting for some other messages
+        Awaitility.await()
+                .during(1000, TimeUnit.MILLISECONDS)
+                .atMost(2000, TimeUnit.MILLISECONDS)
+                .until(() -> to.getReceivedCounter() >= 1);
+
         to.assertIsSatisfied();
     }