KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > exe > state > FaultChildrenTest


1 package org.jbpm.bpel.exe.state;
2
3 import javax.xml.namespace.QName JavaDoc;
4
5 import org.jbpm.bpel.def.FaultHandler;
6 import org.jbpm.bpel.exe.Fault;
7
8 /**
9  * @author Juan Cantu
10  * @version $Revision: 1.2 $ $Date: 2005/05/07 00:03:41 $
11  */

12 public class FaultChildrenTest extends AbstractStateTestCase {
13   
14   public ScopeState getState() {
15     return FaultingState.TERMINATING_CHILDREN;
16   }
17   
18   public void testChildrenTerminated() {
19     scope.setFault(new Fault());
20     
21     scope.getState().childrenTerminated(scope);
22    
23     assertEquals(FaultingState.FAULTING_IMPLICITLY, scope.getState());
24   }
25   
26   public void testChildrenTerminatedWithHandler() {
27     QName JavaDoc faultName = new QName JavaDoc("aFault");
28     FaultHandler hdlr = new FaultHandler();
29     hdlr.setFaultName(faultName);
30     hdlr.setActivity(handlerLog);
31     pd.getScope().addFaultHandler(hdlr);
32     Fault fault = new Fault(faultName);
33     scope.setFault(fault);
34     
35     scope.getState().childrenTerminated(scope);
36     
37     assertEquals(FaultingState.FAULTING_EXPLICITLY, scope.getState());
38     assertTrue(this.handlerLog.executed);
39   }
40   
41   public void testChildrenCompensated() {
42     try { ((HandlingState)scope.getState()).childrenCompensated(scope); }
43     catch(IllegalStateException JavaDoc e) { return; }
44     fail("compensate can't be invoked at this state");
45   }
46   
47   public void testTerminate() {
48     ScopeState oldState = scope.getState();
49     scope.terminate();
50     assertEquals(oldState, scope.getState());
51   }
52 }
53
Popular Tags