[jbpm-commits] JBoss JBPM SVN: r5904 - in jbpm3/branches/jbpm-3.2-soa/modules/core/src: main/resources/org/jbpm/db and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Dec 2 20:18:47 EST 2009
Author: alex.guizar at jboss.com
Date: 2009-12-02 20:18:46 -0500 (Wed, 02 Dec 2009)
New Revision: 5904
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2608/
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2608/JBPM2608Test.java
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
Log:
JBPM-2608: JobSession.findJobsWithOverdueLockTime returns incorrect list of overdue jobs for LockMonitorThread
modify query to return jobs locked *before* the threshold and the calling code to pass a *timestamp*
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-12-02 23:17:00 UTC (rev 5903)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-12-03 01:18:46 UTC (rev 5904)
@@ -257,7 +257,7 @@
public List findJobsWithOverdueLockTime(Date threshold) {
try {
return session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
- .setDate("threshold", threshold)
+ .setTimestamp("threshold", threshold)
.list();
}
catch (HibernateException e) {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-12-02 23:17:00 UTC (rev 5903)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-12-03 01:18:46 UTC (rev 5904)
@@ -385,7 +385,7 @@
<![CDATA[
select job
from org.jbpm.job.Job as job
- where job.lockTime > :threshold
+ where job.lockTime < :threshold
]]>
</query>
Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2608/JBPM2608Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2608/JBPM2608Test.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2608/JBPM2608Test.java 2009-12-03 01:18:46 UTC (rev 5904)
@@ -0,0 +1,93 @@
+/*
+ * 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.jbpm2608;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.job.Job;
+import org.jbpm.job.Timer;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class JBPM2608Test extends AbstractDbTestCase {
+
+ private ProcessDefinition processDefinition;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ processDefinition = new ProcessDefinition(getName());
+ graphSession.saveProcessDefinition(processDefinition);
+ }
+
+ protected void tearDown() throws Exception {
+ graphSession.deleteProcessDefinition(processDefinition);
+ super.tearDown();
+ }
+
+ /**
+ * Test method for
+ * {@link org.jbpm.db.JobSession#findJobsWithOverdueLockTime(java.util.Date)}
+ * .
+ */
+ public void testFindJobsWithOverdueLockTime() {
+ ProcessInstance processInstance = new ProcessInstance(processDefinition);
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.HOUR, -1);
+ // databases such as mysql do not have millisecond precision
+ calendar.set(Calendar.MILLISECOND, 0);
+ Date oneHourAgo = calendar.getTime();
+
+ calendar.add(Calendar.SECOND, -1);
+ Date oneHourAgoMinusOneSec = calendar.getTime();
+
+ calendar.add(Calendar.SECOND, 2);
+ Date oneHourAgoPlusOneSec = calendar.getTime();
+
+ Timer timer = new Timer(processInstance.getRootToken());
+ timer.setLockTime(oneHourAgo);
+ jbpmContext.getServices().getSchedulerService().createTimer(timer);
+
+ newTransaction();
+ timer = jobSession.loadTimer(timer.getId());
+ assertEquals(oneHourAgo, timer.getLockTime());
+
+ List jobs = jobSession.findJobsWithOverdueLockTime(oneHourAgoMinusOneSec);
+ assert jobs.isEmpty() : jobs;
+
+ jobs = jobSession.findJobsWithOverdueLockTime(oneHourAgo);
+ assert jobs.isEmpty() : jobs;
+
+ jobs = jobSession.findJobsWithOverdueLockTime(oneHourAgoPlusOneSec);
+ assertEquals(1, jobs.size());
+
+ Job job = (Job) jobs.get(0);
+ assertSame(job, timer);
+ }
+
+}
More information about the jbpm-commits
mailing list