[jboss-svn-commits] JBL Code SVN: r20236 - in labs/jbossrules/trunk/drools-core/src: test/java/org/drools/process and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 30 20:20:45 EDT 2008
Author: mark.proctor at jboss.com
Date: 2008-05-30 20:20:45 -0400 (Fri, 30 May 2008)
New Revision: 20236
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/timer/TimerManager.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/process/TimerTest.java
Log:
JBRULES-1625 Create Scheduler API with JDK implementation
-Corrected logic for TimerTest, which is emulating the JDK Timer.
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/timer/TimerManager.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/timer/TimerManager.java 2008-05-30 18:46:18 UTC (rev 20235)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/timer/TimerManager.java 2008-05-31 00:20:45 UTC (rev 20236)
@@ -85,14 +85,12 @@
public Date getNextFireTime() {
Date date = null;
- if ( delay == 0 ) {
- if ( count == 0 ) {
- date = new Date( System.currentTimeMillis() + this.period );
- }
- } else if ( count == 0 ) {
- date = new Date( System.currentTimeMillis() + this.delay + this.period );
- } else {
- date = new Date( System.currentTimeMillis() + this.period );
+ if ( count == 0 ) {
+ // initial delay before first fire
+ date = new Date( System.currentTimeMillis() + this.delay );
+ } else if ( this.period != 0 ) {
+ // repeated fires for the given period
+ date = new Date( System.currentTimeMillis() + this.period );
}
count++;
return date;
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/process/TimerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/process/TimerTest.java 2008-05-30 18:46:18 UTC (rev 20235)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/process/TimerTest.java 2008-05-31 00:20:45 UTC (rev 20236)
@@ -37,11 +37,11 @@
counter = 0;
timer = new Timer();
- timer.setDelay(1000);
+ timer.setDelay(500);
timerManager.registerTimer(timer, processInstance);
assertEquals(0, counter);
try {
- Thread.sleep(2000);
+ Thread.sleep(1000);
} catch (InterruptedException e) {
// do nothing
}
@@ -50,18 +50,18 @@
counter = 0;
timer = new Timer();
timer.setDelay(500);
- timer.setPeriod(2000);
+ timer.setPeriod(300);
timerManager.registerTimer(timer, processInstance);
assertEquals(0, counter);
try {
- Thread.sleep(2500);
+ Thread.sleep(700);
} catch (InterruptedException e) {
// do nothing
}
assertEquals(1, counter);
try {
- Thread.sleep(2000);
+ Thread.sleep(1000);
} catch (InterruptedException e) {
// do nothing
}
@@ -71,7 +71,7 @@
timerManager.cancelTimer(timer);
int lastCount = counter;
try {
- Thread.sleep(2000);
+ Thread.sleep(1000);
} catch (InterruptedException e) {
// do nothing
}
More information about the jboss-svn-commits
mailing list