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.InOut; 22 import javax.xml.namespace.QName ; 23 24 import org.apache.servicemix.eip.patterns.WireTap; 25 import org.apache.servicemix.tck.ReceiverComponent; 26 27 public class WireTapTxTest extends AbstractEIPTransactionalTest { 28 29 protected ReceiverComponent inReceiver; 30 protected ReceiverComponent outReceiver; 31 protected ReceiverComponent faultReceiver; 32 protected WireTap wireTap; 33 34 protected void setUp() throws Exception { 35 super.setUp(); 36 37 inReceiver = activateReceiver("in"); 38 outReceiver = activateReceiver("out"); 39 faultReceiver = activateReceiver("fault"); 40 wireTap = new WireTap(); 41 wireTap.setInListener(createServiceExchangeTarget(new QName ("in"))); 42 wireTap.setOutListener(createServiceExchangeTarget(new QName ("out"))); 43 wireTap.setFaultListener(createServiceExchangeTarget(new QName ("fault"))); 44 wireTap.setTarget(createServiceExchangeTarget(new QName ("target"))); 45 configurePattern(wireTap); 46 activateComponent(wireTap, "wireTap"); 47 } 48 49 public void testInOnlySync() throws Exception { 50 ReceiverComponent target = activateReceiver("target"); 51 52 tm.begin(); 53 54 InOnly me = client.createInOnlyExchange(); 55 me.setService(new QName ("wireTap")); 56 me.getInMessage().setContent(createSource("<hello/>")); 57 client.sendSync(me); 58 assertEquals(ExchangeStatus.DONE, me.getStatus()); 59 60 tm.commit(); 61 62 target.getMessageList().assertMessagesReceived(1); 63 inReceiver.getMessageList().assertMessagesReceived(1); 64 outReceiver.getMessageList().assertMessagesReceived(0); 65 faultReceiver.getMessageList().assertMessagesReceived(0); 66 } 67 68 public void testInOnlyAsync() throws Exception { 69 ReceiverComponent target = activateReceiver("target"); 70 71 tm.begin(); 72 73 InOnly me = client.createInOnlyExchange(); 74 me.setService(new QName ("wireTap")); 75 me.getInMessage().setContent(createSource("<hello/>")); 76 client.send(me); 77 78 tm.commit(); 79 80 me = (InOnly) client.receive(); 81 assertEquals(ExchangeStatus.DONE, me.getStatus()); 82 83 target.getMessageList().assertMessagesReceived(1); 84 inReceiver.getMessageList().assertMessagesReceived(1); 85 outReceiver.getMessageList().assertMessagesReceived(0); 86 faultReceiver.getMessageList().assertMessagesReceived(0); 87 } 88 89 public void testInOutSync() throws Exception { 90 activateComponent(new ReturnOutComponent(), "target"); 91 92 tm.begin(); 93 94 InOut me = client.createInOutExchange(); 95 me.setService(new QName ("wireTap")); 96 me.getInMessage().setContent(createSource("<hello/>")); 97 client.sendSync(me); 98 assertEquals(ExchangeStatus.ACTIVE, me.getStatus()); 99 client.done(me); 100 101 tm.commit(); 102 } 103 104 public void testInOutAsync() throws Exception { 105 activateComponent(new ReturnOutComponent(), "target"); 106 107 tm.begin(); 108 109 InOut me = client.createInOutExchange(); 110 me.setService(new QName ("wireTap")); 111 me.getInMessage().setContent(createSource("<hello/>")); 112 client.send(me); 113 114 tm.commit(); 115 116 me = (InOut) client.receive(); 117 client.done(me); 118 } 119 120 } 121 | Popular Tags |