KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jms > client > BasicTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.jms.client;
8
9 import java.util.Enumeration JavaDoc;
10
11 import javax.jms.Connection JavaDoc;
12 import javax.jms.ConnectionFactory JavaDoc;
13 import javax.jms.Message JavaDoc;
14 import javax.jms.MessageProducer JavaDoc;
15 import javax.jms.Queue JavaDoc;
16 import javax.jms.QueueBrowser JavaDoc;
17 import javax.jms.Session JavaDoc;
18
19 import org.jboss.jms.client.ImplementationDelegate;
20 import org.jboss.jms.client.JBossConnectionFactory;
21 import org.jboss.jms.client.jvm.JVMImplementation;
22 import org.jboss.jms.destination.JBossQueue;
23 import org.jboss.jms.server.MessageBroker;
24 import org.jboss.jms.server.standard.StandardMessageBroker;
25 import org.jboss.test.jms.BaseJMSTest;
26
27 /**
28  * A basic test
29  *
30  * @author <a HREF="adrian@jboss.org>Adrian Brock</a>
31  * @version $Revision: 1.4 $
32  */

33 public class BasicTestCase extends BaseJMSTest
34 {
35    // Constants -----------------------------------------------------
36

37    // Attributes ----------------------------------------------------
38

39    // Static --------------------------------------------------------
40

41    // Constructors --------------------------------------------------
42

43    public BasicTestCase(String JavaDoc name)
44    {
45       super(name);
46    }
47
48    // Public --------------------------------------------------------
49

50    public void testSomething()
51       throws Exception JavaDoc
52    {
53       Queue JavaDoc queue = new JBossQueue("queue");
54       MessageBroker broker = new StandardMessageBroker();
55       ImplementationDelegate impl = new JVMImplementation(broker);
56       ConnectionFactory JavaDoc cf = new JBossConnectionFactory(impl);
57       Connection JavaDoc c = cf.createConnection();
58       try
59       {
60          Session JavaDoc s = c.createSession(true, 0);
61          MessageProducer JavaDoc p = s.createProducer(queue);
62          Message JavaDoc m = s.createMessage();
63          p.send(m);
64          p.send(m);
65          QueueBrowser JavaDoc b = s.createBrowser(queue);
66          Enumeration JavaDoc e = b.getEnumeration();
67          while (e.hasMoreElements())
68             System.out.println(e.nextElement());
69       }
70       finally
71       {
72          c.close();
73       }
74    }
75
76    // Protected ------------------------------------------------------
77

78    // Package Private ------------------------------------------------
79

80    // Private --------------------------------------------------------
81

82    // Inner Classes --------------------------------------------------
83
}
84
Popular Tags