mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Big honkin' merge from head. Sheesh!
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,7 +20,6 @@ import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -28,9 +27,7 @@ import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.domain.ChildAssoc;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.domain.NodeAssoc;
|
||||
import org.alfresco.repo.domain.NodeKey;
|
||||
import org.alfresco.repo.domain.NodeStatus;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
@@ -215,52 +212,6 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
assertEquals("Not all aspects persisted", 4, aspects.size());
|
||||
}
|
||||
|
||||
public void testNodeAssoc() throws Exception
|
||||
{
|
||||
// make a source node
|
||||
Node sourceNode = new NodeImpl();
|
||||
sourceNode.setStore(store);
|
||||
sourceNode.setUuid(GUID.generate());
|
||||
sourceNode.setTypeQName(ContentModel.TYPE_CMOBJECT);
|
||||
Serializable realNodeId = getSession().save(sourceNode);
|
||||
|
||||
// make a container node
|
||||
Node targetNode = new NodeImpl();
|
||||
targetNode.setStore(store);
|
||||
targetNode.setStore(store);
|
||||
targetNode.setUuid(GUID.generate());
|
||||
targetNode.setTypeQName(ContentModel.TYPE_CONTAINER);
|
||||
Serializable containerNodeId = getSession().save(targetNode);
|
||||
|
||||
// create an association between them
|
||||
NodeAssoc assoc = new NodeAssocImpl();
|
||||
assoc.setTypeQName(QName.createQName("next"));
|
||||
assoc.buildAssociation(sourceNode, targetNode);
|
||||
getSession().save(assoc);
|
||||
|
||||
// make another association between the same two nodes
|
||||
assoc = new NodeAssocImpl();
|
||||
assoc.setTypeQName(QName.createQName("helper"));
|
||||
assoc.buildAssociation(sourceNode, targetNode);
|
||||
getSession().save(assoc);
|
||||
|
||||
// flush and clear the session
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
|
||||
// reload the source
|
||||
sourceNode = (Node) getSession().get(NodeImpl.class, realNodeId);
|
||||
assertNotNull("Source node not found", sourceNode);
|
||||
// check that the associations are present
|
||||
assertEquals("Expected exactly 2 target assocs", 2, sourceNode.getTargetNodeAssocs().size());
|
||||
|
||||
// reload the target
|
||||
targetNode = (Node) getSession().get(NodeImpl.class, containerNodeId);
|
||||
assertNotNull("Target node not found", targetNode);
|
||||
// check that the associations are present
|
||||
assertEquals("Expected exactly 2 source assocs", 2, targetNode.getSourceNodeAssocs().size());
|
||||
}
|
||||
|
||||
public void testChildAssoc() throws Exception
|
||||
{
|
||||
// make a content node
|
||||
@@ -281,35 +232,27 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
assoc1.setIsPrimary(true);
|
||||
assoc1.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc1.setQname(QName.createQName(null, "number1"));
|
||||
assoc1.setChildNodeName("number1");
|
||||
assoc1.setChildNodeNameCrc(1);
|
||||
assoc1.buildAssociation(containerNode, contentNode);
|
||||
getSession().save(assoc1);
|
||||
|
||||
// make another association between the same two parent and child nodes
|
||||
ChildAssoc assoc2 = new ChildAssocImpl();
|
||||
assoc2.setIsPrimary(true);
|
||||
assoc2.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc2.setTypeQName(QName.createQName(null, "type2"));
|
||||
assoc2.setQname(QName.createQName(null, "number2"));
|
||||
assoc2.setChildNodeName("number2");
|
||||
assoc2.setChildNodeNameCrc(2);
|
||||
assoc2.buildAssociation(containerNode, contentNode);
|
||||
getSession().save(assoc2);
|
||||
|
||||
assertFalse("Hashcode incorrent", assoc2.hashCode() == 0);
|
||||
assertNotSame("Assoc equals failure", assoc1, assoc2);
|
||||
|
||||
// flushAndClear();
|
||||
|
||||
// reload the container
|
||||
containerNode = (Node) getSession().get(NodeImpl.class, containerNodeId);
|
||||
assertNotNull("Node not found", containerNode);
|
||||
// check
|
||||
assertEquals("Expected exactly 2 children", 2, containerNode.getChildAssocs().size());
|
||||
for (Iterator iterator = containerNode.getChildAssocs().iterator(); iterator.hasNext(); /**/)
|
||||
{
|
||||
ChildAssoc assoc = (ChildAssoc) iterator.next();
|
||||
// the node id must be known
|
||||
assertNotNull("Node not populated on assoc", assoc.getChild());
|
||||
assertEquals("Node key on child assoc is incorrect",
|
||||
contentNodeId, assoc.getChild().getId());
|
||||
}
|
||||
|
||||
// check that we can traverse the association from the child
|
||||
Collection<ChildAssoc> parentAssocs = contentNode.getParentAssocs();
|
||||
@@ -362,7 +305,6 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
Map<QName, PropertyValue> checkProperties = checkNode.getProperties();
|
||||
assertTrue("Propery map retrieved was not the same instance", checkProperties == properties);
|
||||
assertTrue("Property not found", checkProperties.containsKey(ContentModel.PROP_NAME));
|
||||
// assertTrue("Property value instance retrieved not the same", checkProperties)
|
||||
|
||||
flushAndClear();
|
||||
// commit the transaction
|
||||
@@ -380,8 +322,6 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
assertNotNull(checkNode);
|
||||
checkAspects = checkNode.getAspects();
|
||||
|
||||
// assertTrue("Node retrieved was not same instance", checkNode == node);
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
@@ -448,6 +388,8 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
assoc1.setIsPrimary(true);
|
||||
assoc1.setTypeQName(QName.createQName(null, "type1"));
|
||||
assoc1.setQname(QName.createQName(null, "number1"));
|
||||
assoc1.setChildNodeName("number1");
|
||||
assoc1.setChildNodeNameCrc(1);
|
||||
assoc1.buildAssociation(containerNode, contentNode1);
|
||||
getSession().save(assoc1);
|
||||
// create an association to content 2
|
||||
@@ -455,6 +397,8 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
assoc2.setIsPrimary(true);
|
||||
assoc2.setTypeQName(QName.createQName(null, "type2"));
|
||||
assoc2.setQname(QName.createQName(null, "number2"));
|
||||
assoc2.setChildNodeName("number2");
|
||||
assoc2.setChildNodeNameCrc(2);
|
||||
assoc2.buildAssociation(containerNode, contentNode2);
|
||||
getSession().save(assoc2);
|
||||
|
||||
@@ -465,37 +409,10 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
// now read the structure back in from the container down
|
||||
containerNodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, containerNodeKey);
|
||||
containerNode = containerNodeStatus.getNode();
|
||||
Collection<ChildAssoc> assocs = containerNode.getChildAssocs();
|
||||
for (ChildAssoc assoc : assocs)
|
||||
{
|
||||
Node childNode = assoc.getChild();
|
||||
Store store = childNode.getStore();
|
||||
childNode.getAspects().size();
|
||||
childNode.getProperties().size();
|
||||
childNode.getParentAssocs().size();
|
||||
childNode.getChildAssocs().size();
|
||||
childNode.getSourceNodeAssocs().size();
|
||||
childNode.getTargetNodeAssocs().size();
|
||||
DbAccessControlList acl = childNode.getAccessControlList();
|
||||
if (acl != null)
|
||||
{
|
||||
acl.getEntries().size();
|
||||
}
|
||||
}
|
||||
|
||||
// clear out again
|
||||
getSession().clear();
|
||||
|
||||
// now remove a property from each child
|
||||
containerNodeStatus = (NodeStatus) getSession().get(NodeStatusImpl.class, containerNodeKey);
|
||||
containerNode = containerNodeStatus.getNode();
|
||||
assocs = containerNode.getChildAssocs();
|
||||
for (ChildAssoc assoc : assocs)
|
||||
{
|
||||
Node childNode = assoc.getChild();
|
||||
PropertyValue removed = childNode.getProperties().remove(ContentModel.PROP_ARCHIVED_BY);
|
||||
assertNotNull("Property was not present", removed);
|
||||
}
|
||||
// expect that just the specific property gets removed in the delete statement
|
||||
getSession().flush();
|
||||
getSession().clear();
|
||||
@@ -510,6 +427,8 @@ public class HibernateNodeTest extends BaseSpringTest
|
||||
assoc3.setIsPrimary(false);
|
||||
assoc3.setTypeQName(QName.createQName(null, "type3"));
|
||||
assoc3.setQname(QName.createQName(null, "number3"));
|
||||
assoc3.setChildNodeName("number3");
|
||||
assoc3.setChildNodeNameCrc(2);
|
||||
assoc3.buildAssociation(containerNode, contentNode2); // check whether the children are pulled in for this
|
||||
getSession().save(assoc3);
|
||||
|
||||
|
Reference in New Issue
Block a user