1 4 package org.jfox.jms; 5 6 import javax.jms.Connection ; 7 import javax.jms.Session ; 8 import javax.naming.InitialContext ; 9 10 import junit.framework.TestCase; 11 12 15 16 public class JMSConnectionTest extends TestCase{ 17 JMSConnectionFactory jmsConnectionFactory; 18 Connection conn; 19 20 public void setUp() throws Exception { 21 super.setUp(); 22 InitialContext ctx = new InitialContext (); 23 Object cf = ctx.lookup("jms/defaultcf"); 24 jmsConnectionFactory = (JMSConnectionFactory) javax.rmi.PortableRemoteObject.narrow(cf, JMSConnectionFactory.class); 25 conn = jmsConnectionFactory.createConnection(); 26 conn.start(); 27 } 28 29 public void tearDown() throws Exception { 30 super.tearDown(); 31 } 32 33 34 public void testCreateSession() { 35 try { 36 Session session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE); 37 System.out.println(session); 38 } 39 catch(Exception e){ 40 e.printStackTrace(); 41 fail(e.getMessage()); 42 } 43 44 } 45 } 46 47 | Popular Tags |