KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossmessaging > ra > RaQueueUnitTestCase


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.jbossmessaging.ra;
23
24 import javax.jms.MessageConsumer JavaDoc;
25 import javax.jms.Queue JavaDoc;
26 import javax.jms.QueueConnection JavaDoc;
27
28 import javax.jms.QueueConnectionFactory JavaDoc;
29 import javax.jms.QueueSession JavaDoc;
30 import javax.jms.Session JavaDoc;
31
32 import javax.management.ObjectName JavaDoc;
33
34 import javax.naming.Context JavaDoc;
35
36 import junit.framework.Test;
37
38 import org.jboss.test.JBossTestSetup;
39
40 /**
41  * Test cases for JMS Resource Adapter use a <em>Queue</em> . <p>
42  *
43  * Created: Mon Apr 23 21:35:25 2001
44  *
45  * @author <a HREF="mailto:peter.antman@tim.se">Peter Antman</a>
46  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
47  * @version $Revision: 37406 $
48  */

49 public class RaQueueUnitTestCase
50        extends RaTest
51 {
52    private final static String JavaDoc QUEUE_FACTORY = "ConnectionFactory";
53    private final static String JavaDoc QUEUE = "queue/testQueue";
54    private final static String JavaDoc JNDI = "TxPublisher";
55
56    /**
57     * Constructor for the RaQueueUnitTestCase object
58     *
59     * @param name Description of Parameter
60     * @exception Exception Description of Exception
61     */

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

73    protected void init(final Context JavaDoc context) throws Exception JavaDoc
74    {
75       QueueConnectionFactory JavaDoc factory =
76             (QueueConnectionFactory JavaDoc)context.lookup(QUEUE_FACTORY);
77
78       connection = factory.createQueueConnection();
79
80       session = ((QueueConnection JavaDoc)connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
81
82       Queue JavaDoc queue = (Queue JavaDoc)context.lookup(QUEUE);
83
84       consumer = ((QueueSession JavaDoc)session).createReceiver(queue);
85    }
86
87    public static Test suite() throws Exception JavaDoc
88    {
89       return new JBossTestSetup(getDeploySetup(RaQueueUnitTestCase.class, "jmsra.jar"))
90          {
91             protected void setUp() throws Exception JavaDoc
92             {
93                super.setUp();
94                ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
95            String JavaDoc resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
96                deploy (loader.getResource(resourceName).toString());
97             }
98
99              protected void tearDown() throws Exception JavaDoc
100              {
101                 super.tearDown();
102
103                 // Remove the messages
104
// richard.achmatowicz: removed this seeminly unnecessary task
105
//getServer().invoke
106
//(
107
// new ObjectName("jboss.mq.destination:service=Queue,name=testQueue"),
108
// "removeAllMessages",
109
// new Object[0],
110
// new String[0]
111
//);
112
ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
113             String JavaDoc resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
114                 undeploy (loader.getResource(resourceName).toString());
115              }
116           };
117    }
118
119
120 }
121
Popular Tags