Fixed one of the failing tests for rules coverage:

- The test model didn't allow multiple values for the category property.
 - The setting of the category in the action puts a single value if one doesn't exist,
   or changes the value to a collection if a category already exists.  This is true even
   if the category is exactly the same.
I have **NOT** managed to fix the 'testInboundRuleType' because it would appear that the
test action evaluation is being done with a NoConditionEvaluator.  The test checks to
see that the action is not executed for an empty content node.  It might be a side-effect
of the parent node update policy ... but I can't see why.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5991 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-06-16 00:40:19 +00:00
parent 0d95c702cb
commit 1bd38892b4
3 changed files with 46 additions and 18 deletions

View File

@@ -142,6 +142,17 @@ public class ActionImpl extends ParameterizedItemImpl
this.actionDefinitionName = actionDefinitionName;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("Action")
.append("[ id=").append(getId())
.append(", node=").append(nodeRef)
.append(" ]");
return sb.toString();
}
/**
* @see org.alfresco.service.cmr.action.Action#getTitle()
*/

View File

@@ -27,6 +27,7 @@ package org.alfresco.repo.action;
import java.util.Set;
import java.util.concurrent.ThreadPoolExecutor;
import org.alfresco.error.StackTraceUtil;
import org.alfresco.repo.rule.RuleServiceImpl;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
@@ -116,6 +117,22 @@ public class AsynchronousActionExecutionQueueImpl implements AsynchronousActionE
actionChain,
executedRules);
threadPoolExecutor.execute(runnable);
// Done
if (logger.isDebugEnabled())
{
// get the stack trace
Exception e = new Exception();
e.fillInStackTrace();
StackTraceElement[] trace = e.getStackTrace();
StringBuilder sb = new StringBuilder();
sb.append("\n")
.append("Placed action on execution queue: \n")
.append(" Action: " + action);
String msg = sb.toString();
sb = new StringBuilder();
StackTraceUtil.buildStackTrace(msg, trace, sb, -1);
logger.debug(sb);
}
}
/**

View File

@@ -27,6 +27,7 @@ package org.alfresco.repo.rule;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -60,8 +61,7 @@ import org.alfresco.repo.dictionary.M2Aspect;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.dictionary.M2Property;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition;
@@ -160,15 +160,15 @@ public class RuleServiceCoverageTest extends TestCase
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
//authenticationComponent.setSystemUserAsCurrentUser();
TransactionWork<Object> setUserWork = new TransactionWork<Object>()
RetryingTransactionCallback<Object> setUserCallback = new RetryingTransactionCallback<Object>()
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
authenticationComponent.setCurrentUser("admin");
return null;
}
};
TransactionUtil.executeInUserTransaction(transactionService, setUserWork);
transactionService.getRetryingTransactionHelper().doInTransaction(setUserCallback);
this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
@@ -218,7 +218,7 @@ public class RuleServiceCoverageTest extends TestCase
genCatProp.setIndexed(true);
genCatProp.setIndexedAtomically(true);
genCatProp.setMandatory(true);
genCatProp.setMultiValued(false);
genCatProp.setMultiValued(true);
genCatProp.setStoredInIndex(true);
genCatProp.setTokenisedInIndex(true);
genCatProp.setType("d:" + DataTypeDefinition.CATEGORY.getLocalName());
@@ -246,11 +246,10 @@ public class RuleServiceCoverageTest extends TestCase
*/
public void testAsyncRuleExecution()
{
final NodeRef newNodeRef = TransactionUtil.executeInUserTransaction(
this.transactionService,
new TransactionUtil.TransactionWork<NodeRef>()
final NodeRef newNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(
new RetryingTransactionCallback<NodeRef>()
{
public NodeRef doWork()
public NodeRef execute()
{
RuleServiceCoverageTest.this.nodeService.addAspect(
RuleServiceCoverageTest.this.nodeRef,
@@ -677,9 +676,11 @@ public class RuleServiceCoverageTest extends TestCase
addContentToNode(newNodeRef2);
// Check that the category value has been set
NodeRef setValue = (NodeRef)this.nodeService.getProperty(newNodeRef2, CAT_PROP_QNAME);
// It has been declared as a multi-value property, so we expect that here
Collection<NodeRef> setValue = (Collection<NodeRef>) this.nodeService.getProperty(newNodeRef2, CAT_PROP_QNAME);
assertNotNull(setValue);
assertEquals(this.catROne, setValue);
assertEquals(1, setValue.size());
assertEquals(this.catROne, setValue.toArray()[0]);
}
@@ -1078,11 +1079,10 @@ public class RuleServiceCoverageTest extends TestCase
this.ruleService.saveRule(this.nodeRef, rule);
List<NodeRef> list = TransactionUtil.executeInUserTransaction(
this.transactionService,
new TransactionUtil.TransactionWork<List<NodeRef>>()
List<NodeRef> list = transactionService.getRetryingTransactionHelper().doInTransaction(
new RetryingTransactionCallback<List<NodeRef>>()
{
public List<NodeRef> doWork()
public List<NodeRef> execute()
{
// Create a new node and check-it out
NodeRef newNodeRef = RuleServiceCoverageTest.this.nodeService.createNode(
@@ -1459,9 +1459,9 @@ public class RuleServiceCoverageTest extends TestCase
this.nodeService.setProperty(nodeRef2, ContentModel.PROP_NAME, "testName2");
assertTrue(this.nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_VERSIONABLE));
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>()
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_NAME, "testName");