1 22 package org.jboss.test.jbossmessaging.ra; 23 24 import javax.jms.MessageConsumer ; 25 import javax.jms.Queue ; 26 import javax.jms.QueueConnection ; 27 28 import javax.jms.QueueConnectionFactory ; 29 import javax.jms.QueueSession ; 30 import javax.jms.Session ; 31 32 import javax.management.ObjectName ; 33 34 import javax.naming.Context ; 35 36 import junit.framework.Test; 37 38 import org.jboss.test.JBossTestSetup; 39 40 49 public class RaQueueUnitTestCase 50 extends RaTest 51 { 52 private final static String QUEUE_FACTORY = "ConnectionFactory"; 53 private final static String QUEUE = "queue/testQueue"; 54 private final static String JNDI = "TxPublisher"; 55 56 62 public RaQueueUnitTestCase(String name) throws Exception 63 { 64 super(name, JNDI); 65 } 66 67 73 protected void init(final Context context) throws Exception 74 { 75 QueueConnectionFactory factory = 76 (QueueConnectionFactory )context.lookup(QUEUE_FACTORY); 77 78 connection = factory.createQueueConnection(); 79 80 session = ((QueueConnection )connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); 81 82 Queue queue = (Queue )context.lookup(QUEUE); 83 84 consumer = ((QueueSession )session).createReceiver(queue); 85 } 86 87 public static Test suite() throws Exception 88 { 89 return new JBossTestSetup(getDeploySetup(RaQueueUnitTestCase.class, "jmsra.jar")) 90 { 91 protected void setUp() throws Exception 92 { 93 super.setUp(); 94 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 95 String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ; 96 deploy (loader.getResource(resourceName).toString()); 97 } 98 99 protected void tearDown() throws Exception 100 { 101 super.tearDown(); 102 103 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 113 String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ; 114 undeploy (loader.getResource(resourceName).toString()); 115 } 116 }; 117 } 118 119 120 } 121 | Popular Tags |