01: package test;
02:
03: import dalma.Fiber;
04: import static dalma.TimeUnit.SECONDS;
05: import dalma.endpoints.timer.TimerEndPoint;
06: import dalma.endpoints.input.LineInputEndPoint;
07: import dalma.test.WorkflowTestProgram;
08: import junit.textui.TestRunner;
09:
10: import java.io.Serializable;
11:
12: /**
13: * @author Kohsuke Kawaguchi
14: */
15: public class AgainTest extends WorkflowTestProgram {
16: public AgainTest(String name) {
17: super (name);
18: }
19:
20: public static void main(String[] args) {
21: TestRunner.run(AgainTest.class);
22: }
23:
24: protected void setupEndPoints() throws Exception {
25: // no endpoint to set up
26: engine.addEndPoint(new LineInputEndPoint());
27: }
28:
29: public void test() throws Exception {
30: createConversation(AgainConversation.class);
31: engine.waitForCompletion();
32: assert retryCount == 3;
33: }
34:
35: private static int retryCount = 0;
36:
37: public static final class AgainConversation implements Runnable,
38: Serializable {
39: public void run() {
40: retryCount = 0;
41:
42: TimerEndPoint.waitFor(1, SECONDS);
43: //String s = LineInputEndPoint.waitForInput();
44: //System.out.println("Received: "+s);
45: retryCount++;
46:
47: System.out.println("again");
48: Fiber.again(3, SECONDS, 3);
49:
50: System.out.println("done");
51: }
52:
53: private static final long serialVersionUID = 1L;
54: }
55: }
|