jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1159612 - /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Fri, 19 Aug 2011 12:33:25 GMT
Author: mduerig
Date: Fri Aug 19 12:33:25 2011
New Revision: 1159612

URL: http://svn.apache.org/viewvc?rev=1159612&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
- workaround for ;clean not working properly

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1159612&r1=1159611&r2=1159612&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Fri Aug 19 12:33:25 2011
@@ -76,37 +76,40 @@ import static org.apache.jackrabbit.spi2
 import static org.junit.Assert.*;
 
 public class RepositoryTest {
-
-    private static final String URL = "fs:target/repository-test/repository";
-    // private static final String URL = "mem:";
+    private static final String BASE_URL = "fs:target/repository-test/repository";
+    private static long counter = System.currentTimeMillis();
 
     private final String testNode = "node_" + System.currentTimeMillis();
     private final String testPath = '/' + testNode;
     private Repository repository;
     private Session session;
 
+    private static String getMkUrl(boolean clean) {
+        if (clean) {
+            counter++;
+        }
+        return BASE_URL + counter + (clean ? ";clean" : "");
+    }
+
     @Before
     public void setup() {
-        MicroKernel mk = MicroKernelFactory.getInstance(URL + ";clean");
-
+        MicroKernel mk = MicroKernelFactory.getInstance(getMkUrl(true));
         try {
-            String head = mk.getHeadRevision();
             String ptUnstructured = '\"' + JsonBuilder.escape(Paths.nameToString(NameConstants.JCR_PRIMARYTYPE))
+ "\":" +
                     "\"7:" + NodeType.NT_UNSTRUCTURED + '\"';
 
-            if (!mk.nodeExists("/default", head)) {
-                head = mk.commit("/",
+            String head = mk.getHeadRevision();
+            assertFalse(mk.nodeExists("/default", head));
+
+            head = mk.commit("/",
                     "+\"default\" : {" +
-                        "\"{}foo\" : {" +
+                            "\"{}foo\" : {" +
                             "\"{}stringProp\":\"stringVal\"," +
                             "\"{}intProp\":42," +
                             "\"{}mvProp\":[1,2,3]}, " +
-                        "\"{}bar\" : {}}", head, "");
-            }
+                            "\"{}bar\" : {}}", head, "");
 
-            if (!mk.nodeExists("/default/{}" + testNode, head)) {
-                mk.commit("/default", "+\"{}" + testNode + "\" : {" + ptUnstructured + '}',
head, "");
-            }
+            mk.commit("/default", "+\"{}" + testNode + "\" : {" + ptUnstructured + '}', head,
"");
         }
         finally {
             mk.dispose();
@@ -115,22 +118,22 @@ public class RepositoryTest {
 
     @After
     public void tearDown() {
-        MicroKernel mk = MicroKernelFactory.getInstance(URL + ";clean");
-        try {
-            String head = mk.getHeadRevision();
-
-            if (mk.nodeExists("/default/{}" + testNode, head)) {
-                mk.commit("/default", "-\"{}" + testNode + '\"', head, "");
-            }
-        }
-        finally {
-            mk.dispose();
-        }
-
         if (session != null) {
             session.logout();
             session = null;
         }
+
+//        MicroKernel mk = MicroKernelFactory.getInstance(URL + ";clean");
+//        try {
+//            String head = mk.getHeadRevision();
+//
+//            if (mk.nodeExists("/default/{}" + testNode, head)) {
+//                mk.commit("/default", "-\"{}" + testNode + '\"', head, "");
+//            }
+//        }
+//        finally {
+//            mk.dispose();
+//        }
     }
 
     @Test
@@ -1384,7 +1387,7 @@ public class RepositoryTest {
             while (repository == null && factories.hasNext()) {
                 RepositoryFactory factory = factories.next();
                 repository = factory.getRepository(Collections.singletonMap(
-                        Spi2MicrokernelRepositoryServiceFactory.PARAM_URL, URL));
+                        Spi2MicrokernelRepositoryServiceFactory.PARAM_URL, getMkUrl(false)));
             }
         }
 



Mime
View raw message