01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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;
25: import javax.jms.ConnectionFactory;
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: * Get the test delegate
44: *
45: * @param clazz the test class
46: * @return the delegate
47: * @throws Exception for any error
48: */
49: public static AbstractTestDelegate getDelegate(Class clazz)
50: throws Exception {
51: return new JBossMQMicrocontainerTestDelegate(clazz);
52: }
53:
54: /**
55: * Create a new JBossMQMicrocontainer test
56: *
57: * @param name the test name
58: */
59: public JBossMQMicrocontainerTest(String name) {
60: super (name);
61: }
62:
63: protected ConnectionFactory getConnectionFactory() throws Exception {
64: return (ConnectionFactory) getBean("ConnectionFactory");
65: }
66:
67: protected Connection createConnection() throws Exception {
68: return getConnectionFactory().createConnection();
69: }
70:
71: protected JMSDestinationManager getJMSServer() throws Exception {
72: return (JMSDestinationManager) getBean("JMSServer");
73: }
74:
75: protected SpyQueue createQueue(String name) throws Exception {
76: SpyQueue queue = new SpyQueue(name);
77: JMSDestinationManager server = getJMSServer();
78: JMSQueue realQueue = new JMSQueue(queue, null, server, server
79: .getParameters());
80: server.addDestination(realQueue);
81: return queue;
82: }
83:
84: protected void removeDestination(SpyDestination destination)
85: throws Exception {
86: JMSDestinationManager server = getJMSServer();
87: server.closeDestination(destination);
88: }
89:
90: protected MockServerFailureInterceptor getMockServerFailure()
91: throws Exception {
92: return (MockServerFailureInterceptor) getBean("MockServerFailure");
93: }
94:
95: protected void raiseReceiveError(boolean value) throws Exception {
96: getMockServerFailure().raiseReceiveError = value;
97: }
98: }
|