jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1525856 [2/2] - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/mongomk/ main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/ test/java/org/apache/jackrabbit/oak/plugins/mongomk/ test/java/org/apache...
Date Tue, 24 Sep 2013 11:21:04 GMT
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java?rev=1525856&r1=1525855&r2=1525856&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/SimpleTest.java
Tue Sep 24 11:21:03 2013
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -379,35 +380,41 @@ public class SimpleTest {
         MongoMK mk = createMK();
         try {
             DocumentStore store = mk.getDocumentStore();
-            String head = mk.getHeadRevision();
-            head = mk.commit("", "+\"/test\":{\"foo\":{}}", head, null);
+            Revision head = Revision.fromString(mk.getHeadRevision());
+            head = Revision.fromString(mk.commit("", "+\"/test\":{\"foo\":{}}", head.toString(),
null));
 
             // root node must not have the revision
             NodeDocument rootDoc = store.find(Collection.NODES, "0:/");
+            assertNotNull(rootDoc);
             assertFalse(rootDoc.containsRevision(head));
 
             // test node must have head in revisions
             NodeDocument node = store.find(Collection.NODES, "1:/test");
+            assertNotNull(node);
             assertTrue(node.containsRevision(head));
 
             // foo must not have head in revisions and must refer to test
             // as commit root (depth = 1)
             NodeDocument foo = store.find(Collection.NODES, "2:/test/foo");
+            assertNotNull(foo);
             assertFalse(foo.containsRevision(head));
             assertEquals("/test", foo.getCommitRootPath(head));
 
-            head = mk.commit("", "+\"/bar\":{}+\"/test/foo/bar\":{}", head, null);
+            head = Revision.fromString(mk.commit("", "+\"/bar\":{}+\"/test/foo/bar\":{}",
head.toString(), null));
 
             // root node is root of commit
             rootDoc = store.find(Collection.NODES, "0:/");
+            assertNotNull(rootDoc);
             assertTrue(rootDoc.containsRevision(head));
 
             // /bar refers to root nodes a commit root
             NodeDocument bar = store.find(Collection.NODES, "1:/bar");
+            assertNotNull(bar);
             assertEquals("/", bar.getCommitRootPath(head));
 
             // /test/foo/bar refers to root nodes a commit root
             bar = store.find(Collection.NODES, "3:/test/foo/bar");
+            assertNotNull(bar);
             assertEquals("/", bar.getCommitRootPath(head));
 
         } finally {

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MergeSortedIteratorsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MergeSortedIteratorsTest.java?rev=1525856&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MergeSortedIteratorsTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MergeSortedIteratorsTest.java
Tue Sep 24 11:21:03 2013
@@ -0,0 +1,78 @@
+/*
+ * 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.oak.plugins.mongomk.util;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * Tests for {@link MergeSortedIterators}.
+ */
+public class MergeSortedIteratorsTest {
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void test() {
+        assertEquals(list(), sort());
+        assertEquals(list(), sort(list()));
+        assertEquals(list(1, 2, 3, 4), sort(list(1, 2), list(3, 4)));
+        assertEquals(list(1, 2, 3, 4), sort(list(1, 3), list(2, 4)));
+        assertEquals(list(1, 2, 3), sort(list(1, 3), list(2)));
+        assertEquals(list(1, 2, 3, 4), sort(list(1, 4), list(2, 3)));
+        assertEquals(list(1, 2, 3, 4, 5, 6), sort(list(1, 5), list(2, 4), list(3, 6)));
+    }
+
+    private List<Integer> sort(List<Integer>... lists) {
+        List<Iterator<Integer>> iterators = Lists.newArrayList();
+        for (List<Integer> list : lists) {
+            iterators.add(list.iterator());
+        }
+        final Iterator<Iterator<Integer>> it = iterators.iterator();
+        MergeSortedIterators<Integer> sort = new MergeSortedIterators<Integer>(new
Comparator<Integer>() {
+            @Override
+            public int compare(Integer o1, Integer o2) {
+                return o1.compareTo(o2);
+            }
+        }) {
+            @Override
+            public Iterator<Integer> nextIterator() {
+                return it.hasNext() ? it.next() : null;
+            }
+        };
+        List<Integer> sorted = new ArrayList<Integer>();
+        while (sort.hasNext()) {
+            sorted.add(sort.next());
+        }
+        return sorted;
+    }
+
+    private static List<Integer> list(int... values) {
+        List<Integer> list = new ArrayList<Integer>();
+        for (int v : values) {
+            list.add(v);
+        }
+        return list;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MergeSortedIteratorsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MergeSortedIteratorsTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message