[jbpm-commits] JBoss JBPM SVN: r6114 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jan 21 07:06:28 EST 2010


Author: jbarrez
Date: 2010-01-21 07:06:28 -0500 (Thu, 21 Jan 2010)
New Revision: 6114

Modified:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
Log:
Fix for Hudson

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-21 11:56:54 UTC (rev 6113)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java	2010-01-21 12:06:28 UTC (rev 6114)
@@ -110,7 +110,22 @@
     "  </process>" +
     "</definitions>";
   
+  private static final String TIMER_CATCH_WITH_CRON_EXPRESSION_2 =
+    "<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
+    "  <process id='timeDateProcess'>" +
+    "    <startEvent id='theStart' />" +
+    "    <sequenceFlow id='flow1' sourceRef='theStart' targetRef='intermediateTimer' />" +
+    "    <intermediateCatchEvent id='intermediateTimer' >" +
+    "      <timerEventDefinition>" +
+    "        <timeCycle>0 0 23 ? * FRI</timeCycle>" + // Every friday at 23:00
+    "      </timerEventDefinition>" +
+    "    </intermediateCatchEvent>" +
+    "    <sequenceFlow id='flow2' sourceRef='intermediateTimer' targetRef='theEnd' />" +
+    "    <endEvent id='theEnd' />" +
+    "  </process>" +
+    "</definitions>";
   
+  
   @Override
   protected void tearDown() throws Exception {
     super.tearDown();
@@ -159,28 +174,42 @@
     CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
     
     Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
-    Date expectedDueDate = getDate(10, Calendar.OCTOBER, 2099);
+    Date expectedDueDate = getDateAtMidnight(10, Calendar.OCTOBER, 2099);
     assertEquals(expectedDueDate.getTime(), timerJob.getDuedate().getTime());
     
     managementService.executeJob(timerJob.getId());
     assertProcessInstanceEnded(pi);
   }
   
-  public void testCronExpression() throws InterruptedException {
+  public void testCronExpression() {
     deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION);
-    Clock.setCurrentTime(new Date(61000)); // Start on 61 seconds
+    Clock.setCurrentTime(getDate(20, Calendar.JANUARY, 2010, 0, 1, 1)); // Start on 61 seconds
     
     ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
     CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
     
     Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
-    assertEquals(120000, timerJob.getDuedate().getTime()); 
+    assertEquals(getDate(20, Calendar.JANUARY, 2010, 0, 2, 0).getTime(), timerJob.getDuedate().getTime()); 
     
     managementService.executeJob(timerJob.getId());
     assertProcessInstanceEnded(pi);
   }
   
-  private Date getDate(int day, int month, int year) {
+  public void testCronExpression2() {
+    deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION_2);
+    Clock.setCurrentTime(getDateAtMidnight(21, Calendar.JANUARY, 2010)); // 21/01/2009 is a Thursday
+    
+    ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
+    CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
+    
+    Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
+    assertEquals(getDate(22, Calendar.JANUARY, 2010, 23, 0, 0).getTime(), timerJob.getDuedate().getTime());
+    
+    managementService.executeJob(timerJob.getId());
+    assertProcessInstanceEnded(pi);
+  }
+  
+  private Date getDateAtMidnight(int day, int month, int year) {
     Calendar cal = Calendar.getInstance();
     cal.set(Calendar.DAY_OF_MONTH, day);
     cal.set(Calendar.MONTH, month);
@@ -191,6 +220,18 @@
     cal.set(Calendar.MILLISECOND, 0);
     return cal.getTime();
   }
+  
+  private Date getDate(int day, int month, int year, int hour, int minute, int second) {
+    Calendar cal = Calendar.getInstance();
+    cal.set(Calendar.DAY_OF_MONTH, day);
+    cal.set(Calendar.MONTH, month);
+    cal.set(Calendar.YEAR, year);
+    cal.set(Calendar.HOUR_OF_DAY, hour);
+    cal.set(Calendar.MINUTE, minute);
+    cal.set(Calendar.SECOND, second);
+    cal.set(Calendar.MILLISECOND, 0);
+    return cal.getTime();
+  }
 
 
 }



More information about the jbpm-commits mailing list