jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1360692 - in /jackrabbit/trunk/jackrabbit-core/src/test: java/org/apache/jackrabbit/core/cluster/ resources/org/apache/jackrabbit/core/cluster/
Date Thu, 12 Jul 2012 14:19:26 GMT
Author: thomasm
Date: Thu Jul 12 14:19:26 2012
New Revision: 1360692

URL: http://svn.apache.org/viewvc?rev=1360692&view=rev
Log:
JCR-3385 DbClusterTest fails when port is already in use

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java?rev=1360692&r1=1360691&r2=1360692&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java
Thu Jul 12 14:19:26 2012
@@ -18,29 +18,20 @@ package org.apache.jackrabbit.core.clust
 
 import java.io.File;
 import java.io.IOException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.test.JUnitTest;
-import org.h2.tools.Server;
 
 /**
  * Tests clustering with a database.
  */
 public class ClusterDescriptorTest extends JUnitTest {
 
-    Server server1, server2;
-    RepositoryImpl rep1, rep2;
+    private RepositoryImpl rep1, rep2;
 
     public void setUp() throws Exception {
         deleteAll();
-        server1 = Server.createTcpServer("-tcpPort", "9001", "-baseDir",
-                "./target/descriptorClusterTest/db1", "-tcpAllowOthers").start();
-        server2 = Server.createTcpServer("-tcpPort", "9002", "-baseDir",
-                "./target/descriptorClusterTest/db2", "-tcpAllowOthers").start();
         FileUtils.copyFile(
                 new File("./src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml"),
                 new File("./target/descriptorClusterTest/node1/repository.xml"));
@@ -55,18 +46,16 @@ public class ClusterDescriptorTest exten
     }
 
     public void tearDown() throws Exception {
-        rep1.shutdown();
-        rep2.shutdown();
-        server1.stop();
-        server2.stop();
+    		rep1.shutdown();
+	    rep2.shutdown();
         deleteAll();
     }
 
-    private void deleteAll() throws IOException {
+    private static void deleteAll() throws IOException {
         FileUtils.deleteDirectory(new File("./target/descriptorClusterTest"));
     }
 
-    public void testRepositoryDescriptor() throws RepositoryException {
+    public void testRepositoryDescriptor() {
         String clusterId1 =  rep1.getDescriptor(RepositoryImpl.JACKRABBIT_CLUSTER_ID);
         String clusterId2 =  rep2.getDescriptor(RepositoryImpl.JACKRABBIT_CLUSTER_ID);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java?rev=1360692&r1=1360691&r2=1360692&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java
Thu Jul 12 14:19:26 2012
@@ -25,21 +25,15 @@ import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.test.JUnitTest;
-import org.h2.tools.Server;
 
 /**
  * Tests clustering with a database.
  */
 public class DbClusterTest extends JUnitTest {
 
-    Server server1, server2;
-
     public void setUp() throws Exception {
         deleteAll();
-        server1 = Server.createTcpServer("-tcpPort", "9001", "-baseDir",
-                "./target/dbClusterTest/db1", "-tcpAllowOthers").start();
-        server2 = Server.createTcpServer("-tcpPort", "9002", "-baseDir",
-                "./target/dbClusterTest/db2", "-tcpAllowOthers").start();
+
         FileUtils.copyFile(
                 new File("./src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml"),
                 new File("./target/dbClusterTest/node1/repository.xml"));
@@ -49,12 +43,10 @@ public class DbClusterTest extends JUnit
     }
 
     public void tearDown() throws Exception {
-        server1.stop();
-        server2.stop();
         deleteAll();
     }
 
-    private void deleteAll() throws IOException {
+    private static void deleteAll() throws IOException {
         FileUtils.deleteDirectory(new File("./target/dbClusterTest"));
     }
 
@@ -65,12 +57,14 @@ public class DbClusterTest extends JUnit
                 new File("./target/dbClusterTest/node2")));
         Session s1 = rep1.login(new SimpleCredentials("admin", "admin".toCharArray()));
         Session s2 = rep2.login(new SimpleCredentials("admin", "admin".toCharArray()));
+
         s1.getRootNode().addNode("test1");
         s2.getRootNode().addNode("test2");
         s1.save();
         s2.save();
         s1.refresh(true);
         s2.refresh(true);
+
         s1.getRootNode().getNode("test2");
         s2.getRootNode().getNode("test1");
         rep1.shutdown();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java?rev=1360692&r1=1360691&r2=1360692&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java
Thu Jul 12 14:19:26 2012
@@ -38,7 +38,6 @@ import org.apache.jackrabbit.commons.Jcr
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.test.JUnitTest;
-import org.h2.tools.Server;
 
 /**
  * Test for JCR3162
@@ -48,9 +47,6 @@ public class DbClusterTestJCR3162 extend
     private static final SimpleCredentials ADMIN = new SimpleCredentials(
             "admin", "admin".toCharArray());
 
-    private Server server1;
-    private Server server2;
-
     private RepositoryImpl rep1;
     private RepositoryImpl rep2;
 
@@ -59,10 +55,6 @@ public class DbClusterTestJCR3162 extend
 
     public void setUp() throws Exception {
         deleteAll();
-        server1 = Server.createTcpServer("-tcpPort", "9001", "-baseDir",
-                "./target/dbClusterTest/db1", "-tcpAllowOthers").start();
-        server2 = Server.createTcpServer("-tcpPort", "9002", "-baseDir",
-                "./target/dbClusterTest/db2", "-tcpAllowOthers").start();
         FileUtils
                 .copyFile(
                         new File(
@@ -89,13 +81,11 @@ public class DbClusterTestJCR3162 extend
                 rep2.shutdown();
             }
         } finally {
-            server1.stop();
-            server2.stop();
             deleteAll();
         }
     }
 
-    private void deleteAll() throws IOException {
+    private static void deleteAll() throws IOException {
         FileUtils.deleteDirectory(new File("./target/dbClusterTest"));
     }
 
@@ -133,8 +123,7 @@ public class DbClusterTestJCR3162 extend
         Connection con = null;
         try {
             con = DriverManager.getConnection(
-                    "jdbc:h2:tcp://localhost:9001,localhost:9002/db", "sa",
-                    "sa");
+                    "jdbc:h2:./target/dbClusterTest/db", "sa", "sa");
             PreparedStatement prep = con
                     .prepareStatement("update JOURNAL_LOCAL_REVISIONS set REVISION_ID=0 where
JOURNAL_ID=?");
             prep.setString(1, clusterId2);

Modified: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml?rev=1360692&r1=1360691&r2=1360692&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml
Thu Jul 12 14:19:26 2012
@@ -28,7 +28,7 @@
         (e.g. registered namespaces, custom node types, etc.)
     -->
     <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
-        <param name="url" value="jdbc:h2:tcp://localhost:9001,localhost:9002/db"/>
+        <param name="url" value="jdbc:h2:${rep.home}/../db"/>
         <param name="schemaObjectPrefix" value="fs_"/>
         <param name="user" value="sa"/>
         <param name="password" value="sa"/>
@@ -38,7 +38,7 @@
         data store configuration
     -->
     <DataStore class="org.apache.jackrabbit.core.data.db.DbDataStore">
-        <param name="url" value="jdbc:h2:tcp://localhost:9001,localhost:9002/db"/>
+        <param name="url" value="jdbc:h2:${rep.home}/../db"/>
         <param name="schemaObjectPrefix" value="datastore_"/>
         <param name="user" value="sa"/>
         <param name="password" value="sa"/>
@@ -103,7 +103,7 @@
             class: FQN of class implementing the PersistenceManager interface
         -->
         <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
-            <param name="url" value="jdbc:h2:tcp://localhost:9001,localhost:9002/db"/>
+            <param name="url" value="jdbc:h2:${rep.home}/../db"/>
             <param name="schemaObjectPrefix" value="ws_${wsp.name}_"/>
             <param name="user" value="sa"/>
             <param name="password" value="sa"/>
@@ -138,7 +138,7 @@
             implementations.
         -->
         <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
-            <param name="url" value="jdbc:h2:tcp://localhost:9001,localhost:9002/db"/>
+            <param name="url" value="jdbc:h2:${rep.home}/../db"/>
             <param name="schemaObjectPrefix" value="version_"/>
             <param name="user" value="sa"/>
             <param name="password" value="sa"/>
@@ -160,7 +160,7 @@
     <Cluster>
         <Journal class="org.apache.jackrabbit.core.journal.DatabaseJournal">
             <param name="driver" value="org.h2.Driver" />
-            <param name="url" value="jdbc:h2:tcp://localhost:9001,localhost:9002/db"/>
+            <param name="url" value="jdbc:h2:${rep.home}/../db"/>
             <param name="schemaObjectPrefix" value="journal_"/>
             <param name="databaseType" value="h2"/>
             <param name="user" value="sa"/>



Mime
View raw message