camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1439634 - in /camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper: ./ policy/
Date Mon, 28 Jan 2013 21:07:13 GMT
Author: cmueller
Date: Mon Jan 28 21:07:12 2013
New Revision: 1439634

URL: http://svn.apache.org/viewvc?rev=1439634&view=rev
Log:
use AvailablePortFinder for Zookeeper unit tests

Modified:
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeChildrenTest.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeDataTest.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperConnectionManagerTest.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperProducerTest.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/FailoverRoutePolicyTest.java
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/ZookeeperRoutePolicyTest.java

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeChildrenTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeChildrenTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeChildrenTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeChildrenTest.java
Mon Jan 28 21:07:12 2013
@@ -38,7 +38,9 @@ public class ConsumeChildrenTest extends
     protected RouteBuilder[] createRouteBuilders() throws Exception {
         return new RouteBuilder[] {new RouteBuilder() {
             public void configure() throws Exception {
-                from("zookeeper://localhost:39913/grimm?repeat=true&listChildren=true").sort(body(),
new NaturalSortComparator(Order.Descending)).to("mock:zookeeper-data");
+                from("zookeeper://localhost:" + getServerPort() + "/grimm?repeat=true&listChildren=true")
+                    .sort(body(), new NaturalSortComparator(Order.Descending))
+                    .to("mock:zookeeper-data");
             }
         }};
     }

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeDataTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeDataTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeDataTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ConsumeDataTest.java
Mon Jan 28 21:07:12 2013
@@ -30,7 +30,7 @@ public class ConsumeDataTest extends Zoo
     protected RouteBuilder[] createRouteBuilders() throws Exception {
         return new RouteBuilder[] {new RouteBuilder() {
             public void configure() throws Exception {
-                from("zookeeper://localhost:39913/camel?repeat=true").to("mock:zookeeper-data");
+                from("zookeeper://localhost:" + getServerPort() + "/camel?repeat=true").to("mock:zookeeper-data");
             }
         }};
     }
@@ -77,7 +77,6 @@ public class ConsumeDataTest extends Zoo
 
     @Test
     public void deletionOfAwaitedNodeCausesNoFailure() throws Exception {
-
         MockEndpoint mock = getMockEndpoint("mock:zookeeper-data");
         mock.expectedMinimumMessageCount(11);
         createCamelNode();

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java
Mon Jan 28 21:07:12 2013
@@ -104,7 +104,7 @@ public class ZooKeeperManagedEndpointTes
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("zookeeper://localhost:39913/node").to("mock:test");
+                from("zookeeper://localhost:" + ZooKeeperTestSupport.getServerPort() + "/node").to("mock:test");
             }
         };
     }

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
Mon Jan 28 21:07:12 2013
@@ -32,6 +32,7 @@ import java.util.concurrent.CountDownLat
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
@@ -57,17 +58,18 @@ import org.slf4j.LoggerFactory;
 public class ZooKeeperTestSupport extends CamelTestSupport {
 
     protected static TestZookeeperServer server;
-    
     protected static TestZookeeperClient client;
 
+    private static volatile int port;
     private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperTestSupport.class);
  
     protected String testPayload = "This is a test";
