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.xml.namespace.QName ; 25 26 import org.apache.servicemix.eip.patterns.StaticRecipientList; 27 import org.apache.servicemix.eip.support.ExchangeTarget; 28 import org.apache.servicemix.tck.ReceiverComponent; 29 30 public class StaticRecipientListTest extends AbstractEIPTest { 31 32 protected StaticRecipientList recipientList; 33 34 protected void setUp() throws Exception { 35 super.setUp(); 36 37 recipientList = new StaticRecipientList(); 38 recipientList.setRecipients( 39 new ExchangeTarget[] { 40 createServiceExchangeTarget(new QName ("recipient1")), 41 createServiceExchangeTarget(new QName ("recipient2")), 42 createServiceExchangeTarget(new QName ("recipient3")) 43 }); 44 configurePattern(recipientList); 45 activateComponent(recipientList, "recipientList"); 46 } 47 48 public void testInOut() throws Exception { 49 InOut me = client.createInOutExchange(); 50 me.setService(new QName ("recipientList")); 51 me.getInMessage().setContent(createSource("<hello/>")); 52 client.sendSync(me); 53 assertEquals(ExchangeStatus.ERROR, me.getStatus()); 54 } 55 56 public void testInOptionalOut() throws Exception { 57 InOptionalOut me = client.createInOptionalOutExchange(); 58 me.setService(new QName ("recipientList")); 59 me.getInMessage().setContent(createSource("<hello/>")); 60 client.sendSync(me); 61 assertEquals(ExchangeStatus.ERROR, me.getStatus()); 62 } 63 64 public void testInOnly() throws Exception { 65 ReceiverComponent r1 = activateReceiver("recipient1"); 66 ReceiverComponent r2 = activateReceiver("recipient2"); 67 ReceiverComponent r3 = activateReceiver("recipient3"); 68 69 InOnly me = client.createInOnlyExchange(); 70 me.setService(new QName ("recipientList")); 71 me.getInMessage().setContent(createSource("<hello/>")); 72 client.sendSync(me); 73 assertEquals(ExchangeStatus.DONE, me.getStatus()); 74 75 r1.getMessageList().assertMessagesReceived(1); 76 r2.getMessageList().assertMessagesReceived(1); 77 r3.getMessageList().assertMessagesReceived(1); 78 } 79 80 public void testRobustInOnly() throws Exception { 81 ReceiverComponent r1 = activateReceiver("recipient1"); 82 ReceiverComponent r2 = activateReceiver("recipient2"); 83 ReceiverComponent r3 = activateReceiver("recipient3"); 84 85 RobustInOnly me = client.createRobustInOnlyExchange(); 86 me.setService(new QName ("recipientList")); 87 me.getInMessage().setContent(createSource("<hello/>")); 88 client.sendSync(me); 89 assertEquals(ExchangeStatus.DONE, me.getStatus()); 90 91 r1.getMessageList().assertMessagesReceived(1); 92 r2.getMessageList().assertMessagesReceived(1); 93 r3.getMessageList().assertMessagesReceived(1); 94 } 95 96 } 97 | Popular Tags |