You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2012/02/08 15:41:11 UTC
svn commit: r1241915 -
/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java
Author: mduerig
Date: Wed Feb 8 14:41:11 2012
New Revision: 1241915
URL: http://svn.apache.org/viewvc?rev=1241915&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- Add test cases for all commutation and reduction rules
Modified:
jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java
Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java?rev=1241915&r1=1241914&r2=1241915&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java Wed Feb 8 14:41:11 2012
@@ -146,6 +146,236 @@ public class ChangeLogTest {
changeLog.removeProperty(path("/"), "a");
assertEquals("^\"//a\":null", changeLog.toJsop());
}
+
+ /**
+ * 1. >/a:/b >/c:/d = >/c:/d >/a:b
+ * 5. >/a:/b >/c:/d = >/c:/d >/a:b
+ * 9. >/a:/b >/c:/d = >/c:/d >/a:b
+ * 13: >/a:/b >/c:/d = >/c:/d >/a:b
+ */
+ @Test
+ public void testRule1_5_9_13() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/c"), path("/d"));
+ assertEquals(">\"//c\":\"//d\">\"//a\":\"//b\"", changeLog.toJsop());
+ }
+
+ /**
+ * 2. >/a:/b >/a/b:/c illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule2() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/a/b"), path("/c"));
+ }
+
+ /**
+ * 3. >/a:/b >/a:/c illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule3() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/a"), path("/c"));
+ }
+
+ /**
+ * 4. >/a/b:/c >/a:/d = >/a:/d >/d/b:/c
+ */
+ @Test
+ public void testRule4() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a/b"), path("/c"));
+ changeLog.moveNode(path("/a"), path("/d"));
+ assertEquals(">\"//a\":\"//d\">\"//d/b\":\"//c\"", changeLog.toJsop());
+
+ }
+
+ /**
+ * 4. >/a/b:/c >/a:/c/d does not commute (q < s)
+ */
+ @Test
+ public void testRule4a() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a/b"), path("/c"));
+ changeLog.moveNode(path("/a"), path("/c/d"));
+ assertEquals(">\"//a/b\":\"//c\">\"//a\":\"//c/d\"", changeLog.toJsop());
+
+ }
+
+ /**
+ * 4'. -/a/b -/a = -/a (s = NIL and q = NIL)
+ */
+ @Test
+ public void testRule4b() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.removeNode(path("/a/b"));
+ changeLog.removeNode(path("/a"));
+ assertEquals("-\"//a\"", changeLog.toJsop());
+
+ }
+
+ /**
+ * 4'. >/a/b:/c -/a = does not commute (s = NIL)
+ */
+ @Test
+ public void testRule4c() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a/b"), path("/c"));
+ changeLog.removeNode(path("/a"));
+ assertEquals(">\"//a/b\":\"//c\"-\"//a\"", changeLog.toJsop());
+
+ }
+
+ /**
+ * 6. >/a:/b >/c:/a/d illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule6() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/c"), path("/a/d"));
+ }
+
+ /**
+ * 7. >/a:/b >/c:/a does not commute
+ */
+ @Test
+ public void testRule7() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/c"), path("/a"));
+ assertEquals(">\"//a\":\"//b\">\"//c\":\"//a\"", changeLog.toJsop());
+ }
+
+ /**
+ * 8. >/a/d:/b >/c:/a illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule8() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a/d"), path("/b"));
+ changeLog.moveNode(path("/c"), path("/a"));
+ }
+
+ /**
+ * 10. >/a:/b >/b/c:/d = >/a/c:/d >/a:/b
+ */
+ @Test
+ public void testRule10() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/b/c"), path("/d"));
+ assertEquals(">\"//a/c\":\"//d\">\"//a\":\"//b\"", changeLog.toJsop());
+ }
+
+ /**
+ * 10'. +/b:{} >/b/c:/d illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule10a() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.addNode(path("/b"));
+ changeLog.moveNode(path("/b/c"), path("/d"));
+ }
+
+ /**
+ * 11. >/a:/b >/b:/c = >/a:/c
+ */
+ @Test
+ public void testRule11() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/b"), path("/c"));
+ assertEquals(">\"//a\":\"//c\"", changeLog.toJsop());
+ }
+
+ /**
+ * 12. >/a:/b/c >/b:/d = >/b:/d >/a:/d/c
+ */
+ @Test
+ public void testRule12() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b/c"));
+ changeLog.moveNode(path("/b"), path("/d"));
+ assertEquals(">\"//b\":\"//d\">\"//a\":\"//d/c\"", changeLog.toJsop());
+ }
+
+ /**
+ * 12'. >/a:/b/c -/b = -/b -/a = -/a -/b
+ */
+ @Test
+ public void testRule12a() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b/c"));
+ changeLog.removeNode(path("/b"));
+ assertEquals("-\"//a\"-\"//b\"", changeLog.toJsop());
+ }
+
+ /**
+ * 14. >/a:/b >/c:/b/d = >/c:/a/d >/a:/b
+ */
+ @Test
+ public void testRule14() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/c"), path("/b/d"));
+ assertEquals(">\"//c\":\"//a/d\">\"//a\":\"//b\"", changeLog.toJsop());
+ }
+
+ /**
+ * 14. >/a/b:/b >/a:/b/d does not commute (p > r)
+ */
+ @Test
+ public void testRule14a() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a/b"), path("/b"));
+ changeLog.moveNode(path("/a"), path("/b/d"));
+ assertEquals(">\"//a/b\":\"//b\">\"//a\":\"//b/d\"", changeLog.toJsop());
+ }
+
+ /**
+ * 14'. +/b:{} >/c:/b/c does not commute (parent of s = q and p = NIL)
+ */
+ @Test
+ public void testRule14b() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.addNode(path("/b"));
+ changeLog.moveNode(path("/c"), path("/b/c"));
+ assertEquals("+\"//b\":{}>\"//c\":\"//b/c\"", changeLog.toJsop());
+ }
+
+ /**
+ * 14'. +/b:{} >/c:/b/c/d illegal (p = NIL)
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule14c() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.addNode(path("/b"));
+ changeLog.moveNode(path("/c"), path("/b/c/d"));
+ }
+
+ /**
+ * 15. >/a:/b >/c:/b illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule15() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b"));
+ changeLog.moveNode(path("/c"), path("/b"));
+ }
+
+ /**
+ * 16. >/a:/b/d >/c:/b illegal
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testRule16() {
+ ChangeLog changeLog = new ChangeLog();
+ changeLog.moveNode(path("/a"), path("/b/d"));
+ changeLog.moveNode(path("/c"), path("/b"));
+ }
//------------------------------------------< private >---