-
     protected byte[] testPayloadBytes = testPayload.getBytes();
         
     @BeforeClass
     public static void setupTestServer() throws Exception {
+        port = AvailablePortFinder.getNextAvailable(39913);
+        
         LOG.info("Starting Zookeeper Test Infrastructure");
         server = new TestZookeeperServer(getServerPort(), clearServerData());
         waitForServerUp("localhost:" + getServerPort(), 1000);
@@ -89,7 +91,7 @@ public class ZooKeeperTestSupport extend
     }
 
     protected static int getServerPort() {
-        return 39913;
+        return port;
     }
 
     protected static int getTestClientSessionTimeout() {
@@ -145,9 +147,7 @@ public class ZooKeeperTestSupport extend
         public static int x;
 
         private final Logger log = LoggerFactory.getLogger(getClass());
-
         private ZooKeeper zk;
-
         private CountDownLatch connected = new CountDownLatch(1);
 
 

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperConnectionManagerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperConnectionManagerTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperConnectionManagerTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperConnectionManagerTest.java
Mon Jan 28 21:07:12 2013
@@ -25,7 +25,7 @@ public class ZookeeperConnectionManagerT
     @Test
     public void shouldWaitForConnection() {
         ZooKeeperConfiguration config = new ZooKeeperConfiguration();
-        config.addZookeeperServer("localhost:39913");
+        config.addZookeeperServer("localhost:" + getServerPort());
 
         ZooKeeperComponent component = new ZooKeeperComponent(config);
         component.setConfiguration(config);

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperProducerTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperProducerTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZookeeperProducerTest.java
Mon Jan 28 21:07:12 2013
@@ -36,29 +36,28 @@ import static org.apache.camel.component
 public class ZookeeperProducerTest extends ZooKeeperTestSupport {
 
     private String zookeeperUri;
-
     private String testPayload = "TestPayload";
 
     @Override
     protected RouteBuilder[] createRouteBuilders() throws Exception {
         return new RouteBuilder[] {new RouteBuilder() {
             public void configure() throws Exception {
-                zookeeperUri = "zookeeper://localhost:39913/node?create=true";
+                zookeeperUri = "zookeeper://localhost:" + getServerPort() + "/node?create=true";
                 from("direct:roundtrip").to(zookeeperUri).to("mock:producer-out");
                 from(zookeeperUri).to("mock:consumed-from-node");
             }
         }, new RouteBuilder() {
             public void configure() throws Exception {
-                from("direct:no-create-fails-set").to("zookeeper://localhost:39913/doesnotexist");
+                from("direct:no-create-fails-set").to("zookeeper://localhost:" + getServerPort()
+ "/doesnotexist");
             }
         }, new RouteBuilder() {
             public void configure() throws Exception {
-                from("direct:node-from-header").to("zookeeper://localhost:39913/notset?create=true");
-                from("zookeeper://localhost:39913/set?create=true").to("mock:consumed-from-set-node");
+                from("direct:node-from-header").to("zookeeper://localhost:" + getServerPort()
+ "/notset?create=true");
+                from("zookeeper://localhost:" + getServerPort() + "/set?create=true").to("mock:consumed-from-set-node");
             }
         }, new RouteBuilder() {
             public void configure() throws Exception {
-                from("direct:create-mode").to("zookeeper://localhost:39913/persistent?create=true&createMode=PERSISTENT").to("mock:create-mode");
+                from("direct:create-mode").to("zookeeper://localhost:" + getServerPort()
+ "/persistent?create=true&createMode=PERSISTENT").to("mock:create-mode");
             }
         }, new RouteBuilder() {
             public void configure() throws Exception {
@@ -157,7 +156,7 @@ public class ZookeeperProducerTest exten
         Exchange exchange = createExchangeWithBody(testPayload);
         exchange.getIn().setHeader(ZOOKEEPER_NODE, "/set-listing/firstborn");
         exchange.setPattern(ExchangePattern.InOut);
-        template.send("zookeeper://localhost:39913/set-listing?create=true&listChildren=true",
exchange);
+        template.send("zookeeper://localhost:" + getServerPort() + "/set-listing?create=true&listChildren=true",
exchange);
         List<?> children = exchange.getOut().getMandatoryBody(List.class);
         assertEquals(1, children.size());
         assertEquals("firstborn", children.get(0));

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/FailoverRoutePolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/FailoverRoutePolicyTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/FailoverRoutePolicyTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/FailoverRoutePolicyTest.java
Mon Jan 28 21:07:12 2013
@@ -112,7 +112,7 @@ public class FailoverRoutePolicyTest ext
         }
 
         public void configure() throws Exception {
-            ZooKeeperRoutePolicy policy = new ZooKeeperRoutePolicy("zookeeper:localhost:39913/someapp/somepolicy",
1);
+            ZooKeeperRoutePolicy policy = new ZooKeeperRoutePolicy("zookeeper:localhost:"
+ getServerPort() + "/someapp/somepolicy", 1);
             from("vm:" + routename).routePolicy(policy).id(routename).to("mock:controlled");
         }
     };

Modified: camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/ZookeeperRoutePolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/ZookeeperRoutePolicyTest.java?rev=1439634&r1=1439633&r2=1439634&view=diff
==============================================================================
--- camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/ZookeeperRoutePolicyTest.java
(original)
+++ camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/policy/ZookeeperRoutePolicyTest.java
Mon Jan 28 21:07:12 2013
@@ -41,7 +41,7 @@ public class ZookeeperRoutePolicyTest ex
 
     public static class ZooKeeperPolicyEnforcedRoute extends RouteBuilder {
         public void configure() throws Exception {
-            ZooKeeperRoutePolicy policy = new ZooKeeperRoutePolicy("zookeeper:localhost:39913/someapp/somepolicy",
1);
+            ZooKeeperRoutePolicy policy = new ZooKeeperRoutePolicy("zookeeper:localhost:"
+ getServerPort() + "/someapp/somepolicy", 1);
             from("direct:policy-controlled").routePolicy(policy).to("mock:controlled");
         }
     };



Mime
View raw message