Index: src/test/java/org/jbpm/test/timer/TimerTest.java
===================================================================
--- src/test/java/org/jbpm/test/timer/TimerTest.java	(revision 6130)
+++ src/test/java/org/jbpm/test/timer/TimerTest.java	(working copy)
@@ -334,33 +334,114 @@
     } catch (Exception e) {}
   }
 
-  public void testTimerELSubtractBusinessFail() {
-    deployJpdlXmlString(
-      "<process name='Insurance claim' key='ICL'>" +
-      "  <start>" +
-      "    <transition to='a' />" +
-      "  </start>" +
-      "  <state name='a'>" +
-      "    <transition to='b' />" +
-      "    <transition name='timeout' to='escalate'>" +
-      "      <timer duedate='#{proc_var} - 6 business days' />" +
-      "    </transition>" +
-      "  </state>" +
-      "  <state name='b' />" +
-      "  <end name='escalate' />" +
-      "</process>"
-    );
+  public void testTimerELSubtractBusiness() {
+	    deployJpdlXmlString(
+	      "<process name='Insurance claim' key='ICL'>" +
+	      "  <start>" +
+	      "    <transition to='a' />" +
+	      "  </start>" +
+	      "  <state name='a'>" +
+	      "    <transition to='b' />" +
+	      "    <transition name='timeout' to='escalate'>" +
+	      "      <timer duedate='#{proc_var} - 5 business days' />" +
+	      "    </transition>" +
+	      "  </state>" +
+	      "  <state name='b' />" +
+	      "  <end name='escalate' />" +
+	      "</process>"
+	    );
 
-    Map<String, Object> proc_vars = new HashMap<String, Object>();
-    Calendar cal = Calendar.getInstance();
-    cal.set(2010, 01, 12, 12, 00, 00); // 12 feb 2010 noon
-    proc_vars.put("proc_var", cal);
-    try {
-      executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
-      fail("Should not happen, exception expected");
-    } catch (Exception e) {}
-  }
+	    Map<String, Object> proc_vars = new HashMap<String, Object>();
+	    Calendar cal = Calendar.getInstance();
+	    cal.set(2010, 01, 19, 12, 00, 00); // 19 feb 2010 noon
+	    proc_vars.put("proc_var", cal);
+	    ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+		    
+	    Job job = managementService.createJobQuery()
+	      .processInstanceId(processInstance.getId())
+	      .uniqueResult();
+	    
+	    Calendar jobDate = Calendar.getInstance();
+	    jobDate.setTime(job.getDuedate());
+	    
+	    // 19 feb is friday, 5 businessdays before is friday 12th
+	    assertEquals(12 , jobDate.get(Calendar.DAY_OF_MONTH));
+	    	    
+	    managementService.executeJob(job.getId());
+	    assertProcessInstanceEnded(processInstance);
+}
   
+  public void testTimerELSubtractBusinessLeap() {
+	    deployJpdlXmlString(
+	      "<process name='Insurance claim' key='ICL'>" +
+	      "  <start>" +
+	      "    <transition to='a' />" +
+	      "  </start>" +
+	      "  <state name='a'>" +
+	      "    <transition to='b' />" +
+	      "    <transition name='timeout' to='escalate'>" +
+	      "      <timer duedate='#{proc_var} - 5 business days' />" +
+	      "    </transition>" +
+	      "  </state>" +
+	      "  <state name='b' />" +
+	      "  <end name='escalate' />" +
+	      "</process>"
+	    );
+		 
+		Map<String, Object> proc_vars = new HashMap<String, Object>();
+	    Calendar cal = Calendar.getInstance();
+	    cal.set(2012, 2, 5, 12, 00, 00); // 5 march 2012 noon
+	    proc_vars.put("proc_var", cal);
+	    ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+
+	    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).uniqueResult();
+
+	    Calendar jobDate = Calendar.getInstance();
+	    jobDate.setTime(job.getDuedate());
+
+	    // 5 mar is monday, 5 businessdays before is monday feb 27th (29-02-12 is leap day)
+	    assertEquals(27, jobDate.get(Calendar.DAY_OF_MONTH));
+
+	    managementService.executeJob(job.getId());
+	    assertProcessInstanceEnded(processInstance);
+	  }  
+	  
+	  public void testTimerELSubtractBusinessMonthBoundary() {
+	    deployJpdlXmlString(
+	      "<process name='Insurance claim' key='ICL'>" +
+	      "  <start>" +
+	      "    <transition to='a' />" +
+	      "  </start>" +
+	      "  <state name='a'>" +
+	      "    <transition to='b' />" +
+	      "    <transition name='timeout' to='escalate'>" +
+	      "      <timer duedate='#{proc_var} - 10 business days' />" +
+	      "    </transition>" +
+	      "  </state>" +
+	      "  <state name='b' />" +
+	      "  <end name='escalate' />" +
+	      "</process>"
+	    );
+	     
+	    Map<String, Object> proc_vars = new HashMap<String, Object>();
+	    Calendar cal = Calendar.getInstance();
+	    cal.set(2012, 02, 13, 21, 00, 00); // 13 mar 2012 
+	    proc_vars.put("proc_var", cal);
+	    ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+
+	    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).uniqueResult();
+
+	    Calendar jobDate = Calendar.getInstance();
+	    jobDate.setTime(job.getDuedate());
+
+	    // 13 mar is tuesday, 10 businessdays before is tuesday feb 28th (29-02-12 is leap day)
+	    assertEquals(28, jobDate.get(Calendar.DAY_OF_MONTH));
+
+	    managementService.executeJob(job.getId());
+	    assertProcessInstanceEnded(processInstance);
+	  }   
+  
+  
   public void testTimerELSubtractPastFail() {
     deployJpdlXmlString(
       "<process name='Insurance claim' key='ICL'>" +
