1 18 package org.apache.activemq.pool; 19 20 import junit.framework.TestCase; 21 import org.apache.activemq.ActiveMQConnectionFactory; 22 import org.apache.activemq.command.ActiveMQTopic; 23 24 import javax.jms.Session ; 25 import javax.jms.TopicConnection ; 26 import javax.jms.TopicPublisher ; 27 import javax.jms.TopicSession ; 28 29 32 public class PooledTopicPublisherTest extends TestCase { 33 private TopicConnection connection; 34 35 public void testPooledConnectionFactory() throws Exception { 36 ActiveMQTopic topic = new ActiveMQTopic("test"); 37 PooledConnectionFactory pcf = new PooledConnectionFactory(); 38 pcf.setConnectionFactory(new ActiveMQConnectionFactory("vm://test")); 39 40 connection = (TopicConnection ) pcf.createConnection(); 41 TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); 42 TopicPublisher publisher = session.createPublisher(topic); 43 publisher.publish(session.createMessage()); 44 } 45 46 @Override 47 protected void tearDown() throws Exception { 48 if (connection != null) { 49 connection.close(); 50 connection = null; 51 } 52 } 53 } 54 | Popular Tags |