Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java =================================================================== --- modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java (revision 6454) +++ modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java (working copy) @@ -39,14 +39,14 @@ import org.w3c.dom.Element; /** parses a descriptor for creating a java object through reflection. - * + * * See schema docs for more details. - * + * * @author Tom Baeyens * @author Guillaume Porcher (documentation) */ public class ObjectBinding extends WireDescriptorBinding { - + public static final String TAG = "object"; public ObjectBinding() { @@ -54,15 +54,18 @@ } public static boolean isObjectDescriptor(Element element) { - if (XmlUtil.attribute(element, "class")!=null) { + if (XmlUtil.attribute(element, "class") != null) { return true; } - if (XmlUtil.attribute(element, "factory")!=null) { + if (XmlUtil.attribute(element, "expr") != null) { return true; } - if (XmlUtil.element(element, "factory")!=null) { + if (XmlUtil.attribute(element, "factory") != null) { return true; } + if (XmlUtil.element(element, "factory") != null) { + return true; + } return false; } @@ -78,43 +81,49 @@ String factoryObjectName = XmlUtil.attribute(element, "factory"); Element factoryElement = XmlUtil.element(element, "factory"); - if (className!=null) { + if (className != null) { descriptor.setClassName(className); - if (factoryObjectName!=null) { - parse.addProblem("attribute 'factory' is specified together with attribute 'class' in element 'object': "+XmlUtil.toString(element), element); + if (factoryObjectName != null) { + parse.addProblem("attribute 'factory' is specified together with attribute 'class' in element 'object': " + + XmlUtil.toString(element), element); } - if (factoryElement!=null) { - parse.addProblem("element 'factory' is specified together with attribute 'class' in element 'object': "+XmlUtil.toString(element), element); + if (factoryElement != null) { + parse.addProblem("element 'factory' is specified together with attribute 'class' in element 'object': " + + XmlUtil.toString(element), element); } Element constructorElement = XmlUtil.element(element, "constructor"); - if (constructorElement!=null) { + if (constructorElement != null) { List argElements = XmlUtil.elements(constructorElement, "arg"); List argDescriptors = parser.parseArgs(argElements, parse); descriptor.setArgDescriptors(argDescriptors); if (element.hasAttribute("method")) { - parse.addProblem("attributes 'class' and 'method' indicate static method and also a 'constructor' element is specified for element 'object': "+XmlUtil.toString(element), element); + parse.addProblem("attributes 'class' and 'method' indicate static method and also a 'constructor' element is specified for element 'object': " + + XmlUtil.toString(element), element); } } - } else if (factoryObjectName!=null) { + } else if (factoryObjectName != null) { descriptor.setFactoryObjectName(factoryObjectName); if (factoryElement!=null) { - parse.addProblem("element 'factory' is specified together with attribute 'factory' in element 'object': "+XmlUtil.toString(element), element); + parse.addProblem("element 'factory' is specified together with attribute 'factory' in element 'object': " + + XmlUtil.toString(element), element); } - } else if (factoryElement!=null) { + } else if (factoryElement != null) { Element factoryDescriptorElement = XmlUtil.element(factoryElement); - Descriptor factoryDescriptor = (Descriptor) parser.parseElement(factoryDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR); + Descriptor factoryDescriptor = (Descriptor) parser.parseElement(factoryDescriptorElement, + parse, WireParser.CATEGORY_DESCRIPTOR); descriptor.setFactoryDescriptor(factoryDescriptor); - } else if (expr!=null) { + } else if (expr != null) { String exprType = XmlUtil.attribute(element, "expr-type"); descriptor.setExpression(Expression.create(expr, exprType)); - + } else { - parse.addProblem("element 'object' must have one of {attribute 'class', attribute 'expr', attribute 'factory' or element 'factory'}: "+XmlUtil.toString(element), element); + parse.addProblem("element 'object' must have one of {attribute 'class', attribute 'expr', attribute 'factory' or element 'factory'}: " + + XmlUtil.toString(element), element); } // method @@ -124,22 +133,24 @@ List argElements = XmlUtil.elements(element, "arg"); List argDescriptors = parser.parseArgs(argElements, parse); descriptor.setArgDescriptors(argDescriptors); - } else if ( (factoryObjectName!=null) - || (factoryElement!=null) + } else if ( (factoryObjectName != null) + || (factoryElement != null) ) { - parse.addProblem("element 'object' with a element 'factory' or a attribute 'factory' must have a attribute 'method': "+XmlUtil.toString(element), element); + parse.addProblem("element 'object' with a element 'factory' or a attribute 'factory' must have a attribute 'method': " + + XmlUtil.toString(element), element); } - if( (className == null) + if( (className == null) && (XmlUtil.element(element, "constructor") != null) ) { - parse.addProblem("element 'object' with a 'constructor' element must have 'class' attribute: "+XmlUtil.toString(element), element); + parse.addProblem("element 'object' with a 'constructor' element must have 'class' attribute: " + + XmlUtil.toString(element), element); } // read the operations elements List operations = null; List elements = XmlUtil.elements(element); - + Set operationTagNames = null; Bindings bindings = parser.getBindings(); if (bindings!=null) { @@ -148,10 +159,10 @@ operationTagNames = Collections.emptySet(); } - for (Element childElement: elements) { + for (Element childElement : elements) { if (operationTagNames.contains(childElement.getTagName())) { Operation operation = (Operation) parser.parseElement(childElement, parse, WireParser.CATEGORY_OPERATION); - if (operations==null) { + if (operations == null) { operations = new ArrayList(); } operations.add(operation); @@ -161,7 +172,7 @@ // autowiring Boolean isAutoWireEnabled = XmlUtil.attributeBoolean(element, "auto-wire", parse); - if (isAutoWireEnabled!=null) { + if (isAutoWireEnabled != null) { descriptor.setAutoWireEnabled(isAutoWireEnabled); } return descriptor; Index: modules/test-db/src/test/java/org/jbpm/test/task/ExceptionTaskTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/task/ExceptionTaskTest.java (revision 6454) +++ modules/test-db/src/test/java/org/jbpm/test/task/ExceptionTaskTest.java (working copy) @@ -1,61 +0,0 @@ -package org.jbpm.test.task; - -import java.util.*; - -import org.jbpm.api.*; -import org.jbpm.api.job.*; -import org.jbpm.api.task.*; - -import org.jbpm.test.*; - - -public class ExceptionTaskTest extends JbpmTestCase { - protected void setUp() throws Exception { - super.setUp(); - identityService.createUser("johnsmith", "johnsmith", "johnsmith"); - deployJpdlXmlString( - "" - + " " - + " " - + " " + " " - + " " - + " " + " " - + " " - + " ${task.name}" + " " - + " " + " " + " " - + " " - + " " + ""); - } - - protected void tearDown() throws Exception { - identityService.deleteUser("johnsmith"); - super.tearDown(); - } - - public void testDefault() throws Exception { - ProcessInstance processInstance = executionService - .startProcessInstanceByKey("X10ExceptionTaskTest"); - String processInstanceId = processInstance.getId(); - int retries = 0; - - while (retries < 3) { - retries++; - - try { - List jobs = managementService.createJobQuery().list(); - Job job = jobs.get(0); - managementService.executeJob(job.getId()); - - break; - } catch (Exception e) { - System.out.println(e); - } - } - - List tasks = taskService.createTaskQuery().list(); - assertEquals(0, tasks.size()); - } -} Index: modules/test-db/src/test/java/org/jbpm/test/task/NotificationTaskTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/task/NotificationTaskTest.java (revision 6454) +++ modules/test-db/src/test/java/org/jbpm/test/task/NotificationTaskTest.java (working copy) @@ -1,43 +1,55 @@ package org.jbpm.test.task; +import java.io.*; import java.util.*; +import javax.mail.Message; import org.jbpm.api.*; import org.jbpm.api.job.*; import org.jbpm.api.task.*; - +import org.jbpm.pvm.internal.email.spi.*; import org.jbpm.test.*; - -public class ExceptionTaskTest extends JbpmTestCase { +/** + * @author Huisheng Xu + */ +public class NotificationTaskTest extends JbpmTestCase { protected void setUp() throws Exception { super.setUp(); identityService.createUser("johnsmith", "johnsmith", "johnsmith"); + } + + protected void tearDown() throws Exception { + identityService.deleteUser("johnsmith"); + super.tearDown(); + } + + public void t1estDefault() throws Exception { deployJpdlXmlString( - "" + "" + " " + " " - + " " + " " + + " " + + " " + " " - + " " + " " + + " " + + " " + " " - + " ${task.name}" + " " + + " ${task.name}" + + " " + " " + " " + " " + + " ${task.description}" + + " Sent by JBoss jBPM" + + " ]]>" + + " " + + " " + " " - + " " + ""); - } + + " " + + ""); - protected void tearDown() throws Exception { - identityService.deleteUser("johnsmith"); - super.tearDown(); - } - - public void testDefault() throws Exception { ProcessInstance processInstance = executionService - .startProcessInstanceByKey("X10ExceptionTaskTest"); + .startProcessInstanceByKey("NotificationTaskTest"); String processInstanceId = processInstance.getId(); int retries = 0; @@ -58,4 +70,32 @@ List tasks = taskService.createTaskQuery().list(); assertEquals(0, tasks.size()); } + + public void testSupportExpr() { + deployJpdlXmlString( + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""); + + ProcessInstance processInstance = executionService + .startProcessInstanceByKey("NotificationTaskTest", + Collections.singletonMap("jbpmCustomMailProducer", new JbpmCustomMailProducer())); + String processInstanceId = processInstance.getId(); + } + + public static class JbpmCustomMailProducer implements MailProducer, Serializable { + private String templateName; + public Collection produce(Execution execution) { + return Collections.EMPTY_SET; + } + } }