1 17 package org.apache.servicemix.remoting; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 import org.apache.servicemix.client.ServiceMixClient; 22 import org.apache.servicemix.jbi.container.SpringJBIContainer; 23 import org.springframework.context.support.AbstractXmlApplicationContext; 24 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 25 26 import javax.jbi.messaging.InOut; 27 import javax.jbi.messaging.NormalizedMessage; 28 import javax.xml.transform.stream.StreamSource ; 29 30 import java.io.StringReader ; 31 32 import junit.framework.TestCase; 33 34 37 public class RemoteServiceMixClientTest extends TestCase { 38 private static final transient Log log = LogFactory.getLog(RemoteServiceMixClientTest.class); 39 protected AbstractXmlApplicationContext context; 40 protected ServiceMixClient client; 41 42 public void testRemoteSend() throws Exception { 45 InOut exchange = client.createInOutExchange(); 46 NormalizedMessage message = exchange.getInMessage(); 47 message.setProperty("name", "lufc"); 48 message.setContent(new StreamSource (new StringReader ("<hello>world</hello>"))); 49 assertTrue(client.sendSync(exchange)); 50 System.out.println("OUT = " + exchange.getOutMessage()); 51 } 53 54 protected void setUp() throws Exception { 55 context = createBeanFactory(); 56 client = (ServiceMixClient) getBean("client"); 57 SpringJBIContainer jbi = (SpringJBIContainer) getBean("jbi"); 58 } 59 60 protected Object getBean(String name) { 61 Object answer = context.getBean(name); 62 assertNotNull("Could not find object in Spring for key: " + name, answer); 63 return answer; 64 } 65 66 protected AbstractXmlApplicationContext createBeanFactory() { 67 return new ClassPathXmlApplicationContext("org/apache/servicemix/remoting/example.xml"); 68 } 69 } 70 | Popular Tags |