1 16 package org.springframework.jms.core.support; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 import javax.jms.ConnectionFactory ; 22 23 import junit.framework.TestCase; 24 import org.easymock.MockControl; 25 26 import org.springframework.jms.core.JmsTemplate; 27 28 32 public class JmsGatewaySupportTests extends TestCase { 33 34 public void testJmsGatewaySupportWithConnectionFactory() throws Exception { 35 MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory .class); 36 ConnectionFactory mockConnectionFactory = (ConnectionFactory ) connectionFactoryControl.getMock(); 37 connectionFactoryControl.replay(); 38 final List test = new ArrayList (); 39 JmsGatewaySupport gateway = new JmsGatewaySupport() { 40 protected void initGateway() { 41 test.add("test"); 42 } 43 }; 44 gateway.setConnectionFactory(mockConnectionFactory); 45 gateway.afterPropertiesSet(); 46 assertEquals("Correct ConnectionFactory", mockConnectionFactory, gateway.getConnectionFactory()); 47 assertEquals("Correct JmsTemplate", mockConnectionFactory, gateway.getJmsTemplate().getConnectionFactory()); 48 assertEquals("initGatway called", test.size(), 1); 49 connectionFactoryControl.verify(); 50 51 } 52 public void testJmsGatewaySupportWithJmsTemplate() throws Exception { 53 JmsTemplate template = new JmsTemplate(); 54 final List test = new ArrayList (); 55 JmsGatewaySupport gateway = new JmsGatewaySupport() { 56 protected void initGateway() { 57 test.add("test"); 58 } 59 }; 60 gateway.setJmsTemplate(template); 61 gateway.afterPropertiesSet(); 62 assertEquals("Correct JmsTemplate", template, gateway.getJmsTemplate()); 63 assertEquals("initGateway called", test.size(), 1); 64 } 65 66 } 67 | Popular Tags |