camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: Use dynamic ports in test
Date Sat, 04 Mar 2017 09:10:19 GMT
Repository: camel
Updated Branches:
  refs/heads/master f361fb772 -> 7445dbccb


Use dynamic ports in test


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

Branch: refs/heads/master
Commit: 7445dbccb075fe6930b6fc8f7d7fa4c65039d9f4
Parents: f361fb7
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Mar 4 10:09:28 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Mar 4 10:10:10 2017 +0100

----------------------------------------------------------------------
 .../component/sip/PublishSubscribeTest.java     | 35 ++++++++++++++------
 1 file changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7445dbcc/components/camel-sip/src/test/java/org/apache/camel/component/sip/PublishSubscribeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sip/src/test/java/org/apache/camel/component/sip/PublishSubscribeTest.java
b/components/camel-sip/src/test/java/org/apache/camel/component/sip/PublishSubscribeTest.java
index 3343d83..ac282f0 100644
--- a/components/camel-sip/src/test/java/org/apache/camel/component/sip/PublishSubscribeTest.java
+++ b/components/camel-sip/src/test/java/org/apache/camel/component/sip/PublishSubscribeTest.java
@@ -23,27 +23,41 @@ import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 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.Test;
 
 public class PublishSubscribeTest extends CamelTestSupport {
-    
+
+    private int port1;
+    private int port2;
+    private int port3;
+
     @EndpointInject(uri = "mock:neverland")
-    protected MockEndpoint unreachableEndpoint;
+    private MockEndpoint unreachableEndpoint;
 
     @EndpointInject(uri = "mock:notification")
-    protected MockEndpoint resultEndpoint;
+    private MockEndpoint resultEndpoint;
 
     @Produce(uri = "direct:start")
-    protected ProducerTemplate producerTemplate;
-    
+    private ProducerTemplate producerTemplate;
+
+    @Override
+    public void setUp() throws Exception {
+        port1 = AvailablePortFinder.getNextAvailable(17189);
+        port2 = AvailablePortFinder.getNextAvailable(port1 + 1);
+        port3 = AvailablePortFinder.getNextAvailable(port2 + 1);
+
+        super.setUp();
+    }
+
     @Test
     public void testPresenceAgentBasedPubSub() throws Exception {
         unreachableEndpoint.expectedMessageCount(0);
         resultEndpoint.expectedMinimumMessageCount(1);
-        
+
         producerTemplate.sendBodyAndHeader(
-            "sip://agent@localhost:5252?stackName=client&eventHeaderName=evtHdrName&eventId=evtid&fromUser=user2&fromHost=localhost&fromPort=3534",

+            "sip://agent@localhost:" + port1 + "?stackName=client&eventHeaderName=evtHdrName&eventId=evtid&fromUser=user2&fromHost=localhost&fromPort="
+ port3,
             "EVENT_A",
             "REQUEST_METHOD", Request.PUBLISH);         
 
@@ -56,11 +70,12 @@ public class PublishSubscribeTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {  
                 // Create PresenceAgent
-                from("sip://agent@localhost:5252?stackName=PresenceAgent&presenceAgent=true&eventHeaderName=evtHdrName&eventId=evtid")
+                fromF("sip://agent@localhost:%s?stackName=PresenceAgent&presenceAgent=true&eventHeaderName=evtHdrName&eventId=evtid",
port1)
+                    .to("log:neverland")
                     .to("mock:neverland");
                 
-                from("sip://johndoe@localhost:5254?stackName=Subscriber&toUser=agent&toHost=localhost&toPort=5252&eventHeaderName=evtHdrName&eventId=evtid")
-                    .to("log:ReceivedEvent")
+                fromF("sip://johndoe@localhost:%s?stackName=Subscriber&toUser=agent&toHost=localhost&toPort=%s&eventHeaderName=evtHdrName&eventId=evtid",
port2, port1)
+                    .to("log:notification")
                     .to("mock:notification");
             }
         };


Mime
View raw message