You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2012/04/12 18:25:14 UTC
svn commit: r1325354 - in
/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk:
ConflictingMoveTest.java MoveNodeIT.java simple/MoveNodeIT.java
simple/SimpleKernelTest.java
Author: jukka
Date: Thu Apr 12 16:25:13 2012
New Revision: 1325354
URL: http://svn.apache.org/viewvc?rev=1325354&view=rev
Log:
OAK-12: Implement a test suite for the MicroKernel
Move SimpleKernelImpl-specific tests to the .simple package so that we can better track general integration tests
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/MoveNodeIT.java
- copied, changed from r1325340, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java?rev=1325354&r1=1325353&r2=1325354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java Thu Apr 12 16:25:13 2012
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertTru
import static org.junit.Assert.fail;
import org.apache.jackrabbit.mk.api.MicroKernelException;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -36,11 +35,6 @@ public class ConflictingMoveTest extends
super(url);
}
- @Before
- public void setUp() throws Exception {
- super.setUp();
- }
-
@Test
public void collidingMove() {
String head = mk.getHeadRevision();
@@ -93,16 +87,4 @@ public class ConflictingMoveTest extends
}
}
- @Test
- public void doubleDelete() {
- if (!isSimpleKernel(mk)) {
- // TODO
- return;
- }
- String head = mk.getHeadRevision();
- head = mk.commit("/", "+\"a\": {}", head, "");
- mk.commit("/", "-\"a\"", head, "");
- mk.commit("/", "-\"a\"", head, "");
- }
-
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java?rev=1325354&r1=1325353&r2=1325354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java Thu Apr 12 16:25:13 2012
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.mk;
import static org.junit.Assert.fail;
import junit.framework.Assert;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.mk.json.JsopTokenizer;
import org.junit.Before;
import org.junit.Test;
@@ -49,253 +48,6 @@ public class MoveNodeIT extends MultiMkT
}
@Test
- public void addProperty() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
- // add a property /test/c
- commit("/", "+ \"test/c\": 123");
- Assert.assertEquals("{c:123,a,b,c}", getNode("/test"));
- assertJournal("+\"/test/c\":123");
- }
-
- @Test
- public void addPropertyTwice() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- commit("/", "+ \"test/c\": 123");
-
- // duplicate add property can fail
- // TODO document that both is fine
- try {
- commit("/", "+ \"test/c\": 123");
- Assert.fail();
- } catch (MicroKernelException e) {
- // expected
- }
- Assert.assertEquals("{c:123,a,b,c}", getNode("/test"));
- }
-
- @Test
- public void order() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
- Assert.assertEquals("{a,b,c}", getNode("/test"));
- }
-
- @Test
- public void rename() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
- // rename /test/b
- commit("/", "> \"test/b\": \"test/b1\"");
- Assert.assertEquals("{a,b1,c}", getNode("/test"));
- assertJournal(">\"/test/b\":\"/test/b1\"");
-
- // and back
- commit("/", "> \"test/b1\": \"test/b\"");
- Assert.assertEquals("{a,b,c}", getNode("/test"));
- assertJournal(">\"/test/b1\":\"/test/b\"");
- }
-
- @Test
- public void reorderBefore() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // order c before b
- commit("/", "> \"test/c\": {\"before\": \"test/b\"}");
- Assert.assertEquals("{a,c,b}", getNode("/test"));
- assertJournal(">\"/test/c\":{\"before\":\"/test/b\"}");
-
- // and now b before a
- commit("/", "> \"test/b\": {\"before\": \"test/a\"}");
- Assert.assertEquals("{b,a,c}", getNode("/test"));
- assertJournal(">\"/test/b\":{\"before\":\"/test/a\"}");
- }
-
- @Test
- public void reorderAfter() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // order a after b
- commit("/", "> \"test/a\": {\"after\": \"test/b\"}");
- Assert.assertEquals("{b,a,c}", getNode("/test"));
- assertJournal(">\"/test/a\":{\"after\":\"/test/b\"}");
-
- // and now a after c
- commit("/", "> \"test/a\": {\"after\": \"test/c\"}");
- Assert.assertEquals("{b,c,a}", getNode("/test"));
- assertJournal(">\"/test/a\":{\"after\":\"/test/c\"}");
-
- // and now a after a (a no-op)
- commit("/", "> \"test/a\": {\"after\": \"test/a\"}");
- Assert.assertEquals("{b,c,a}", getNode("/test"));
- assertJournal(">\"/test/a\":{\"after\":\"/test/a\"}");
- }
-
- @Test
- public void moveFirst() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // move /test/a to /test2/a (rename is not supported in this way)
- commit("/", "> \"test/a\": {\"first\": \"test2\"}");
- Assert.assertEquals("{b,c}", getNode("/test"));
- Assert.assertEquals("{a}", getNode("/test2"));
- assertJournal(">\"/test/a\":{\"first\":\"/test2\"}");
-
- // move /test/c to /test2
- commit("/", "> \"test/c\": {\"first\": \"test2\"}");
- Assert.assertEquals("{b}", getNode("/test"));
- Assert.assertEquals("{c,a}", getNode("/test2"));
- assertJournal(">\"/test/c\":{\"first\":\"/test2\"}");
- }
-
- @Test
- public void moveCombinedWithSet() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // move /test/b to /test_b
- commit("/", "> \"test/b\": \"test_b\"");
- Assert.assertEquals("{a,c}", getNode("/test"));
- Assert.assertEquals("{}", getNode("/test_b"));
- assertJournal(">\"/test/b\":\"/test_b\"");
-
- // move /test/a to /test_a, combined with adding a property
- commit("/", "> \"test/a\": \"test_a\" ^ \"test_a/x\": 1");
- Assert.assertEquals("{c}", getNode("/test"));
- Assert.assertEquals("{x:1}", getNode("/test_a"));
- assertJournal(
- ">\"/test/a\":\"/test_a\"\n"+
- "+\"/test_a/x\":1");
- }
-
- @Test
- public void moveBefore() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // move /test/b to /test2/b, before any other nodes in /test2
- commit("/", "> \"test/b\": {\"first\": \"test2\"}");
- Assert.assertEquals("{a,c}", getNode("/test"));
- Assert.assertEquals("{b}", getNode("/test2"));
- assertJournal(">\"/test/b\":{\"first\":\"/test2\"}");
-
- // move /test/c to /test2, before b
- commit("/", "> \"test/c\": {\"before\": \"test2/b\"}");
- Assert.assertEquals("{a}", getNode("/test"));
- Assert.assertEquals("{c,b}", getNode("/test2"));
- assertJournal(">\"/test/c\":{\"before\":\"/test2/b\"}");
- }
-
- @Test
- public void moveAfter() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // move /test/c to /test2
- commit("/", "> \"test/c\": \"test2/c\"");
- Assert.assertEquals("{a,b}", getNode("/test"));
- Assert.assertEquals("{c}", getNode("/test2"));
- assertJournal(">\"/test/c\":\"/test2/c\"");
-
- // move /test/a to /test2, after c
- commit("/", "> \"test/a\": {\"after\": \"test2/c\"}");
- Assert.assertEquals("{b}", getNode("/test"));
- Assert.assertEquals("{c,a}", getNode("/test2"));
- assertJournal(">\"/test/a\":{\"after\":\"/test2/c\"}");
-
- // move /test/b to /test2, after c
- commit("/", "> \"test/b\": {\"after\": \"test2/c\"}");
- Assert.assertEquals("{}", getNode("/test"));
- Assert.assertEquals("{c,b,a}", getNode("/test2"));
- assertJournal(">\"/test/b\":{\"after\":\"/test2/c\"}");
- }
-
- @Test
- public void moveLast() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
- // move /test/a to /test2, as last
- commit("/", "> \"test/b\": {\"last\": \"test2\"}");
- Assert.assertEquals("{a,c}", getNode("/test"));
- Assert.assertEquals("{b}", getNode("/test2"));
- assertJournal(">\"/test/b\":{\"last\":\"/test2\"}");
-
- // move /test/c to /test2, as last
- commit("/", "> \"test/c\": {\"last\": \"test2\"}");
- Assert.assertEquals("{a}", getNode("/test"));
- Assert.assertEquals("{b,c}", getNode("/test2"));
- assertJournal(">\"/test/c\":{\"last\":\"/test2\"}");
- }
-
- @Test
- public void copy() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
- // copy /test to /test2/copy
- commit("/", "* \"test\": \"/test2/copy\"");
- Assert.assertEquals("{a,b,c}", getNode("/test"));
- Assert.assertEquals("{copy:{a,b,c}}", getNode("/test2"));
-
- if (isSimpleKernel(mk)) {
- assertJournal("*\"/test\":\"/test2/copy\"");
- } else {
- assertJournal("+\"/test2/copy\":{\"a\":{},\"b\":{},\"c\":{}}");
- }
- }
-
- @Test
- public void move() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
- // move /test/b to /test2
- commit("/", "> \"test/b\": \"/test2/b\"");
- Assert.assertEquals("{a,c}", getNode("/test"));
- Assert.assertEquals("{b}", getNode("/test2"));
- assertJournal(">\"/test/b\":\"/test2/b\"");
-
- // move /test/a to /test2
- commit("/", "> \"test/a\": \"test2/b1\"");
- Assert.assertEquals("{c}", getNode("/test"));
- Assert.assertEquals("{b,b1}", getNode("/test2"));
- assertJournal(">\"/test/a\":\"/test2/b1\"");
-
- // move /test/c to /test2
- commit("/", "> \"test/c\": \"test2/c\"");
- Assert.assertEquals("{}", getNode("/test"));
- Assert.assertEquals("{b,b1,c}", getNode("/test2"));
- assertJournal(">\"/test/c\":\"/test2/c\"");
- }
-
- @Test
public void moveTryOverwriteExisting() {
// move /test/b to /test2
commit("/", "> \"test/b\": \"/test2/b\"");
@@ -326,19 +78,6 @@ public class MoveNodeIT extends MultiMkT
head = mk.commit(root, diff, head, null);
}
- private String getNode(String node) {
- String s = mk.getNodes(node, mk.getHeadRevision());
- s = s.replaceAll("\"", "").replaceAll(":childNodeCount:.", "");
- s = s.replaceAll("\\{\\,", "\\{").replaceAll("\\,\\}", "\\}");
- s = s.replaceAll("\\:\\{\\}", "");
- s = s.replaceAll(",,", ",");
- return s;
- }
-
- private void assertJournal(String expectedJournal) {
- Assert.assertEquals(expectedJournal, getJournal());
- }
-
private String getJournal() {
if (journalRevision == null) {
String revs = mk.getRevisions(0, 1);
Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/MoveNodeIT.java (from r1325340, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/MoveNodeIT.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/MoveNodeIT.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java&r1=1325340&r2=1325354&rev=1325354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MoveNodeIT.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/MoveNodeIT.java Thu Apr 12 16:25:13 2012
@@ -14,47 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.mk;
+package org.apache.jackrabbit.mk.simple;
-import static org.junit.Assert.fail;
import junit.framework.Assert;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.mk.json.JsopTokenizer;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
/**
- * Test moving nodes.
+ * Test moving nodes. These tests currently only work against the
+ * {@link SimpleKernelImpl} implementation as they assume a specific
+ * ordering of child nodes that isn't guaranteed by the
+ * {@link MicroKernel} contract.
*/
-@RunWith(Parameterized.class)
-public class MoveNodeIT extends MultiMkTestBase {
+public class MoveNodeIT {
+
+ private final MicroKernel mk = new SimpleKernelImpl("mem:SimpleKernelTest");
private String head;
private String journalRevision;
- public MoveNodeIT(String url) {
- super(url);
- }
-
@Before
- @Override
public void setUp() throws Exception {
- super.setUp();
head = mk.getHeadRevision();
commit("/", "+ \"test\": {\"a\":{}, \"b\":{}, \"c\":{}}");
commit("/", "+ \"test2\": {}");
getJournal();
}
+ // TODO fix test since it incorrectly expects a specific order of child nodes
@Test
public void addProperty() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
// add a property /test/c
commit("/", "+ \"test/c\": 123");
Assert.assertEquals("{c:123,a,b,c}", getNode("/test"));
@@ -63,10 +56,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void addPropertyTwice() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
commit("/", "+ \"test/c\": 123");
// duplicate add property can fail
@@ -80,23 +69,15 @@ public class MoveNodeIT extends MultiMkT
Assert.assertEquals("{c:123,a,b,c}", getNode("/test"));
}
+ // TODO fix test since it incorrectly expects a specific order of child nodes
@Test
public void order() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
Assert.assertEquals("{a,b,c}", getNode("/test"));
}
+ // TODO fix test since it incorrectly expects a specific order of child nodes
@Test
public void rename() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
// rename /test/b
commit("/", "> \"test/b\": \"test/b1\"");
Assert.assertEquals("{a,b1,c}", getNode("/test"));
@@ -110,10 +91,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void reorderBefore() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// order c before b
commit("/", "> \"test/c\": {\"before\": \"test/b\"}");
Assert.assertEquals("{a,c,b}", getNode("/test"));
@@ -127,10 +104,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void reorderAfter() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// order a after b
commit("/", "> \"test/a\": {\"after\": \"test/b\"}");
Assert.assertEquals("{b,a,c}", getNode("/test"));
@@ -149,10 +122,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void moveFirst() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// move /test/a to /test2/a (rename is not supported in this way)
commit("/", "> \"test/a\": {\"first\": \"test2\"}");
Assert.assertEquals("{b,c}", getNode("/test"));
@@ -168,10 +137,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void moveCombinedWithSet() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// move /test/b to /test_b
commit("/", "> \"test/b\": \"test_b\"");
Assert.assertEquals("{a,c}", getNode("/test"));
@@ -189,10 +154,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void moveBefore() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// move /test/b to /test2/b, before any other nodes in /test2
commit("/", "> \"test/b\": {\"first\": \"test2\"}");
Assert.assertEquals("{a,c}", getNode("/test"));
@@ -208,10 +169,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void moveAfter() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// move /test/c to /test2
commit("/", "> \"test/c\": \"test2/c\"");
Assert.assertEquals("{a,b}", getNode("/test"));
@@ -233,10 +190,6 @@ public class MoveNodeIT extends MultiMkT
@Test
public void moveLast() {
- if (!isSimpleKernel(mk)) {
- return;
- }
-
// move /test/a to /test2, as last
commit("/", "> \"test/b\": {\"last\": \"test2\"}");
Assert.assertEquals("{a,c}", getNode("/test"));
@@ -250,32 +203,24 @@ public class MoveNodeIT extends MultiMkT
assertJournal(">\"/test/c\":{\"last\":\"/test2\"}");
}
+ // TODO fix test since it incorrectly expects a specific order of child nodes
@Test
public void copy() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
// copy /test to /test2/copy
commit("/", "* \"test\": \"/test2/copy\"");
Assert.assertEquals("{a,b,c}", getNode("/test"));
Assert.assertEquals("{copy:{a,b,c}}", getNode("/test2"));
- if (isSimpleKernel(mk)) {
+ // if (isSimpleKernel(mk)) {
assertJournal("*\"/test\":\"/test2/copy\"");
- } else {
- assertJournal("+\"/test2/copy\":{\"a\":{},\"b\":{},\"c\":{}}");
- }
+ // } else {
+ // assertJournal("+\"/test2/copy\":{\"a\":{},\"b\":{},\"c\":{}}");
+ // }
}
+ // TODO fix test since it incorrectly expects a specific order of child nodes
@Test
public void move() {
- if (!isSimpleKernel(mk)) {
- // TODO fix test since it incorrectly expects a specific order of child nodes
- return;
- }
-
// move /test/b to /test2
commit("/", "> \"test/b\": \"/test2/b\"");
Assert.assertEquals("{a,c}", getNode("/test"));
@@ -295,33 +240,6 @@ public class MoveNodeIT extends MultiMkT
assertJournal(">\"/test/c\":\"/test2/c\"");
}
- @Test
- public void moveTryOverwriteExisting() {
- // move /test/b to /test2
- commit("/", "> \"test/b\": \"/test2/b\"");
-
- try {
- // try to move /test/a to /test2/b
- commit("/", "> \"test/a\": \"/test2/b\"");
- fail();
- } catch (Exception e) {
- // expected
- }
- }
-
- @Test
- public void moveTryBecomeDescendantOfSelf() {
- // move /test to /test/a/test
-
- try {
- // try to move /test to /test/a/test
- commit("/", "> \"test\": \"/test/a/test\"");
- fail();
- } catch (Exception e) {
- // expected
- }
- }
-
private void commit(String root, String diff) {
head = mk.commit(root, diff, head, null);
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java?rev=1325354&r1=1325353&r2=1325354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java Thu Apr 12 16:25:13 2012
@@ -19,6 +19,15 @@ package org.apache.jackrabbit.mk.simple;
import org.apache.jackrabbit.mk.api.MicroKernel;
import org.junit.Test;
+/**
+ * {@link MicroKernel} test cases that currently only work against the
+ * {@link SimpleKernelImpl} implementation.
+ * <p>
+ * TODO: Review these to see if they rely on implementation-specific
+ * functionality or if they should be turned into generic integration
+ * tests and the respective test failures in other MK implementations
+ * fixed.
+ */
public class SimpleKernelTest {
private final MicroKernel mk = new SimpleKernelImpl("mem:SimpleKernelTest");
@@ -34,4 +43,12 @@ public class SimpleKernelTest {
// System.out.println(mk.getNodes('/' + node, head).replaceAll("\"", "").replaceAll(":childNodeCount:.", ""));
}
+ @Test
+ public void doubleDelete() {
+ String head = mk.getHeadRevision();
+ head = mk.commit("/", "+\"a\": {}", head, "");
+ mk.commit("/", "-\"a\"", head, "");
+ mk.commit("/", "-\"a\"", head, "");
+ }
+
}