Index: jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java
===================================================================
--- jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java	(revision 804874)
+++ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ShareableNodeTest.java	(working copy)
@@ -119,4 +119,25 @@
         superuser.getWorkspace().getObservationManager().removeEventListener(el);
         assertEquals(1, el.getEventCount());
     }
+    
+    /**
+     * Verify that a shared node is removed when the ancestor is removed.
+     */
+    public void testRemoveAncestorOfSharedNode() throws Exception {
+       Node a1 = testRootNode.addNode("a1");
+       Node a2 = a1.addNode("a2");
+       Node b1 = a1.addNode("b1");
+       ensureMixinType(b1, mixShareable);
+       testRootNode.save();
+       //now we have a shareable node N with path a1/b1
+
+       Workspace workspace = testRootNode.getSession().getWorkspace();
+       String path = a2.getPath() + "/b2";
+       workspace.clone(workspace.getName(), b1.getPath(), path, false);
+       testRootNode.save();
+       //now we have another shareable node N' in the same shared set as N with path a1/a2/b2
+
+       a2.remove();
+       testRootNode.save();
+    } 
 }
