1 17 package org.apache.servicemix.eip; 18 19 import javax.jbi.messaging.ExchangeStatus; 20 import javax.jbi.messaging.InOnly; 21 import javax.jbi.messaging.InOptionalOut; 22 import javax.jbi.messaging.InOut; 23 import javax.jbi.messaging.RobustInOnly; 24 import javax.transaction.Status ; 25 import javax.xml.namespace.QName ; 26 27 import org.apache.servicemix.eip.patterns.StaticRoutingSlip; 28 import org.apache.servicemix.eip.support.ExchangeTarget; 29 30 31 public class StaticRoutingSlipTxTest extends AbstractEIPTransactionalTest { 32 33 protected StaticRoutingSlip routingSlip; 34 35 protected void setUp() throws Exception { 36 super.setUp(); 37 38 routingSlip = new StaticRoutingSlip(); 39 routingSlip.setTargets( 40 new ExchangeTarget[] { 41 createServiceExchangeTarget(new QName ("target1")), 42 createServiceExchangeTarget(new QName ("target2")), 43 createServiceExchangeTarget(new QName ("target3")) 44 }); 45 configurePattern(routingSlip); 46 activateComponent(routingSlip, "routingSlip"); 47 } 48 49 public void testSync() throws Exception { 50 activateComponent(new ReturnOutComponent(), "target1"); 51 activateComponent(new ReturnOutComponent(), "target2"); 52 activateComponent(new ReturnOutComponent(), "target3"); 53 54 tm.begin(); 55 56 InOut me = client.createInOutExchange(); 57 me.setService(new QName ("routingSlip")); 58 me.getInMessage().setContent(createSource("<hello/>")); 59 client.sendSync(me); 60 assertEquals(ExchangeStatus.ACTIVE, me.getStatus()); 61 assertNotNull(me.getOutMessage()); 62 client.done(me); 63 64 tm.commit(); 65 66 listener.assertExchangeCompleted(); 67 } 68 69 public void testAsync() throws Exception { 70 activateComponent(new ReturnOutComponent(), "target1"); 71 activateComponent(new ReturnOutComponent(), "target2"); 72 activateComponent(new ReturnOutComponent(), "target3"); 73 74 tm.begin(); 75 76 InOut me = client.createInOutExchange(); 77 me.setService(new QName ("routingSlip")); 78 me.getInMessage().setContent(createSource("<hello/>")); 79 client.send(me); 80 81 tm.commit(); 82 83 me = (InOut) client.receive(); 84 assertEquals(ExchangeStatus.ACTIVE, me.getStatus()); 85 assertEquals(Status.STATUS_ACTIVE, tm.getStatus()); 86 assertNotNull(me.getOutMessage()); 87 client.done(me); 88 89 listener.assertExchangeCompleted(); 90 } 91 92 } 93 | Popular Tags |