jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1145226 - in /jackrabbit/trunk/jackrabbit-core: pom.xml src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
Date Mon, 11 Jul 2011 16:11:30 GMT
Author: reschke
Date: Mon Jul 11 16:11:30 2011
New Revision: 1145226

URL: http://svn.apache.org/viewvc?rev=1145226&view=rev
Log:
JCR-3018 - add test case demonstrating transient space corruption after sequence of failed/successful
save() operations

Modified:
    jackrabbit/trunk/jackrabbit-core/pom.xml
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java

Modified: jackrabbit/trunk/jackrabbit-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/pom.xml?rev=1145226&r1=1145225&r2=1145226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/pom.xml Mon Jul 11 16:11:30 2011
@@ -101,11 +101,13 @@
               <value>
 org.apache.jackrabbit.core.xml.DocumentViewTest#testMultiValue
 org.apache.jackrabbit.core.ConcurrentImportTest
+org.apache.jackrabbit.core.NodeImplTest#testReferentialIntegrityCorruptionGetPath
 org.apache.jackrabbit.core.integration.ConcurrentQueryTest#testConcurrentQueryWithDeletes
 org.apache.jackrabbit.test.api.ShareableNodeTest#testGetName
 org.apache.jackrabbit.test.api.ShareableNodeTest#testGetNode
 org.apache.jackrabbit.test.api.ShareableNodeTest#testGetNodes
 org.apache.jackrabbit.test.api.ShareableNodeTest#testGetNodesByPattern
+org.apache.jackrabbit.test.api.ShareableNodeTest#testGetNodesByPattern
               </value>
             </property>
             <property>

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java?rev=1145226&r1=1145225&r2=1145226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
Mon Jul 11 16:11:30 2011
@@ -335,4 +335,66 @@ public class NodeImplTest extends Abstra
         session.save();
     }
 
+    /**
+     * Test corruption in session / persistence state after
+     * {@link ReferentialIntegrityException}.
+     * <p>
+     * This is a variant of {@link #testReferentialIntegrityCorruption()}
+     * that checks that {@link Node#getPath()} works after the save operation.
+     * 
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-3018">JCR-3018</a>
+     */
+    public void testReferentialIntegrityCorruptionGetPath() throws Exception {
+        Session session = testRootNode.getSession();
+        Node root = testRootNode.addNode("testReferentialIntegrityCorruption");
+
+        // Create test nodes P1 and P2
+        Node nodeP1 = root.addNode("P1");
+        nodeP1.addMixin("mix:referenceable");
+        Node nodeP2 = root.addNode("P2");
+        nodeP2.addMixin("mix:referenceable");
+        session.save();
+
+        // Create reference from P2 to P1 and save
+        nodeP2.setProperty("referencetoP1", nodeP1);
+        session.save();
+
+        // Add node P3
+        Node nodeP3 = root.addNode("P3");
+        nodeP3.addMixin("mix:referenceable");
+
+        String nodeP3path = nodeP3.getPath();
+
+        // And try to remove P1 while P2 still references P1
+        nodeP1.remove();
+        try {
+            session.save();
+        } catch (ReferentialIntegrityException expected) {
+            // Got ReferentialIntegrityException as expected
+        }
+
+        // Remove P2 and save again, this will succeed. As P1, P2
+        // should be removed and P3 should exist
+        try {
+            nodeP2.remove();
+            session.save();
+        } catch (Exception e) {
+            String msg = "JCR-3018: Saving delete after"
+                    + " ReferentialIntegrityException failed";
+            log.error(msg, e);
+            fail(msg);
+        }
+
+        try {
+            assertEquals(nodeP3path, nodeP3.getPath());
+            nodeP3 = session.getNodeByIdentifier(nodeP3.getIdentifier());
+        } catch (Exception e) {
+            String msg = "JCR-3018: getting path of P3 failed. Corrupt session?";
+            log.error(msg, e);
+            fail(msg);
+        }
+
+        root.remove();
+        session.save();
+    }
 }



Mime
View raw message