1 17 package org.apache.servicemix.components.xslt; 18 19 import org.apache.servicemix.tck.MessageList; 20 import org.apache.servicemix.tck.TestSupport; 21 import org.springframework.context.support.AbstractXmlApplicationContext; 22 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 23 24 import javax.xml.namespace.QName ; 25 import java.util.Date ; 26 27 30 public class XsltSplitTest extends TestSupport { 31 32 public void testUseXsltAsRouter() throws Exception { 33 QName service = new QName ("http://servicemix.org/cheese/", "transformer"); 34 35 sendMessages(service, 20); 36 assertMessagesReceived(20); 37 38 MessageList messageList1 = assertMessagesReceived("service1", 20); 39 MessageList messageList2 = assertMessagesReceived("service2", 20); 40 MessageList messageList3 = assertMessagesReceived("service3", 40); 41 42 assertMessageXPath(messageList1, 0, "/cheese", "Edam"); 43 assertMessageXPath(messageList1, 1, "/cheese", "Edam"); 44 assertMessageXPath(messageList1, 19, "/cheese", "Edam"); 45 assertMessageXPath(messageList1, 0, "/cheese/@id", "1"); 46 assertMessageXPath(messageList1, 1, "/cheese/@id", "2"); 47 48 assertMessageXPath(messageList2, 0, "/beer", "Stella"); 49 assertMessageXPath(messageList2, 19, "/beer", "Stella"); 50 51 assertMessageXPath(messageList3, 0, "/lineitem", "Beer"); 52 assertMessageXPath(messageList3, 1, "/lineitem", "Food"); 53 assertMessageXPath(messageList3, 38, "/lineitem", "Beer"); 54 assertMessageXPath(messageList3, 39, "/lineitem", "Food"); 55 } 56 57 protected String createMessageXmlText(int index) { 58 return "<foo id='" + index + "' sent='" + new Date () + "'>" 59 + "<cheese>Edam</cheese><beer>Stella</beer><lineitem>Beer</lineitem><lineitem>Food</lineitem></foo>"; 60 } 61 62 protected AbstractXmlApplicationContext createBeanFactory() { 63 return new ClassPathXmlApplicationContext("org/apache/servicemix/components/xslt/split.xml"); 64 } 65 } 66 | Popular Tags |