01: package com.mockrunner.mock.jms;
02:
03: import java.util.List;
04:
05: import javax.jms.ConnectionConsumer;
06: import javax.jms.JMSException;
07: import javax.jms.Queue;
08: import javax.jms.QueueConnection;
09: import javax.jms.QueueSession;
10: import javax.jms.ServerSessionPool;
11: import javax.jms.Session;
12:
13: import com.mockrunner.jms.ConfigurationManager;
14: import com.mockrunner.jms.DestinationManager;
15:
16: /**
17: * Mock implementation of JMS <code>QueueConnection</code>.
18: * Please note: The interfaces <code>ConnectionConsumer</code>,
19: * <code>ServerSessionPool</code> and <code>ServerSession</code>
20: * are not meant for application use. Mockrunner provides very
21: * simple mock implementations but usually you won't need them.
22: */
23: public class MockQueueConnection extends MockConnection implements
24: QueueConnection {
25: public MockQueueConnection(DestinationManager destinationManager,
26: ConfigurationManager configurationManager) {
27: super (destinationManager, configurationManager);
28: }
29:
30: /**
31: * Returns the list of {@link MockQueueSession} objects that were created
32: * with {@link #createQueueSession}.
33: * @return the list
34: */
35: public List getQueueSessionList() {
36: return super .getSessionList();
37: }
38:
39: /**
40: * Returns a {@link MockQueueSession} that was created with
41: * {@link #createQueueSession}. If there's no such
42: * {@link MockQueueSession}, <code>null</code> is returned.
43: * @param index the index of the session object
44: * @return the session object
45: */
46: public MockQueueSession getQueueSession(int index) {
47: return (MockQueueSession) super .getSession(index);
48: }
49:
50: public Session createSession(boolean transacted, int acknowledgeMode)
51: throws JMSException {
52: return createQueueSession(transacted, acknowledgeMode);
53: }
54:
55: public QueueSession createQueueSession(boolean transacted,
56: int acknowledgeMode) throws JMSException {
57: throwJMSException();
58: MockQueueSession session = new MockQueueSession(this ,
59: transacted, acknowledgeMode);
60: sessions().add(session);
61: return session;
62: }
63:
64: public ConnectionConsumer createConnectionConsumer(Queue queue,
65: String messageSelector, ServerSessionPool sessionPool,
66: int maxMessages) throws JMSException {
67: return super.createConnectionConsumer(queue, messageSelector,
68: sessionPool, maxMessages);
69: }
70: }
|