### Eclipse Workspace Patch 1.0 #P jackrabbit-core Index: src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java (revision 1360114) +++ src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTest.java (working copy) @@ -18,6 +18,7 @@ import java.io.File; import java.io.IOException; + import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; @@ -25,21 +26,15 @@ 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 +44,10 @@ } 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 +58,14 @@ 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(); Index: src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml =================================================================== --- src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml (revision 1360114) +++ src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml (working copy) @@ -28,7 +28,7 @@ (e.g. registered namespaces, custom node types, etc.) --> - + @@ -38,7 +38,7 @@ data store configuration --> - + @@ -103,7 +103,7 @@ class: FQN of class implementing the PersistenceManager interface --> - + @@ -138,7 +138,7 @@ implementations. --> - + @@ -160,7 +160,7 @@ - + Index: src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java (revision 1360114) +++ src/test/java/org/apache/jackrabbit/core/cluster/DbClusterTestJCR3162.java (working copy) @@ -38,7 +38,6 @@ 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 @@ 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,7 @@ 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 +82,11 @@ 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 +124,7 @@ 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); Index: src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java (revision 1360114) +++ src/test/java/org/apache/jackrabbit/core/cluster/ClusterDescriptorTest.java (working copy) @@ -18,29 +18,22 @@ 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 +48,20 @@ } public void tearDown() throws Exception { - rep1.shutdown(); - rep2.shutdown(); - server1.stop(); - server2.stop(); - deleteAll(); + try { + rep1.shutdown(); + rep2.shutdown(); + deleteAll(); + } catch (Exception e) { + e.printStackTrace(); + } } - 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);