1 17 package org.apache.servicemix.beanflow; 18 19 import org.apache.servicemix.beanflow.util.ActivityTestSupport; 20 21 25 public class JoinAllTest 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 JoinAll flow = new JoinAll(child1, child2, child3); 35 flow.startWithTimeout(timer, timeout); 36 37 child1.stop(); 39 assertStarted(flow); 40 41 child2.stop(); 42 assertStarted(flow); 43 44 child3.stop(); 45 assertStopped(flow); 46 } 48 49 public void testJoinAllTerminatesWhenAClientFails() throws Exception { 50 JoinAll flow = new JoinAll(child1, child2, child3); 51 startActivity(flow, timeout); 52 53 child3.fail("Test case error simulation"); 54 assertStarted(flow); 55 56 child2.stop(); 57 assertStarted(flow); 58 59 child1.stop(); 60 assertFailed(flow); 61 } 62 63 public void testJoinAllTerminatesAsSoonAsOneChildFails() throws Exception { 64 JoinAll flow = new JoinAll(child1, child2, child3); 65 flow.setFailFast(true); 66 startActivity(flow, timeout); 67 68 child1.fail("Test case error simulation"); 69 assertFailed(flow); 70 } 71 72 public void testJoinAllFailsIfChildrenDoNotCompleteInTime() throws Exception { 73 JoinAll flow = new JoinAll(child1, child2, child3); 74 startActivity(flow, timeout); 75 76 child1.stop(); 77 assertStarted(flow); 78 79 child2.stop(); 80 assertStarted(flow); 81 82 Thread.sleep(timeout * 2); 84 85 assertFailed(flow); 86 87 child3.stop(); 89 assertFailed(flow); 90 } 91 } 92 | Popular Tags |