jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r160903 - in incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/ java/org/apache/jackrabbit/core/xml/ test/org/apache/jackrabbit/test/api/
Date Mon, 11 Apr 2005 15:14:27 GMT
Author: stefan
Date: Mon Apr 11 08:14:23 2005
New Revision: 160903

URL: http://svn.apache.org/viewcvs?view=rev&rev=160903
Log:
fixed incorrect test cases and fixed code that caused valid testcases to fail

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
Mon Apr 11 08:14:23 2005
@@ -377,7 +377,8 @@
         try {
             int depth = 0;
             ItemState state = getItemState(id);
-            for (String parentUUID = state.getParentUUID(); parentUUID != null;) {
+            String parentUUID = state.getParentUUID();
+            while (parentUUID != null) {
                 state = (NodeState) getItemState(new NodeId(parentUUID));
                 parentUUID = state.getParentUUID();
                 depth++;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Mon Apr 11
08:14:23 2005
@@ -1424,6 +1424,9 @@
      * {@inheritDoc}
      */
     public String getPath() throws RepositoryException {
+        // check state of this instance
+        sanityCheck();
+
         try {
             return getPrimaryPath().toJCRPath(session.getNamespaceResolver());
         } catch (NoPrefixDeclaredException npde) {
@@ -1438,6 +1441,9 @@
      * {@inheritDoc}
      */
     public int getDepth() throws RepositoryException {
+        // check state of this instance
+        sanityCheck();
+
         if (state.getParentUUID() == null) {
             // shortcut
             return 0;
@@ -1449,6 +1455,9 @@
      * {@inheritDoc}
      */
     public Session getSession() throws RepositoryException {
+        // check state of this instance
+        sanityCheck();
+
         return session;
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Mon Apr 11
08:14:23 2005
@@ -626,8 +626,7 @@
             // remove properties
             // use temp array to avoid ConcurrentModificationException
             tmp = new ArrayList(thisState.getPropertyEntries());
-            // remove from tail to avoid problems with same-name siblings
-            for (int i = tmp.size() - 1; i >= 0; i--) {
+            for (int i = 0; i < tmp.size(); i++) {
                 NodeState.PropertyEntry entry = (NodeState.PropertyEntry) tmp.get(i);
                 removeChildProperty(entry.getName());
             }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java Mon Apr
11 08:14:23 2005
@@ -1173,6 +1173,9 @@
      * {@inheritDoc}
      */
     public String getName() throws RepositoryException {
+        // check state of this instance
+        sanityCheck();
+
         PropertyId propId = (PropertyId) id;
         QName name = propId.getName();
         try {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/WorkspaceImpl.java Mon
Apr 11 08:14:23 2005
@@ -897,8 +897,7 @@
             // remove properties
             // use temp array to avoid ConcurrentModificationException
             tmp = new ArrayList(targetState.getPropertyEntries());
-            // remove from tail to avoid problems with same-name siblings
-            for (int i = tmp.size() - 1; i >= 0; i--) {
+            for (int i = 0; i < tmp.size(); i++) {
                 NodeState.PropertyEntry entry = (NodeState.PropertyEntry) tmp.get(i);
                 PropertyId propId =
                         new PropertyId(targetState.getUUID(), entry.getName());
@@ -923,8 +922,9 @@
         targetState.removeParentUUID(parentUUID);
 
         if (orphaned) {
-            // destroy target state
-            stateMgr.destroy(targetState);
+            // destroy target state (pass overlayed state since target state
+            // might have been modified during unlinking)
+            stateMgr.destroy(targetState.getOverlayedState());
         } else {
             // store target state
             stateMgr.store(targetState);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
Mon Apr 11 08:14:23 2005
@@ -474,8 +474,7 @@
             // remove properties
             // use temp array to avoid ConcurrentModificationException
             tmp = new ArrayList(target.getPropertyEntries());
-            // remove from tail to avoid problems with same-name siblings
-            for (int i = tmp.size() - 1; i >= 0; i--) {
+            for (int i = 0; i < tmp.size(); i++) {
                 NodeState.PropertyEntry entry = (NodeState.PropertyEntry) tmp.get(i);
                 PropertyId propId =
                         new PropertyId(target.getUUID(), entry.getName());
@@ -499,7 +498,9 @@
         target.removeParentUUID(parentUUID);
 
         if (orphaned) {
-            // destroy target
+            // destroy target state (pass overlayed state since target state
+            // might have been modified during unlinking)
+            stateMgr.destroy(target.getOverlayedState());
             stateMgr.destroy(target);
         } else {
             // store target

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java
Mon Apr 11 08:14:23 2005
@@ -50,17 +50,14 @@
     /**
      * add the mix:referenceable mixin type to a node.
      *
-     * @param parent
      * @param node
      * @return referenceable node.
      */
-    protected Node addMixinReferenceableToNode(Node parent, Node node) throws RepositoryException
{
-        NodeType nodetype = node.getPrimaryNodeType();
-        if (!nodetype.isNodeType(mixReferenceable)) {
+    protected Node addMixinReferenceableToNode(Node node) throws RepositoryException {
+        if (!node.isNodeType(mixReferenceable)) {
             node.addMixin(mixReferenceable);
+            node.save();
         }
-        parent.save();
-
         return node;
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
Mon Apr 11 08:14:23 2005
@@ -38,7 +38,7 @@
      */
     public void testCloneNodesReferenceableNodesOriginalUUID() throws RepositoryException
{
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
 
         // copy referenceable node below non-referenceable node
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();
@@ -62,7 +62,7 @@
      */
     public void testCloneNodesRemoveExistingTrue() throws RepositoryException {
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
 
         // clone a node from default workspace to have the same uuid on second workspace
         String dstAbsPath = node2W2.getPath() + "/" + nodeName2;
@@ -76,11 +76,7 @@
 
         // because a node with same uuid exists (cloned node in earlier step - nodeName2),
the existing node (and its subtree)
         // should be removed ...
-        assertFalse(testRootNodeW2.hasNode(clonedNode.getName()));
-
-        // ... and is copied to this workspace as part of the copied subtree (that is, not
into the former location of the old node).
-        Node clonedNodeMoved = clonedNode2.getNode(clonedNode.getName());
-        assertTrue(testRootNodeW2.hasNode(clonedNodeMoved.getName()));
+        assertFalse(node2W2.hasNode(nodeName2));
     }
 
     /**
@@ -89,7 +85,7 @@
      */
     public void testCloneNodesRemoveExistingFalse() throws RepositoryException {
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
 
         // clone a node from default workspace to have the same uuid on second workspace
         workspaceW2.clone(workspace.getName(), node1.getPath(), testRootNodeW2.getPath()
+ "/" + nodeName2, false);
@@ -110,7 +106,7 @@
         // clone referenceable node
 
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
         if (node1.isNodeType(mixReferenceable)) {
             workspaceW2.clone(workspace.getName(), node1.getPath(), testRootNodeW2.getPath()
+ "/" + nodeName2, false);
         } else {

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
Mon Apr 11 08:14:23 2005
@@ -106,7 +106,7 @@
      */
     public void testCloneNodesAccessDenied() throws RepositoryException {
         // logout and get read only session
-        superuser.logout();
+        //superuser.logout();
         Session readOnlySuperuser = helper.getReadOnlySession();
 
         String dstAbsPath = node2.getPath() + "/" + node1.getName();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
Mon Apr 11 08:14:23 2005
@@ -36,7 +36,7 @@
      */
     public void testCopyNodesReferenceableNodesNewUUID() throws RepositoryException {
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
         
         // copy referenceable node below non-referenceable node
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
Mon Apr 11 08:14:23 2005
@@ -109,8 +109,6 @@
      * sufficient access permissions to complete the operation.
      */
     public void testCopyNodesAccessDenied() throws RepositoryException {
-        // logout and get read only session
-        superuser.logout();
         Session readOnlySuperuser = helper.getReadOnlySession();
 
         String dstAbsPath = node2.getPath() + "/" + node1.getName();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
Mon Apr 11 08:14:23 2005
@@ -36,7 +36,7 @@
      */
     public void testCopyNodesNewUUID() throws RepositoryException {
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
         
         // copy referenceable node below non-referenceable node
         String dstAbsPath = node2.getPath() + "/" + node1.getName();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
Mon Apr 11 08:14:23 2005
@@ -90,8 +90,6 @@
      * sufficient access permissions to complete the operation.
      */
     public void testCopyNodesAccessDenied() throws RepositoryException {
-        // logout and get read only session
-        superuser.logout();
         Session readOnlySuperuser = helper.getReadOnlySession();
 
         String dstAbsPath = node2.getPath() + "/" + node1.getName();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
Mon Apr 11 08:14:23 2005
@@ -36,7 +36,7 @@
      */
     public void testMoveNodesReferenceableNodesNewUUID() throws RepositoryException {
         // add mixin referenceable to node1
-        addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(node1);
         
         // copy referenceable node below non-referenceable node
         String dstAbsPath = node2.getPath() + "/" + node1.getName();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java?view=diff&r1=160902&r2=160903
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
Mon Apr 11 08:14:23 2005
@@ -90,8 +90,6 @@
      * sufficient access permissions to complete the operation.
      */
     public void testMoveNodesAccessDenied() throws RepositoryException {
-        // logout and get read only session
-        superuser.logout();
         Session readOnlySuperuser = helper.getReadOnlySession();
 
         String dstAbsPath = node2.getPath() + "/" + node1.getName();



Mime
View raw message