[jbpm-commits] JBoss JBPM SVN: r6127 - in jbpm4/trunk: modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer and 15 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 25 08:47:19 EST 2010
Author: tom.baeyens at jboss.com
Date: 2010-01-25 08:47:18 -0500 (Mon, 25 Jan 2010)
New Revision: 6127
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java
Modified:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
jbpm4/trunk/pom.xml
Log:
fixing test clock handling
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -45,12 +45,12 @@
@Override
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testIntermediateTimerWithDuration() {
- Clock.setCurrentTime(new Date(0));
+ Clock.setExplicitTime(new Date(0));
ProcessInstance processInstance = executionService.startProcessInstanceByKey("intermediateTimerCatch");
Job timerJob = managementService.createJobQuery()
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -86,7 +86,7 @@
Date end = null;
long millis = convertToMillis(duration);
end = new Date(date.getTime()-millis);
- if (end.before(Clock.getCurrentTime())) {
+ if (end.before(Clock.getTime())) {
throw new JbpmException("Duedate "+ end+ " in the past");
}
return end;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -1035,7 +1035,7 @@
//Calendar cl = Calendar.getInstance(getTimeZone());
Calendar cl = Calendar.getInstance();
- cl.setTime(Clock.getCurrentTime());
+ cl.setTime(Clock.getTime());
// move ahead one second, since we're computing the time *after* the
// given time
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -380,7 +380,7 @@
public TaskImpl createTask() {
TaskImpl task = newTask();
- task.setCreateTime(Clock.getCurrentTime());
+ task.setCreateTime(Clock.getTime());
return task;
}
@@ -409,14 +409,14 @@
public JobImpl<?> findFirstAcquirableJob() {
Query query = session.getNamedQuery("findFirstAcquirableJob");
- query.setTimestamp("now", Clock.getCurrentTime());
+ query.setTimestamp("now", Clock.getTime());
query.setMaxResults(1);
return (JobImpl<?>) query.uniqueResult();
}
public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
Query query = session.getNamedQuery("findExclusiveJobs");
- query.setTimestamp("now", Clock.getCurrentTime());
+ query.setTimestamp("now", Clock.getTime());
query.setEntity("processInstance", processInstance);
return query.list();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -54,7 +54,7 @@
}
protected void updateHistoryActivityInstance(HistoryActivityInstanceImpl historyActivityInstance) {
- historyActivityInstance.setEndTime(Clock.getCurrentTime());
+ historyActivityInstance.setEndTime(Clock.getTime());
historyActivityInstance.setTransitionName(transitionName);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -38,7 +38,7 @@
Session session = EnvironmentImpl.getFromCurrent(Session.class);
HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
session.load(HistoryProcessInstanceImpl.class, execution.getDbid());
- historyProcessInstanceImpl.setEndTime(Clock.getCurrentTime());
+ historyProcessInstanceImpl.setEndTime(Clock.getTime());
historyProcessInstanceImpl.setState(execution.getState());
historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -49,12 +49,12 @@
Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
session.load(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
- historyTaskInstance.setEndTime(Clock.getCurrentTime());
+ historyTaskInstance.setEndTime(Clock.getTime());
historyTaskInstance.setTransitionName(outcome);
HistoryTaskImpl historyTask = historyTaskInstance.getHistoryTask();
historyTask.setOutcome(outcome);
- historyTask.setEndTime(Clock.getCurrentTime());
+ historyTask.setEndTime(Clock.getTime());
historyTask.setState(HistoryTask.STATE_COMPLETED);
session.update(historyTaskInstance);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -56,7 +56,7 @@
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
HistoryTaskImpl historyTask = (HistoryTaskImpl) dbSession.get(HistoryTaskImpl.class, task.getDbid());
historyTask.setState(reason);
- historyTask.setEndTime(Clock.getCurrentTime());
+ historyTask.setEndTime(Clock.getTime());
}
protected Class<? extends HistoryActivityInstanceImpl> getHistoryActivityInstanceClass() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -38,6 +38,6 @@
public HistoryAutomaticInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution) {
super(historyProcessInstanceImpl, execution);
- setEndTime(Clock.getCurrentTime());
+ setEndTime(Clock.getTime());
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -57,7 +57,7 @@
// the default constructor which is used by hibernate
protected HistoryDetailImpl(String dummy) {
this.dbid = DbidGenerator.getDbidGenerator().getNextId();
- this.time = Clock.getCurrentTime();
+ this.time = Clock.getTime();
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
if (environment!=null) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -78,7 +78,7 @@
this.processInstanceId = processInstance.getId();
this.key = processInstance.getKey();
this.state = "active";
- this.startTime = Clock.getCurrentTime();
+ this.startTime = Clock.getTime();
}
public void setEndTime(Date endTime) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -71,7 +71,7 @@
this.assignee = task.getAssignee();
this.priority = task.getPriority();
this.duedate = task.getDuedate();
- this.createTime = Clock.getCurrentTime();
+ this.createTime = Clock.getTime();
}
public void updated(TaskImpl task) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -125,7 +125,7 @@
if (durationMatcher.matches()) {
// add duration to current date
dueDate = EnvironmentImpl.getFromCurrent(BusinessCalendar.class).add(
- Clock.getCurrentTime(), durationMatcher.group(1));
+ Clock.getTime(), durationMatcher.group(1));
} else {
throw new JbpmException("invalid due date duration: " + dueDateDescription);
}
@@ -168,7 +168,7 @@
// then the repeat action duedate could already have passed
do {
setDueDateDescription(repeat);
- } while (duedate.getTime() <= Clock.getCurrentTime().getTime());
+ } while (duedate.getTime() <= Clock.getTime().getTime());
if (log.isDebugEnabled()) log.debug("rescheduled "+this+" for "+formatDueDate(duedate));
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -308,7 +308,7 @@
if (timer.getDuedate() == null && timerDefinition.getCronExpression() != null) {
try {
timer.setDuedate(new CronExpression(timerDefinition.getCronExpression())
- .getNextValidTimeAfter(Clock.getCurrentTime()));
+ .getNextValidTimeAfter(Clock.getTime()));
} catch (ParseException pe) {
throw new JbpmException("Can't parse cron expression " + timerDefinition.getCronExpression(), pe);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -55,7 +55,7 @@
try {
execution.setPropagation(Propagation.UNSPECIFIED);
- execution.setHistoryActivityStart(Clock.getCurrentTime());
+ execution.setHistoryActivityStart(Clock.getTime());
activityBehaviour.execute(execution);
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -0,0 +1,42 @@
+/*
+ * 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.pvm.internal.test;
+
+import java.util.Date;
+
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.test.JbpmTestExtensions;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JbpmTestExtensionsImpl extends JbpmTestExtensions {
+
+ public Date getExplicitTime() {
+ return Clock.getExplicitTime();
+ }
+
+ public void setExplicitTime(Date explicitTime) {
+ Clock.setExplicitTime(explicitTime);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -4,16 +4,20 @@
public abstract class Clock {
- protected static Date currentTime = null;
+ protected static Date explicitTime = null;
- public static Date getCurrentTime() {
- if (currentTime==null) {
+ public static Date getTime() {
+ if (explicitTime==null) {
return new Date();
}
- return currentTime;
+ return explicitTime;
}
- public static void setCurrentTime(Date currentTime) {
- Clock.currentTime = currentTime;
+ public static void setExplicitTime(Date explicitTime) {
+ Clock.explicitTime = explicitTime;
}
+
+ public static Date getExplicitTime() {
+ return explicitTime;
+ }
}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -24,6 +24,7 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Jdk14LogFactory;
import org.jbpm.internal.log.Log;
import org.jbpm.internal.log.LogFormatter;
@@ -54,6 +55,7 @@
Jdk14LogFactory.initializeJdk14Logging();
}
+ static protected JbpmTestExtensions jbpmTestExtensions = JbpmTestExtensions.getJbpmTestExtensions();
static protected Log log = Log.getLog(BaseJbpmTestCase.class.getName());
Throwable exception;
@@ -65,6 +67,11 @@
protected void tearDown() throws Exception {
log.debug("=== ending "+getName()+" =============================\n");
+
+ if (jbpmTestExtensions.getExplicitTime()!=null) {
+ jbpmTestExtensions.setExplicitTime(null);
+ throw new JbpmException("This test forgot to unset the explicit time of the clock. use JbpmTestExtensions.getJbpmTestExtensions().setExplicitTime(null);");
+ }
}
public void assertTextPresent(String expected, String value) {
Added: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java (rev 0)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+import java.util.Date;
+
+import org.jbpm.api.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JbpmTestExtensions {
+
+ protected static JbpmTestExtensions instance = instantiateJbpmTestExtentions();
+
+ protected static JbpmTestExtensions instantiateJbpmTestExtentions() {
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ JbpmTestExtensions newInstance;
+ try {
+ Class<?> implClass = Class.forName("org.jbpm.pvm.internal.test.JbpmTestExtensionsImpl", true, contextClassLoader);
+ newInstance = (JbpmTestExtensions) implClass.newInstance();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't load jbpm test extensions", e);
+ }
+ return newInstance;
+ }
+
+ public static JbpmTestExtensions getJbpmTestExtensions() {
+ return instance;
+ }
+
+ public abstract void setExplicitTime(Date explicitTime);
+ public abstract Date getExplicitTime();
+}
Property changes on: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -39,7 +39,7 @@
@Override
protected void tearDown() throws Exception {
super.tearDown();
- Clock.setCurrentTime(null);
+ Clock.setExplicitTime(null);
}
public void testCustomBusinessCalendarCfg() {
@@ -62,7 +62,7 @@
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.set(2009, Calendar.JANUARY, 30, 11, 0, 0);
Date clockDate = gregorianCalendar.getTime();
- Clock.setCurrentTime(clockDate);
+ Clock.setExplicitTime(clockDate);
try {
ProcessInstance processInstance = executionService.startProcessInstanceByKey("CustomBusinessCalendarCfg");
@@ -83,7 +83,7 @@
assertEquals(0, gregorianCalendar.get(Calendar.SECOND));
} finally {
- Clock.setCurrentTime(null);
+ Clock.setExplicitTime(null);
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -126,10 +126,9 @@
"</definitions>";
- @Override
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testInvalidProcess() {
@@ -154,7 +153,7 @@
deployBpmn2XmlString(TIMER_CATCH_WITH_TIMECYCLE);
long processStartTime = 5000;
- Clock.setCurrentTime(new Date(processStartTime));
+ Clock.setExplicitTime(new Date(processStartTime));
ProcessInstance pi = executionService.startProcessInstanceByKey("timeCycleProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
@@ -183,7 +182,7 @@
public void testCronExpression() {
deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION);
- Clock.setCurrentTime(getDate(20, Calendar.JANUARY, 2010, 0, 1, 1)); // Start on 61 seconds
+ Clock.setExplicitTime(getDate(20, Calendar.JANUARY, 2010, 0, 1, 1)); // Start on 61 seconds
ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
@@ -197,7 +196,7 @@
public void testCronExpression2() {
deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION_2);
- Clock.setCurrentTime(getDateAtMidnight(21, Calendar.JANUARY, 2010)); // 21/01/2009 is a Thursday
+ Clock.setExplicitTime(getDateAtMidnight(21, Calendar.JANUARY, 2010)); // 21/01/2009 is a Thursday
ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -21,11 +21,13 @@
*/
package org.jbpm.test.history;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.Map;
import org.jbpm.api.Execution;
import org.jbpm.api.ProcessDefinition;
-import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.test.JbpmTestCase;
@@ -63,22 +65,35 @@
Long avgDurationOne = avgDurations.get("one");
assertNotNull(avgDurationOne);
- assertTrue("expected avg duration bigger then 40, but was"+avgDurationOne, avgDurationOne>40);
+ assertTrue("expected avg duration bigger then 40, but was "+avgDurationOne, avgDurationOne>40);
Long avgDurationTwo = avgDurations.get("two");
assertNotNull(avgDurationTwo);
- assertTrue("expected avg duration bigger then 10, but was"+avgDurationTwo, avgDurationTwo>10);
+ assertTrue("expected avg duration bigger then 10, but was "+avgDurationTwo, avgDurationTwo>10);
Long avgDurationThree = avgDurations.get("three");
assertNotNull(avgDurationThree);
- assertTrue("expected avg duration bigger then 0, but was"+avgDurationThree, avgDurationThree>=0);
+ assertTrue("expected avg duration bigger then 0, but was "+avgDurationThree, avgDurationThree>=0);
assertEquals(3, avgDurations.size());
}
+ static DateFormat dateFormat = new SimpleDateFormat("ss,SSS");
protected void executeProcess() throws InterruptedException {
Execution execution = executionService.startProcessInstanceByKey("ICL");
- Thread.sleep(50);
+ log.info("waiting 50 millis at "+dateFormat.format(new Date()));
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ log.info("done waiting 50 millis at "+dateFormat.format(new Date()));
executionService.signalExecutionById(execution.getId());
- Thread.sleep(20);
+ log.info("waiting 20 millis at "+dateFormat.format(new Date()));
+ try {
+ Thread.sleep(20);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ log.info("done waiting 20 millis at "+dateFormat.format(new Date()));
executionService.signalExecutionById(execution.getId());
executionService.signalExecutionById(execution.getId());
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -43,8 +43,8 @@
public class HistoryActivityInstanceQueryTest extends JbpmTestCase {
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testSimpleQuery() {
@@ -109,12 +109,12 @@
deployTestProcess();
// start 8 processes (18 activity instances) on simulated time 3000000
- Clock.setCurrentTime(new Date(3000000));
+ Clock.setExplicitTime(new Date(3000000));
generateHistoryForTestProcess();
generateHistoryForTestProcess();
// start another 4 processes (9 activity instances) on simulated time 3005000
- Clock.setCurrentTime(new Date(3005000));
+ Clock.setExplicitTime(new Date(3005000));
generateHistoryForTestProcess();
Date timeStamp = new Date(3003000);
@@ -126,11 +126,11 @@
deployTestProcess();
// start 4 processes (9 activity instances) on simulated time 3000000
- Clock.setCurrentTime(new Date(3000000));
+ Clock.setExplicitTime(new Date(3000000));
generateHistoryForTestProcess();
// start another 8 processes (18 activity instances) on simulated time 3000200
- Clock.setCurrentTime(new Date(3002000));
+ Clock.setExplicitTime(new Date(3002000));
generateHistoryForTestProcess();
generateHistoryForTestProcess();
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -44,10 +44,9 @@
*/
public class HistoryTaskQueryTest extends JbpmTestCase {
- @Override
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testOrderByName() {
@@ -139,7 +138,7 @@
" <end name='theEnd' />" +
"</process>";
- Clock.setCurrentTime(new Date(CLOCK_TEST_TIME));
+ Clock.setExplicitTime(new Date(CLOCK_TEST_TIME));
String processXml3 = processXml1.replace("1", "2").replace("Alex", "Tom");
String processXml2 = processXml1.replace("1", "3").replace("Alex", "Joram");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -116,7 +116,7 @@
Calendar now = Calendar.getInstance();
// prevent wrong results in databases lacking millisecond precision
now.set(Calendar.MILLISECOND, 0);
- Clock.setCurrentTime(now.getTime());
+ Clock.setExplicitTime(now.getTime());
String processInstanceId = executionService.startProcessInstanceByKey("Duration").getId();
@@ -130,5 +130,7 @@
// because task.getDuedate() returns java.sql.Timestamp here,
// comparison has to be made in milliseconds
assertEquals(now.getTimeInMillis(), task.getDuedate().getTime());
+
+ Clock.setExplicitTime(null);
}
}
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/pom.xml 2010-01-25 13:47:18 UTC (rev 6127)
@@ -73,8 +73,6 @@
<stax.api.version>1.0.1</stax.api.version>
<wiser.version>1.2</wiser.version>
<woodstox.version>3.2.6</woodstox.version>
- <!-- Database Driver Versions -->
- <hsqldb.version>1.8.0.7</hsqldb.version>
<mysql.connector.version>5.0.8</mysql.connector.version>
<postgresql.version>8.3-603.jdbc3</postgresql.version>
<jtds.version>1.2.2</jtds.version>
More information about the jbpm-commits
mailing list