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.XPathSplitter; 25 import org.apache.servicemix.tck.ReceiverComponent; 26 27 public class XPathSplitterTest extends AbstractEIPTest { 28 29 private XPathSplitter splitter; 30 31 protected void setUp() throws Exception { 32 super.setUp(); 33 34 splitter = new XPathSplitter(); 35 splitter.setTarget(createServiceExchangeTarget(new QName ("target"))); 36 splitter.setXPath("/hello/*"); 37 configurePattern(splitter); 38 activateComponent(splitter, "splitter"); 39 } 40 41 public void testInOnly() throws Exception { 42 ReceiverComponent rec = activateReceiver("target"); 43 44 InOnly me = client.createInOnlyExchange(); 45 me.setService(new QName ("splitter")); 46 me.getInMessage().setContent(createSource("<hello><one/><two/><three/></hello>")); 47 client.sendSync(me); 48 assertEquals(ExchangeStatus.DONE, me.getStatus()); 49 50 rec.getMessageList().assertMessagesReceived(3); 51 } 52 53 public void testInOut() throws Exception { 54 InOut me = client.createInOutExchange(); 55 me.setService(new QName ("splitter")); 56 me.getInMessage().setContent(createSource("<hello><one/><two/><three/></hello>")); 57 client.sendSync(me); 58 assertEquals(ExchangeStatus.ERROR, me.getStatus()); 59 } 60 61 } 62 | Popular Tags |