1 22 package org.jboss.test.jmsra.test; 23 import javax.jms.MessageConsumer ; 24 import javax.jms.Session ; 25 import javax.jms.Topic ; 26 import javax.jms.TopicConnection ; 27 28 import javax.jms.TopicConnectionFactory ; 29 import javax.jms.TopicSession ; 30 31 import javax.management.ObjectName ; 32 33 import javax.naming.Context ; 34 35 import junit.framework.Test; 36 37 import org.jboss.test.JBossTestSetup; 38 39 48 public class RaTopicUnitTestCase 49 extends RaTest 50 { 51 private final static String TOPIC_FACTORY = "ConnectionFactory"; 52 private final static String TOPIC = "topic/testTopic"; 53 private final static String JNDI = "TxTopicPublisher"; 54 55 61 public RaTopicUnitTestCase(String name) throws Exception 62 { 63 super(name, JNDI); 64 } 65 66 72 protected void init(final Context context) throws Exception 73 { 74 TopicConnectionFactory factory = 75 (TopicConnectionFactory )context.lookup(TOPIC_FACTORY); 76 77 connection = factory.createTopicConnection(); 78 79 session = ((TopicConnection )connection).createTopicSession(false, Session.AUTO_ACKNOWLEDGE); 80 81 Topic topic = (Topic )context.lookup(TOPIC); 82 83 consumer = ((TopicSession )session).createSubscriber(topic); 84 } 85 86 public static Test suite() throws Exception 87 { 88 return new JBossTestSetup(getDeploySetup(RaQueueUnitTestCase.class, "jmsra.jar")) 89 { 90 protected void setUp() throws Exception 91 { 92 super.setUp(); 93 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 94 deploy (loader.getResource("messaging/test-destinations-service.xml").toString()); 95 } 96 97 protected void tearDown() throws Exception 98 { 99 super.tearDown(); 100 101 getServer().invoke 103 ( 104 new ObjectName ("jboss.mq.destination:service=Queue,name=testQueue"), 105 "removeAllMessages", 106 new Object [0], 107 new String [0] 108 ); 109 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 110 undeploy (loader.getResource("messaging/test-destinations-service.xml").toString()); 111 } 112 }; 113 } 114 115 116 } 117 | Popular Tags |