KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jmsra > test > RaTopicUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jmsra.test;
23 import javax.jms.MessageConsumer JavaDoc;
24 import javax.jms.Session JavaDoc;
25 import javax.jms.Topic JavaDoc;
26 import javax.jms.TopicConnection JavaDoc;
27
28 import javax.jms.TopicConnectionFactory JavaDoc;
29 import javax.jms.TopicSession JavaDoc;
30
31 import javax.management.ObjectName JavaDoc;
32
33 import javax.naming.Context JavaDoc;
34
35 import junit.framework.Test;
36
37 import org.jboss.test.JBossTestSetup;
38
39 /**
40  * Test cases for JMS Resource Adapter using a <em>Topic</em> . <p>
41  *
42  * Created: Mon Apr 23 21:35:25 2001
43  *
44  * @author <a HREF="mailto:peter.antman@tim.se">Peter Antman</a>
45  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
46  * @version $Revision: 37406 $
47  */

48 public class RaTopicUnitTestCase
49        extends RaTest
50 {
51    private final static String JavaDoc TOPIC_FACTORY = "ConnectionFactory";
52    private final static String JavaDoc TOPIC = "topic/testTopic";
53    private final static String JavaDoc JNDI = "TxTopicPublisher";
54
55    /**
56     * Constructor for the RaTopicUnitTestCase object
57     *
58     * @param name Description of Parameter
59     * @exception Exception Description of Exception
60     */

61    public RaTopicUnitTestCase(String JavaDoc name) throws Exception JavaDoc
62    {
63       super(name, JNDI);
64    }
65
66    /**
67     * #Description of the Method
68     *
69     * @param context Description of Parameter
70     * @exception Exception Description of Exception
71     */

72    protected void init(final Context JavaDoc context) throws Exception JavaDoc
73    {
74       TopicConnectionFactory JavaDoc factory =
75             (TopicConnectionFactory JavaDoc)context.lookup(TOPIC_FACTORY);
76
77       connection = factory.createTopicConnection();
78
79       session = ((TopicConnection JavaDoc)connection).createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
80
81       Topic JavaDoc topic = (Topic JavaDoc)context.lookup(TOPIC);
82
83       consumer = ((TopicSession JavaDoc)session).createSubscriber(topic);
84    }
85
86    public static Test suite() throws Exception JavaDoc
87    {
88       return new JBossTestSetup(getDeploySetup(RaQueueUnitTestCase.class, "jmsra.jar"))
89          {
90             protected void setUp() throws Exception JavaDoc
91             {
92                super.setUp();
93                ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
94                deploy (loader.getResource("messaging/test-destinations-service.xml").toString());
95             }
96
97              protected void tearDown() throws Exception JavaDoc
98              {
99                 super.tearDown();
100
101                 // Remove the messages
102
getServer().invoke
103                 (
104                    new ObjectName JavaDoc("jboss.mq.destination:service=Queue,name=testQueue"),
105                    "removeAllMessages",
106                    new Object JavaDoc[0],
107                    new String JavaDoc[0]
108                 );
109                 ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
110                 undeploy (loader.getResource("messaging/test-destinations-service.xml").toString());
111              }
112           };
113    }
114
115
116 }
117
Popular Tags