jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1232861 - /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/ManyRevisionsTest.java
Date Wed, 18 Jan 2012 12:41:43 GMT
Author: thomasm
Date: Wed Jan 18 12:41:42 2012
New Revision: 1232861

URL: http://svn.apache.org/viewvc?rev=1232861&view=rev
Log:
Test case that generates and reads many revisions

Added:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/ManyRevisionsTest.java

Added: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/ManyRevisionsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/ManyRevisionsTest.java?rev=1232861&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/ManyRevisionsTest.java
(added)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/ManyRevisionsTest.java
Wed Jan 18 12:41:42 2012
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.mk.large;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import org.apache.jackrabbit.mk.MultiMkTestBase;
+import org.apache.jackrabbit.mk.json.fast.Jsop;
+import org.apache.jackrabbit.mk.json.fast.JsopArray;
+import org.apache.jackrabbit.mk.json.fast.JsopObject;
+import org.apache.jackrabbit.mk.mem.NodeImpl;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ * Test moving nodes.
+ */
+@RunWith(Parameterized.class)
+public class ManyRevisionsTest extends MultiMkTestBase {
+
+    public ManyRevisionsTest(String url) {
+        super(url);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Test
+    public void test() {
+        String head = mk.getHeadRevision();
+        head = mk.commit("/", "+\"test\" : {\"id\": -1}", head, "\"-1\"");
+        String first = head;
+        ArrayList<String> revs = new ArrayList<String>();
+        for (int i = 0; i < 1000; i++) {
+            String rev = mk.commit("/", "^ \"test/id\": " + i, head, "\"" + i + "\"");
+            revs.add(rev);
+            head = rev;
+        }
+        int i = 0;
+        String last = first;
+        for (String rev : revs) {
+            String n = mk.getNodes("/test", rev);
+            NodeImpl node = NodeImpl.parse(n);
+            assertEquals(i, Integer.parseInt(node.getProperty("id")));
+            String journal = mk.getJournal(last, rev);
+            JsopArray array = (JsopArray) Jsop.parse(journal);
+            assertEquals(last + ".." + rev + ": " + journal,
+                    2, array.size());
+            JsopObject obj = (JsopObject) array.get(0);
+            assertEquals("\"" + (i - 1) + "\"", obj.get("msg"));
+            obj = (JsopObject) array.get(1);
+            assertEquals("\"" + i + "\"", obj.get("msg"));
+            last = rev;
+            i++;
+        }
+    }
+
+}



Mime
View raw message