KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossmq > JBossMQMicrocontainerTest


1 /*
2  * JBoss, Home of Professional Open Source.
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * as indicated by the @author tags. See the copyright.txt file in the
5  * distribution for a 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.jbossmq;
23
24 import javax.jms.Connection JavaDoc;
25 import javax.jms.ConnectionFactory JavaDoc;
26
27 import org.jboss.mq.SpyDestination;
28 import org.jboss.mq.SpyQueue;
29 import org.jboss.mq.server.JMSDestinationManager;
30 import org.jboss.mq.server.JMSQueue;
31 import org.jboss.test.AbstractTestDelegate;
32 import org.jboss.test.jbossmq.support.MockServerFailureInterceptor;
33 import org.jboss.test.kernel.junit.MicrocontainerTest;
34
35 /**
36  * JBossMQMicrocontainerTest.
37  *
38  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
39  * @version $Revision: 1.1 $
40  */

41 public class JBossMQMicrocontainerTest extends MicrocontainerTest
42 {
43    /**
44     * Get the test delegate
45     *
46     * @param clazz the test class
47     * @return the delegate
48     * @throws Exception for any error
49     */

50    public static AbstractTestDelegate getDelegate(Class JavaDoc clazz) throws Exception JavaDoc
51    {
52       return new JBossMQMicrocontainerTestDelegate(clazz);
53    }
54    
55    /**
56     * Create a new JBossMQMicrocontainer test
57     *
58     * @param name the test name
59     */

60    public JBossMQMicrocontainerTest(String JavaDoc name)
61    {
62       super(name);
63    }
64    
65    protected ConnectionFactory JavaDoc getConnectionFactory() throws Exception JavaDoc
66    {
67       return (ConnectionFactory JavaDoc) getBean("ConnectionFactory");
68    }
69    
70    protected Connection JavaDoc createConnection() throws Exception JavaDoc
71    {
72       return getConnectionFactory().createConnection();
73    }
74    
75    protected JMSDestinationManager getJMSServer() throws Exception JavaDoc
76    {
77       return (JMSDestinationManager) getBean("JMSServer");
78    }
79    
80    protected SpyQueue createQueue(String JavaDoc name) throws Exception JavaDoc
81    {
82       SpyQueue queue = new SpyQueue(name);
83       JMSDestinationManager server = getJMSServer();
84       JMSQueue realQueue = new JMSQueue(queue, null, server, server.getParameters());
85       server.addDestination(realQueue);
86       return queue;
87    }
88    
89    protected void removeDestination(SpyDestination destination) throws Exception JavaDoc
90    {
91       JMSDestinationManager server = getJMSServer();
92       server.closeDestination(destination);
93    }
94    
95    protected MockServerFailureInterceptor getMockServerFailure() throws Exception JavaDoc
96    {
97       return (MockServerFailureInterceptor) getBean("MockServerFailure");
98    }
99    
100    protected void raiseReceiveError(boolean value) throws Exception JavaDoc
101    {
102       getMockServerFailure().raiseReceiveError = value;
103    }
104 }
105
Popular Tags