Repository: camel
Updated Branches:
  refs/heads/master f9a911361 -> e6a7caecc


Fix test name and logging


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

Branch: refs/heads/master
Commit: e59b00b22d11fa8e2ac14b0911c4024b4cb33cf4
Parents: f9a9113
Author: lburgazzoli <lburgazz...@gmail.com>
Authored: Wed Jun 28 10:35:00 2017 +0200
Committer: lburgazzoli <lburgazz...@gmail.com>
Committed: Wed Jun 28 15:03:32 2017 +0200

----------------------------------------------------------------------
 .../ha/ZooKeeperClientRoutePolicyTest.java      | 122 -------------------
 .../ha/ZooKeeperClusteredRoutePolicyTest.java   | 122 +++++++++++++++++++
 .../src/test/resources/log4j2.properties        |   2 +-
 3 files changed, 123 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e59b00b2/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClientRoutePolicyTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClientRoutePolicyTest.java
 
b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClientRoutePolicyTest.java
deleted file mode 100644
index 564940d..0000000
--- 
a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClientRoutePolicyTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * 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.zookeeper.ha;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.zookeeper.ZooKeeperTestSupport;
-import 
org.apache.camel.component.zookeeper.ZooKeeperTestSupport.TestZookeeperServer;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.ha.ClusteredRoutePolicyFactory;
-import org.apache.camel.test.AvailablePortFinder;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class ZooKeeperClientRoutePolicyTest {
-    private static final int PORT = AvailablePortFinder.getNextAvailable();
-    private static final Logger LOGGER = 
LoggerFactory.getLogger(ZooKeeperClientRoutePolicyTest.class);
-    private static final List<String> CLIENTS = IntStream.range(0, 
3).mapToObj(Integer::toString).collect(Collectors.toList());
-    private static final List<String> RESULTS = new ArrayList<>();
-    private static final ScheduledExecutorService SCHEDULER = 
Executors.newScheduledThreadPool(CLIENTS.size() * 2);
-    private static final CountDownLatch LATCH = new 
CountDownLatch(CLIENTS.size());
-
-    // ************************************
-    // Test
-    // ************************************
-
-    @Test
-    public void test() throws Exception {
-        TestZookeeperServer server = null;
-
-        try {
-            server = new TestZookeeperServer(PORT, true);
-            ZooKeeperTestSupport.waitForServerUp("localhost:" + PORT, 1000);
-
-            for (String id : CLIENTS) {
-                SCHEDULER.submit(() -> run(id));
-            }
-
-            LATCH.await(1, TimeUnit.MINUTES);
-            SCHEDULER.shutdownNow();
-
-            Assert.assertEquals(CLIENTS.size(), RESULTS.size());
-            Assert.assertTrue(RESULTS.containsAll(CLIENTS));
-        } finally {
-            if (server != null) {
-                server.shutdown();
-            }
-        }
-    }
-
-    // ************************************
-    // Run a Camel node
-    // ************************************
-
-    private static void run(String id) {
-        try {
-            CountDownLatch contextLatch = new CountDownLatch(1);
-
-            ZooKeeperClusterService service = new ZooKeeperClusterService();
-            service.setId("node-" + id);
-            service.setNodes("localhost:" + PORT);
-            service.setNamespace(null );
-
-            DefaultCamelContext context = new DefaultCamelContext();
-            context.disableJMX();
-            context.setName("context-" + id);
-            context.addService(service);
-            
context.addRoutePolicyFactory(ClusteredRoutePolicyFactory.forNamespace("/my-ns"));
-            context.addRoutes(new RouteBuilder() {
-                @Override
-                public void configure() throws Exception {
-                    from("timer:zookeeper?delay=1s&period=1s&repeatCount=1")
-                        .routeId("route-" + id)
-                        .process(e -> {
-                            LOGGER.debug("Node {} done", id);
-                            RESULTS.add(id);
-                            // Shutdown the context later on to give a chance 
to
-                            // other members to catch-up
-                            SCHEDULER.schedule(contextLatch::countDown, 2 + 
ThreadLocalRandom.current().nextInt(3), TimeUnit.SECONDS);
-                        });
-                }
-            });
-
-            // Start the context after some random time so the startup order
-            // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
-            context.start();
-
-            contextLatch.await();
-            context.stop();
-
-            LATCH.countDown();
-        } catch (Exception e) {
-            LOGGER.warn("", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/e59b00b2/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClusteredRoutePolicyTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClusteredRoutePolicyTest.java
 
b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClusteredRoutePolicyTest.java
new file mode 100644
index 0000000..d73648b
--- /dev/null
+++ 
b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ha/ZooKeeperClusteredRoutePolicyTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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.zookeeper.ha;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.zookeeper.ZooKeeperTestSupport;
+import 
org.apache.camel.component.zookeeper.ZooKeeperTestSupport.TestZookeeperServer;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.ha.ClusteredRoutePolicyFactory;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class ZooKeeperClusteredRoutePolicyTest {
+    private static final int PORT = AvailablePortFinder.getNextAvailable();
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ZooKeeperClusteredRoutePolicyTest.class);
+    private static final List<String> CLIENTS = IntStream.range(0, 
3).mapToObj(Integer::toString).collect(Collectors.toList());
+    private static final List<String> RESULTS = new ArrayList<>();
+    private static final ScheduledExecutorService SCHEDULER = 
Executors.newScheduledThreadPool(CLIENTS.size() * 2);
+    private static final CountDownLatch LATCH = new 
CountDownLatch(CLIENTS.size());
+
+    // ************************************
+    // Test
+    // ************************************
+
+    @Test
+    public void test() throws Exception {
+        TestZookeeperServer server = null;
+
+        try {
+            server = new TestZookeeperServer(PORT, true);
+            ZooKeeperTestSupport.waitForServerUp("localhost:" + PORT, 1000);
+
+            for (String id : CLIENTS) {
+                SCHEDULER.submit(() -> run(id));
+            }
+
+            LATCH.await(1, TimeUnit.MINUTES);
+            SCHEDULER.shutdownNow();
+
+            Assert.assertEquals(CLIENTS.size(), RESULTS.size());
+            Assert.assertTrue(RESULTS.containsAll(CLIENTS));
+        } finally {
+            if (server != null) {
+                server.shutdown();
+            }
+        }
+    }
+
+    // ************************************
+    // Run a Camel node
+    // ************************************
+
+    private static void run(String id) {
+        try {
+            CountDownLatch contextLatch = new CountDownLatch(1);
+
+            ZooKeeperClusterService service = new ZooKeeperClusterService();
+            service.setId("node-" + id);
+            service.setNodes("localhost:" + PORT);
+            service.setNamespace(null);
+
+            DefaultCamelContext context = new DefaultCamelContext();
+            context.disableJMX();
+            context.setName("context-" + id);
+            context.addService(service);
+            
context.addRoutePolicyFactory(ClusteredRoutePolicyFactory.forNamespace("/my-ns"));
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("timer:zookeeper?delay=1s&period=1s&repeatCount=1")
+                        .routeId("route-" + id)
+                        .process(e -> {
+                            LOGGER.debug("Node {} done", id);
+                            RESULTS.add(id);
+                            // Shutdown the context later on to give a chance 
to
+                            // other members to catch-up
+                            SCHEDULER.schedule(contextLatch::countDown, 2 + 
ThreadLocalRandom.current().nextInt(3), TimeUnit.SECONDS);
+                        });
+                }
+            });
+
+            // Start the context after some random time so the startup order
+            // changes for each test.
+            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            context.start();
+
+            contextLatch.await();
+            context.stop();
+
+            LATCH.countDown();
+        } catch (Exception e) {
+            LOGGER.warn("", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e59b00b2/components/camel-zookeeper/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/test/resources/log4j2.properties 
b/components/camel-zookeeper/src/test/resources/log4j2.properties
index 2e7cfa5..d7bb987 100644
--- a/components/camel-zookeeper/src/test/resources/log4j2.properties
+++ b/components/camel-zookeeper/src/test/resources/log4j2.properties
@@ -43,6 +43,6 @@ logger.springframework.name = org.springframework
 logger.springframework.level = WARN
 rootLogger.level = INFO
 #rootLogger.appenderRef.stdout.ref = out
-rootLogger.appenderRef.file.ref = out
+rootLogger.appenderRef.file.ref = file
 
 

Reply via email to