camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1167162 - /camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java
Date Fri, 09 Sep 2011 13:42:08 GMT
Author: cschneider
Date: Fri Sep  9 13:42:07 2011
New Revision: 1167162

URL: http://svn.apache.org/viewvc?rev=1167162&view=rev
Log:
CAMEL-4431 Quick fix for test failure by using a new directory for each test class

Modified:
    camel/trunk/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperTestSupport.java

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=1167162&r1=1167161&r2=1167162&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
Fri Sep  9 13:42:07 2011
@@ -98,33 +98,43 @@ public class ZooKeeperTestSupport extend
     public static class TestZookeeperServer {
         private NIOServerCnxn.Factory connectionFactory;
         private ZooKeeperServer zkServer;
-
+        
+        private static int count = 0;
+        File zookeeperBaseDir;
+        
         public TestZookeeperServer(int clientPort, boolean clearServerData) throws Exception
{
-
+            // TODO This is necessary as zookeeper does not delete the log dir when it shuts
down. Remove as soon as zookeeper shutdown works
+            zookeeperBaseDir = new File("./target/zookeeper" + count++);
             if (clearServerData) {
-                File working = new File("./target/zookeeper");
-                deleteDir(working);
-                if (working.exists()) {
-                    throw new Exception("Could not delete Test Zookeeper Server working dir
./target/zookeeper");
-                }
+                cleanZookeeperDir();
             }
             zkServer = new ZooKeeperServer();
-            File dataDir = new File("./target/zookeeper/log");
-            File snapDir = new File("./target/zookeeper/data");
+            File dataDir = new File(zookeeperBaseDir, "log");
+            File snapDir = new File(zookeeperBaseDir, "data");
             FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);
             zkServer.setTxnLogFactory(ftxn);
             zkServer.setTickTime(1000);
             connectionFactory = new NIOServerCnxn.Factory(new InetSocketAddress("localhost",
clientPort), 0);
             connectionFactory.startup(zkServer);
         }
+        
+        private void cleanZookeeperDir() throws Exception {
+            File working = zookeeperBaseDir;
+            deleteDir(working);
+            if (working.exists()) {
+                throw new Exception("Could not delete Test Zookeeper Server working dir "
+ zookeeperBaseDir);
+            }
+        }
 
         public void shutdown() throws Exception {
             connectionFactory.shutdown();
             connectionFactory.join();
+            zkServer.shutdown();
             while (zkServer.isRunning()) {
                 zkServer.shutdown();
                 Thread.sleep(100);
             }
+            //cleanZookeeperDir();
         }
     }
 



Mime
View raw message