Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java =================================================================== --- modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java (revision 6529) +++ modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java (working copy) @@ -34,6 +34,7 @@ import org.jbpm.api.JbpmException; import org.jbpm.pvm.internal.el.Expression; import org.jbpm.pvm.internal.env.EnvironmentImpl; +import org.jbpm.pvm.internal.model.ExecutionImpl; import org.jbpm.pvm.internal.util.Clock; /** @@ -110,6 +111,10 @@ } public static Date calculateDueDate(String durationExpression) { + return calculateDueDate(durationExpression, null); + } + + public static Date calculateDueDate(String durationExpression, ExecutionImpl executionImpl) { Date duedate = null; if (durationExpression != null) { @@ -120,7 +125,7 @@ if (durationExpression.startsWith("#")) { String baseDateEL = durationExpression.substring(0, durationExpression.indexOf("}") + 1); - Object result = Expression.create(baseDateEL).evaluate(); + Object result = Expression.create(baseDateEL).evaluate(executionImpl); if (result instanceof Date) { baseDate = (Date) result; @@ -132,7 +137,7 @@ if (endOfELIndex < (durationExpression.length() - 1)) { throw new JbpmException("Invalid duedate, didnot support + or - in String type EL."); } - durationString = (String) Expression.create(durationExpression, null).evaluate((Execution) null); + durationString = (String) Expression.create(durationExpression, null).evaluate(executionImpl); } else { throw new JbpmException("Invalid basedate type: " + baseDateEL + " is of type " + result.getClass().getName() Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java =================================================================== --- modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java (revision 6529) +++ modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java (working copy) @@ -40,7 +40,7 @@ /** * a runtime timer instance. - * + * * @author Tom Baeyens * @author Pascal Verdage * @author Alejandro Guizar @@ -71,7 +71,7 @@ public void setDueDateDescription(String dueDateDescription) { if (dueDateDescription != null) { - dueDate = Duration.calculateDueDate(dueDateDescription); + dueDate = Duration.calculateDueDate(dueDateDescription, this.execution); } } Index: modules/test-db/src/test/java/org/jbpm/test/timer/StartProcessTimerTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/timer/StartProcessTimerTest.java (revision 0) +++ modules/test-db/src/test/java/org/jbpm/test/timer/StartProcessTimerTest.java (revision 0) @@ -0,0 +1,99 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jbpm.test.timer; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jbpm.api.ProcessInstance; +import org.jbpm.api.job.Job; +import org.jbpm.api.listener.EventListener; +import org.jbpm.api.listener.EventListenerExecution; +import org.jbpm.test.JbpmTestCase; + +/** + * + * @author Maciej Swiderski + * + */ +public class StartProcessTimerTest extends JbpmTestCase { + + + + public void testTimerTimeout() { + deployJpdlXmlString( + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + ); + Map variables = new HashMap(); + variables.put("duedate", "24 business minutes"); + ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", variables, "82436"); + + List job = managementService.createJobQuery() + .processInstanceId(processInstance.getId()) + .list(); + + assertEquals(2, job.size()); + + managementService.executeJob(job.get(0).getId()); + + managementService.executeJob(job.get(1).getId()); + + String executionId = processInstance.findActiveExecutionIn("a").getId(); + + processInstance = executionService.signalExecutionById(executionId); + executionService.signalExecutionById(processInstance.getId()); + + assertProcessInstanceEnded(processInstance); + } + + public static class MyCustomEvent implements EventListener { + + private static final long serialVersionUID = 1L; + + static int nrOfTimesCalled; + + public void notify(EventListenerExecution execution) throws Exception { + nrOfTimesCalled++; + } + } + +}