1 17 package org.apache.servicemix.beanflow; 18 19 import org.apache.servicemix.beanflow.util.ActivityTestSupport; 20 21 25 public class JoinQuorumTest extends ActivityTestSupport { 26 27 protected Activity child1 = new TimeoutActivity(); 28 protected Activity child2 = new TimeoutActivity(); 29 protected Activity child3 = new TimeoutActivity(); 30 31 public void testJoinAllWhenEachChildFlowCompletes() throws Exception { 32 JoinQuorum flow = new JoinQuorum(child1, child2, child3); 33 startActivity(flow, timeout); 34 35 child1.stop(); 36 assertStarted(flow); 37 38 child2.stop(); 39 assertStopped(flow); 40 41 child3.stop(); 43 assertStopped(flow); 44 } 45 46 public void testJoinQuorumTerminatesWhenTooManyClientsFail() throws Exception { 47 JoinQuorum flow = new JoinQuorum(child1, child2, child3); 48 startActivity(flow, timeout); 49 50 child3.fail("Test case error simulation"); 51 assertStarted(flow); 52 53 child2.fail("Test case error simulation"); 54 assertFailed(flow); 55 } 56 57 public void testJoinQuorumFailsIfChildrenDoNotCompleteInTime() throws Exception { 58 JoinQuorum flow = new JoinQuorum(child1, child2, child3); 59 startActivity(flow, timeout); 60 61 child1.stop(); 62 assertStarted(flow); 63 64 Thread.sleep(timeout * 2); 66 67 assertFailed(flow); 68 69 child2.stop(); 71 assertFailed(flow); 72 73 child3.stop(); 74 assertFailed(flow); 75 } 76 } 77 | Popular Tags |