1 17 package org.apache.servicemix.eip; 18 19 import javax.jbi.messaging.ExchangeStatus; 20 import javax.jbi.messaging.InOnly; 21 import javax.xml.namespace.QName ; 22 23 import org.apache.servicemix.eip.patterns.StaticRecipientList; 24 import org.apache.servicemix.eip.support.ExchangeTarget; 25 import org.apache.servicemix.tck.ReceiverComponent; 26 27 public class StaticRecipientListTxTest extends AbstractEIPTransactionalTest { 28 29 protected StaticRecipientList recipientList; 30 31 protected void setUp() throws Exception { 32 super.setUp(); 33 34 recipientList = new StaticRecipientList(); 35 recipientList.setRecipients( 36 new ExchangeTarget[] { 37 createServiceExchangeTarget(new QName ("recipient1")), 38 createServiceExchangeTarget(new QName ("recipient2")), 39 createServiceExchangeTarget(new QName ("recipient3")) 40 }); 41 configurePattern(recipientList); 42 activateComponent(recipientList, "recipientList"); 43 } 44 45 public void testInOnlySync() throws Exception { 46 ReceiverComponent r1 = activateReceiver("recipient1"); 47 ReceiverComponent r2 = activateReceiver("recipient2"); 48 ReceiverComponent r3 = activateReceiver("recipient3"); 49 50 tm.begin(); 51 52 InOnly me = client.createInOnlyExchange(); 53 me.setService(new QName ("recipientList")); 54 me.getInMessage().setContent(createSource("<hello/>")); 55 client.sendSync(me); 56 assertEquals(ExchangeStatus.DONE, me.getStatus()); 57 58 tm.commit(); 59 60 r1.getMessageList().assertMessagesReceived(1); 61 r2.getMessageList().assertMessagesReceived(1); 62 r3.getMessageList().assertMessagesReceived(1); 63 } 64 65 public void testInOnlyAsync() throws Exception { 66 ReceiverComponent r1 = activateReceiver("recipient1"); 67 ReceiverComponent r2 = activateReceiver("recipient2"); 68 ReceiverComponent r3 = activateReceiver("recipient3"); 69 70 tm.begin(); 71 72 InOnly me = client.createInOnlyExchange(); 73 me.setService(new QName ("recipientList")); 74 me.getInMessage().setContent(createSource("<hello/>")); 75 client.send(me); 76 77 tm.commit(); 78 79 me = (InOnly) client.receive(); 80 assertEquals(ExchangeStatus.DONE, me.getStatus()); 81 82 r1.getMessageList().assertMessagesReceived(1); 83 r2.getMessageList().assertMessagesReceived(1); 84 r3.getMessageList().assertMessagesReceived(1); 85 } 86 87 } 88 | Popular Tags |