mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.2 to HEAD
10963: Merged DEV/LARGE_COLLECTION_PROPERTIES_2.2.1 to V2.2 - PersonService: Lucene removal - Lucene optimizations (in progress) - Multi-valued and locale-specific properties persisted in alf_node_properties - Removal of unused AVM tables 10987: Oracle dialects and enhanced SQL patch support - Only support Alfresco's 9i and 10g dialects (with auto-switching) - SQL script patches can now apply selectively to ranges 11007: Test to check cached retrieval of QNames git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11206 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -88,68 +88,21 @@ public class AuditableAspectTest extends BaseSpringTest
|
||||
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated <b>cm:auditable</b> is always present (2.2.2)
|
||||
*/
|
||||
public void testNoAudit()
|
||||
{
|
||||
// Create a person (which doesn't have auditable capability by default)
|
||||
Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
|
||||
personProps.put(ContentModel.PROP_USERNAME, "test person");
|
||||
personProps.put(ContentModel.PROP_HOMEFOLDER, rootNodeRef);
|
||||
personProps.put(ContentModel.PROP_FIRSTNAME, "test first name");
|
||||
personProps.put(ContentModel.PROP_LASTNAME, "test last name");
|
||||
|
||||
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("{test}testperson"),
|
||||
ContentModel.TYPE_PERSON,
|
||||
personProps);
|
||||
|
||||
// Assert the person is not auditable
|
||||
Set<QName> aspects = nodeService.getAspects(childAssocRef.getChildRef());
|
||||
assertFalse(aspects.contains(ContentModel.ASPECT_AUDITABLE));
|
||||
|
||||
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated <b>cm:auditable</b> is always present (2.2.2)
|
||||
*/
|
||||
public void testAddAudit()
|
||||
{
|
||||
// Create a person
|
||||
Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
|
||||
personProps.put(ContentModel.PROP_USERNAME, "test person");
|
||||
personProps.put(ContentModel.PROP_HOMEFOLDER, rootNodeRef);
|
||||
personProps.put(ContentModel.PROP_FIRSTNAME, "test first name");
|
||||
personProps.put(ContentModel.PROP_LASTNAME, "test last name");
|
||||
|
||||
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("{test}testperson"),
|
||||
ContentModel.TYPE_PERSON,
|
||||
personProps);
|
||||
|
||||
// Assert the person is not auditable
|
||||
Set<QName> aspects = nodeService.getAspects(childAssocRef.getChildRef());
|
||||
assertFalse(aspects.contains(ContentModel.ASPECT_AUDITABLE));
|
||||
|
||||
// Add auditable capability
|
||||
nodeService.addAspect(childAssocRef.getChildRef(), ContentModel.ASPECT_AUDITABLE, null);
|
||||
|
||||
nodeService.addAspect(childAssocRef.getChildRef(), ContentModel.ASPECT_TITLED, null);
|
||||
|
||||
// Assert the person is now audiable
|
||||
aspects = nodeService.getAspects(childAssocRef.getChildRef());
|
||||
assertTrue(aspects.contains(ContentModel.ASPECT_AUDITABLE));
|
||||
|
||||
// Assert the person's auditable property
|
||||
assertAuditableProperties(childAssocRef.getChildRef());
|
||||
|
||||
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||
}
|
||||
|
||||
|
||||
public void testAddAspect()
|
||||
public synchronized void testAddAspect() throws Exception
|
||||
{
|
||||
// Create a person (which doesn't have auditable capability by default)
|
||||
Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
|
||||
@@ -158,20 +111,45 @@ public class AuditableAspectTest extends BaseSpringTest
|
||||
personProps.put(ContentModel.PROP_FIRSTNAME, "test first name ");
|
||||
personProps.put(ContentModel.PROP_LASTNAME, "test last name");
|
||||
|
||||
long t1 = System.currentTimeMillis();
|
||||
this.wait(100);
|
||||
|
||||
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("{test}testperson"),
|
||||
ContentModel.TYPE_PERSON,
|
||||
personProps);
|
||||
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
|
||||
assertAuditableProperties(nodeRef);
|
||||
|
||||
long t2 = System.currentTimeMillis();
|
||||
|
||||
// Check that the dates were set correctly
|
||||
Date aspectCreatedDate1 = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_CREATED);
|
||||
Date aspectModifiedDate1 = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
|
||||
assertTrue("Created date should be later than t1", t1 < aspectCreatedDate1.getTime());
|
||||
assertTrue(
|
||||
"Modified date must be after or on creation date",
|
||||
aspectCreatedDate1.getTime() <= aspectModifiedDate1.getTime() &&
|
||||
aspectModifiedDate1.getTime() < t2);
|
||||
|
||||
long t3 = System.currentTimeMillis();
|
||||
this.wait(100);
|
||||
|
||||
// Add auditable capability
|
||||
nodeService.addAspect(childAssocRef.getChildRef(), ContentModel.ASPECT_TITLED, null);
|
||||
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
||||
|
||||
// Check that the dates were set correctly
|
||||
Date aspectCreatedDate2 = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_CREATED);
|
||||
Date aspectModifiedDate2 = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
|
||||
assertEquals("The created date must not change", aspectCreatedDate1, aspectCreatedDate2);
|
||||
assertTrue("New modified date should be later than t3", t3 < aspectModifiedDate2.getTime());
|
||||
|
||||
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||
}
|
||||
|
||||
|
||||
private void assertAuditableProperties(NodeRef nodeRef)
|
||||
{
|
||||
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
|
||||
|
Reference in New Issue
Block a user