1 17 package org.apache.servicemix.jbi.nmr.flow.jms; 18 19 import javax.jbi.messaging.InOut; 20 import javax.jbi.messaging.NormalizedMessage; 21 import javax.xml.namespace.QName ; 22 23 import junit.framework.TestCase; 24 25 import org.apache.servicemix.client.ServiceMixClient; 26 import org.apache.servicemix.jbi.container.SpringJBIContainer; 27 import org.apache.servicemix.jbi.jaxp.SourceTransformer; 28 import org.apache.servicemix.jbi.jaxp.StringSource; 29 import org.springframework.context.support.AbstractXmlApplicationContext; 30 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 31 32 35 public class SimpleClusterSendSyncTest extends TestCase { 36 protected SpringJBIContainer jbi; 37 protected AbstractXmlApplicationContext context; 38 39 42 protected void setUp() throws Exception { 43 context = new ClassPathXmlApplicationContext("org/apache/servicemix/jbi/nmr/flow/jms/broker.xml"); 44 jbi = (SpringJBIContainer) context.getBean("jbi"); 45 assertNotNull("JBI Container not found in spring!", jbi); 46 47 } 48 49 protected void tearDown() throws Exception { 50 context.close(); 51 } 52 53 public void testSendSync() throws Exception { 54 AbstractXmlApplicationContext ctx = new ClassPathXmlApplicationContext("org/apache/servicemix/jbi/nmr/flow/jms/client.xml"); 55 try { 56 ServiceMixClient client = (ServiceMixClient) ctx.getBean("client"); 57 Thread.sleep(2000); 58 InOut exchange = client.createInOutExchange(); 59 exchange.setService(new QName ("http://www.habuma.com/foo", "pingService")); 60 NormalizedMessage in = exchange.getInMessage(); 61 in.setContent(new StringSource("<ping>Pinging you</ping>")); 62 System.out.println("SENDING; exchange.status=" + exchange.getStatus()); 63 client.sendSync(exchange); 64 assertNotNull(exchange.getOutMessage()); 65 System.out.println("GOT RESPONSE; exchange.out=" + new SourceTransformer().toString(exchange.getOutMessage().getContent())); 66 client.done(exchange); 67 Thread.sleep(50); 69 } finally { 70 ctx.close(); 71 } 72 } 73 } 74 | Popular Tags |