KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > jms > JMSConnectionTest


1 /*
2  * Copyright (c) 2004 Your Corporation. All Rights Reserved.
3  */

4 package org.jfox.jms;
5
6 import javax.jms.Connection JavaDoc;
7 import javax.jms.Session JavaDoc;
8 import javax.naming.InitialContext JavaDoc;
9
10 import junit.framework.TestCase;
11
12 /**
13  * @author <a HREF="mailto:yy.young@gmail.com">Young Yang</a>
14  */

15
16 public class JMSConnectionTest extends TestCase{
17     JMSConnectionFactory jmsConnectionFactory;
18     Connection JavaDoc conn;
19
20     public void setUp() throws Exception JavaDoc {
21         super.setUp();
22         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
23         Object JavaDoc 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 JavaDoc {
30         super.tearDown();
31     }
32
33
34     public void testCreateSession() {
35         try {
36             Session JavaDoc session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
37             System.out.println(session);
38         }
39         catch(Exception JavaDoc e){
40             e.printStackTrace();
41             fail(e.getMessage());
42         }
43
44     }
45 }
46
47
Popular Tags