- 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:
Roy Wetherall
2006-02-02 12:23:43 +00:00
parent 5d8d0e136c
commit a38de2aa2d
3 changed files with 58 additions and 1 deletions

View File

@@ -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