mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Added onContentRead policy to help support planned samples
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2284 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -257,6 +257,7 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
||||
}
|
||||
|
||||
private boolean policyFired = false;
|
||||
private boolean readPolicyFired = false;
|
||||
private boolean newContent = true;
|
||||
|
||||
/**
|
||||
@@ -298,6 +299,35 @@ public class RoutingContentServiceTest extends BaseSpringTest
|
||||
this.policyFired = true;
|
||||
}
|
||||
|
||||
public void testOnContentReadPolicy()
|
||||
{
|
||||
// Register interest in the content read event for a versionable node
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onContentRead"),
|
||||
ContentModel.ASPECT_VERSIONABLE,
|
||||
new JavaBehaviour(this, "onContentReadBehaviourTest"));
|
||||
|
||||
// First check that the policy is not fired when the versionable aspect is not present
|
||||
this.contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertFalse(this.readPolicyFired);
|
||||
|
||||
// Write some content and check that the policy is still not fired
|
||||
ContentWriter contentWriter2 = this.contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter2.putContent("content update two");
|
||||
this.contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertFalse(this.readPolicyFired);
|
||||
|
||||
// Now check that the policy is fired when the versionable aspect is present
|
||||
this.nodeService.addAspect(this.contentNodeRef, ContentModel.ASPECT_VERSIONABLE, null);
|
||||
this.contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertTrue(this.readPolicyFired);
|
||||
}
|
||||
|
||||
public void onContentReadBehaviourTest(NodeRef nodeRef)
|
||||
{
|
||||
this.readPolicyFired = true;
|
||||
}
|
||||
|
||||
public void testTempWrite() throws Exception
|
||||
{
|
||||
// get a temporary writer
|
||||
|
Reference in New Issue
Block a user