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 2016/02/29 09:32:53 UTC

[09/13] camel git commit: [camel-amqp] Avoiding tests' port conflicts.

[camel-amqp] Avoiding tests' port conflicts.


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

Branch: refs/heads/camel-2.16.x
Commit: 940077a429a46b9561ae9cf01578e6f2852998d5
Parents: a7f1846
Author: Henryk Konsek <he...@gmail.com>
Authored: Thu Dec 3 12:17:54 2015 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Feb 29 09:29:08 2016 +0100

----------------------------------------------------------------------
 .../camel/component/amqp/AMQPRouteTest.java     | 21 +++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/940077a4/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java b/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
index d5d37db..ce89bc6 100644
--- a/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
+++ b/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPRouteTest.java
@@ -21,6 +21,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -30,6 +31,8 @@ import static org.apache.camel.component.amqp.AMQPComponent.amqpComponent;
 
 public class AMQPRouteTest extends CamelTestSupport {
 
+    static int amqpPort = AvailablePortFinder.getNextAvailable();
+
     static BrokerService broker;
 
     @EndpointInject(uri = "mock:result")
@@ -41,7 +44,7 @@ public class AMQPRouteTest extends CamelTestSupport {
     public static void beforeClass() throws Exception {
         broker = new BrokerService();
         broker.setPersistent(false);
-        broker.addConnector("amqp://0.0.0.0:5672");
+        broker.addConnector("amqp://0.0.0.0:" + amqpPort);
         broker.start();
     }
 
@@ -54,13 +57,13 @@ public class AMQPRouteTest extends CamelTestSupport {
     public void testJmsQueue() throws Exception {
         resultEndpoint.expectedMessageCount(1);
         resultEndpoint.message(0).header("cheese").isEqualTo(123);
-        template.sendBodyAndHeader("amqp1-0:queue:ping", expectedBody, "cheese", 123);
+        template.sendBodyAndHeader("amqp:queue:ping", expectedBody, "cheese", 123);
         resultEndpoint.assertIsSatisfied();
     }
 
     @Test
     public void testRequestReply() {
-        String response = template.requestBody("amqp1-0:queue:inOut", expectedBody, String.class);
+        String response = template.requestBody("amqp:queue:inOut", expectedBody, String.class);
         assertEquals("response", response);
     }
 
@@ -68,31 +71,31 @@ public class AMQPRouteTest extends CamelTestSupport {
     public void testJmsTopic() throws Exception {
         resultEndpoint.expectedMessageCount(2);
         resultEndpoint.message(0).header("cheese").isEqualTo(123);
-        template.sendBodyAndHeader("amqp1-0:topic:ping", expectedBody, "cheese", 123);
+        template.sendBodyAndHeader("amqp:topic:ping", expectedBody, "cheese", 123);
         resultEndpoint.assertIsSatisfied();
     }
 
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
-        camelContext.addComponent("amqp1-0", amqpComponent("amqp://localhost:5672"));
+        camelContext.addComponent("amqp", amqpComponent("amqp://localhost:" + amqpPort));
         return camelContext;
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("amqp1-0:queue:ping")
+                from("amqp:queue:ping")
                     .to("log:routing")
                     .to("mock:result");
 
-                from("amqp1-0:queue:inOut")
+                from("amqp:queue:inOut")
                         .setBody().constant("response");
 
-                from("amqp1-0:topic:ping")
+                from("amqp:topic:ping")
                         .to("log:routing")
                         .to("mock:result");
 
-                from("amqp1-0:topic:ping")
+                from("amqp:topic:ping")
                         .to("log:routing")
                         .to("mock:result");
             }