jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1211906 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel: MicrokernelTest.java RepositoryTest.java
Date Thu, 08 Dec 2011 14:25:17 GMT
Author: stefan
Date: Thu Dec  8 14:25:17 2011
New Revision: 1211906

URL: http://svn.apache.org/viewvc?rev=1211906&view=rev
Log:
some test cases fail with mongodb-backed mk because they assume an empty repo

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
    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/MicrokernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java?rev=1211906&r1=1211905&r2=1211906&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Thu Dec  8 14:25:17 2011
@@ -23,7 +23,10 @@ import junit.framework.Assert;
 import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
+import org.apache.jackrabbit.spi2microkernel.json.DefaultJsonTokenizer;
 import org.apache.jackrabbit.spi2microkernel.json.FullJsonParser;
+import org.apache.jackrabbit.spi2microkernel.json.JsonHandler;
+import org.apache.jackrabbit.spi2microkernel.json.JsonParser;
 import org.apache.jackrabbit.spi2microkernel.json.JsonTokenizer;
 import org.apache.jackrabbit.spi2microkernel.json.JsonValue;
 import org.apache.jackrabbit.spi2microkernel.json.JsonValue.JsonArray;
@@ -40,6 +43,8 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -56,15 +61,42 @@ public class MicrokernelTest {
     @Before
     public void setup() {
         MicroKernel mk = getMicroKernel();
-        String head = mk.getHeadRevision();
+        // clean all existing content
+        String result = mk.getNodes("/", mk.getHeadRevision(), 0, 0, -1);
+        final List<String> names = new ArrayList<String>();
+        new JsonParser(new JsonHandler() {
+
+            public void atom(Token key, Token value) {
+                if (key.text().charAt(0) != ':') {
+                    names.add(key.text());
+                }
+            }
 
-        if (!mk.nodeExists("/test", head)) {
-            mk.commit("/", "+\"test\" : {" +
-                "\"stringProp\":\"stringVal\"," +
-                "\"intProp\":42," +
-                "\"floatProp\":42.2," +
-                "\"multiIntProp\":[1,2,3]} ", head, "");
+            public void object(JsonParser parser, Token key, JsonTokenizer tokenizer) {
+                super.object(parser, key, tokenizer);
+                names.add(key.text());
+            }
+
+            public void array(JsonParser parser, Token key, JsonTokenizer tokenizer) {
+                super.array(parser, key, tokenizer);
+                // don't care
+            }
+        }).parseObject(new DefaultJsonTokenizer(result));
+
+        if (!names.isEmpty()) {
+            StringBuilder buf = new StringBuilder();
+            for (String name : names) {
+                buf.append("- \"").append(name).append("\"\n");
+            }
+            mk.commit("/", buf.toString(), mk.getHeadRevision(), null);
         }
+
+        String head = mk.getHeadRevision();
+        mk.commit("/", "+\"test\" : {" +
+            "\"stringProp\":\"stringVal\"," +
+            "\"intProp\":42," +
+            "\"floatProp\":42.2," +
+            "\"multiIntProp\":[1,2,3]} ", head, "");
     }
 
     @After

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=1211906&r1=1211905&r2=1211906&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
Thu Dec  8 14:25:17 2011
@@ -23,6 +23,11 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.mk.json.JsonBuilder;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.util.Arrays;
+import org.apache.jackrabbit.spi2microkernel.json.DefaultJsonTokenizer;
+import org.apache.jackrabbit.spi2microkernel.json.JsonHandler;
+import org.apache.jackrabbit.spi2microkernel.json.JsonParser;
+import org.apache.jackrabbit.spi2microkernel.json.JsonTokenizer;
+import org.apache.jackrabbit.spi2microkernel.json.Token;
 import org.apache.jackrabbit.spi2microkernel.util.Loop;
 import org.apache.jackrabbit.spi2microkernel.util.NumberStream;
 import org.junit.After;
@@ -105,6 +110,36 @@ public class RepositoryTest {
             String ptUnstructured = '\"' + JsonBuilder.escape(Paths.nameToString(NameConstants.JCR_PRIMARYTYPE))
+ "\":" +
                     "\"7:" + NodeType.NT_UNSTRUCTURED + '\"';
 
+            // clean all existing content
+            String result = mk.getNodes("/", mk.getHeadRevision(), 0, 0, -1);
+            final List<String> names = new ArrayList<String>();
+            new JsonParser(new JsonHandler() {
+
+                public void atom(Token key, Token value) {
+                    if (key.text().charAt(0) != ':') {
+                        names.add(key.text());
+                    }
+                }
+
+                public void object(JsonParser parser, Token key, JsonTokenizer tokenizer)
{
+                    super.object(parser, key, tokenizer);
+                    names.add(key.text());
+                }
+
+                public void array(JsonParser parser, Token key, JsonTokenizer tokenizer)
{
+                    super.array(parser, key, tokenizer);
+                    // don't care
+                }
+            }).parseObject(new DefaultJsonTokenizer(result));
+
+            if (!names.isEmpty()) {
+                StringBuilder buf = new StringBuilder();
+                for (String name : names) {
+                    buf.append("- \"").append(name).append("\"\n");
+                }
+                mk.commit("/", buf.toString(), mk.getHeadRevision(), null);
+            }
+
             String head = mk.getHeadRevision();
             assertFalse(mk.nodeExists("/default", head));
 



Mime
View raw message