1 17 package org.apache.servicemix.components.reflection; 18 19 import junit.framework.TestCase; 20 21 import org.apache.servicemix.components.reflection.ProxyInOnlyBinding; 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 29 public class ReflectionBindingTest extends TestCase { 30 31 private AbstractXmlApplicationContext context; 32 protected int messageCount = 20; 33 private SpringJBIContainer jbi; 34 35 public void testSendMessagesToJmsThenOutofJmsToReceiver() throws Exception { 36 Counter counter = (Counter) ((ProxyInOnlyBinding)jbi.getBean("proxyCounter")).createProxy(); 37 for (int i = 1; i <= messageCount; i++) { 38 counter.increment(); 39 } 40 Thread.sleep(100); 41 SimpleCounter simpleCounter = (SimpleCounter) getBean("counter"); 42 assertEquals(messageCount, simpleCounter.getValue() ); 43 44 } 45 46 protected void setUp() throws Exception { 47 context = createBeanFactory(); 48 jbi = (SpringJBIContainer) getBean("jbi"); 49 } 50 51 protected void tearDown() throws Exception { 52 if (context != null) { 53 context.close(); 54 } 55 } 56 57 protected Object getBean(String name) { 58 Object answer = context.getBean(name); 59 assertNotNull("Could not find object in Spring for key: " + name, answer); 60 return answer; 61 } 62 63 protected AbstractXmlApplicationContext createBeanFactory() { 64 return new ClassPathXmlApplicationContext("org/apache/servicemix/components/reflection/example.xml"); 65 } 66 67 68 } 69 | Popular Tags |