1 package org.jbpm.bpel.timer.def; 2 3 import org.jbpm.bpel.data.def.Snippet; 4 import org.jbpm.bpel.db.AbstractDbTestCase; 5 import org.jbpm.bpel.def.BpelDefinition; 6 import org.jbpm.bpel.def.Wait; 7 8 public class AlarmDbTest extends AbstractDbTestCase { 9 10 BpelDefinition processDefinition; 11 Alarm alarm; 12 13 public void setUp() { 14 super.setUp(); 15 processDefinition = new BpelDefinition(); 16 Wait wait = new Wait("parent"); 17 alarm = new Alarm(wait); 18 alarm.setAlarmKind(Alarm.AlarmKind.DEADLINE); 19 wait.setAlarm(alarm); 20 processDefinition.addNode(wait); 21 } 22 23 public void testCyclicExpression() { 24 alarm.setAlarmKind(Alarm.AlarmKind.CYCLIC); 25 Snippet cyclicExpr = new Snippet(); 26 cyclicExpr.setUse(Snippet.Use.EXPRESSION); 27 alarm.setRepeatEvery(cyclicExpr); 28 29 processDefinition = saveAndReload(processDefinition); 30 alarm = getAlarm(); 31 32 assertNotNull( alarm.getRepeatEvery() ); 33 assertEquals( Alarm.AlarmKind.CYCLIC, alarm.getAlarmKind()); 34 } 35 36 public void testDeadlineExpression() { 37 alarm.setAlarmKind(Alarm.AlarmKind.DEADLINE); 38 Snippet deadlineExpr = new Snippet(); 39 deadlineExpr.setUse(Snippet.Use.EXPRESSION); 40 alarm.setUntil(deadlineExpr); 41 42 processDefinition = saveAndReload(processDefinition); 43 alarm = getAlarm(); 44 45 assertNotNull( alarm.getUntil() ); 46 assertEquals( Alarm.AlarmKind.DEADLINE, alarm.getAlarmKind()); 47 } 48 49 public void testDurationExpression() { 50 alarm.setAlarmKind(Alarm.AlarmKind.DURATION); 51 Snippet durationExpr = new Snippet(); 52 durationExpr.setUse(Snippet.Use.EXPRESSION); 53 alarm.setFor(durationExpr); 54 55 processDefinition = saveAndReload(processDefinition); 56 alarm = getAlarm(); 57 58 assertNotNull( alarm.getFor() ); 59 assertEquals( Alarm.AlarmKind.DURATION, alarm.getAlarmKind()); 60 } 61 62 public void testListener() { 63 processDefinition = saveAndReload(processDefinition); 64 alarm = getAlarm(); 65 66 assertNotNull( alarm.getAlarmActivity() ); 67 } 68 69 private Alarm getAlarm() { 70 Wait wait = ((Wait) processDefinition.getNode("parent")); 71 return wait.getAlarm(); 72 } 73 } 74 | Popular Tags |