mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for rev 31223: Missing child node cache invalidation call (ALF-10699)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31253 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,6 +21,7 @@ package org.alfresco.repo.node;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,6 +32,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -423,4 +425,41 @@ public class NodeServiceTest extends TestCase
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the node caches react correct when a node is deleted
|
||||
*/
|
||||
public void testCaches_DeleteNode()
|
||||
{
|
||||
final NodeRef[] liveNodeRefs = new NodeRef[10];
|
||||
final NodeRef workspaceRootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
|
||||
buildNodeHierarchy(workspaceRootNodeRef, liveNodeRefs);
|
||||
nodeService.addAspect(liveNodeRefs[3], ContentModel.ASPECT_TEMPORARY, null);
|
||||
|
||||
// Create a child under node 2
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(3);
|
||||
props.put(ContentModel.PROP_NAME, "Secondary");
|
||||
NodeRef secondaryNodeRef = nodeService.createNode(
|
||||
liveNodeRefs[2],
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NAMESPACE, "secondary"),
|
||||
ContentModel.TYPE_FOLDER,
|
||||
props).getChildRef();
|
||||
// Make it a child of node 3
|
||||
nodeService.addChild(liveNodeRefs[3], secondaryNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NAMESPACE, "secondary"));
|
||||
// Make it a child of node 4
|
||||
nodeService.addChild(liveNodeRefs[4], secondaryNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NAMESPACE, "secondary"));
|
||||
|
||||
// Check
|
||||
List<ChildAssociationRef> parentAssocsPre = nodeService.getParentAssocs(secondaryNodeRef);
|
||||
assertEquals("Incorrect number of parent assocs", 3, parentAssocsPre.size());
|
||||
|
||||
// Delete node 3 (should affect 2 of the parent associations);
|
||||
nodeService.deleteNode(liveNodeRefs[3]);
|
||||
|
||||
// Check
|
||||
List<ChildAssociationRef> parentAssocsPost = nodeService.getParentAssocs(secondaryNodeRef);
|
||||
assertEquals("Incorrect number of parent assocs", 1, parentAssocsPost.size());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user