01: package com.mockrunner.mock.jms;
02:
03: import javax.jms.Connection;
04: import javax.jms.JMSException;
05:
06: import com.mockrunner.jms.ConfigurationManager;
07: import com.mockrunner.jms.DestinationManager;
08:
09: /**
10: * Mock implementation of JMS <code>QueueConnectionFactory</code>.
11: */
12: public class MockQueueConnectionFactory extends MockConnectionFactory {
13: public MockQueueConnectionFactory(
14: DestinationManager destinationManager,
15: ConfigurationManager configurationManager) {
16: super (destinationManager, configurationManager);
17: }
18:
19: public Connection createConnection() throws JMSException {
20: return createQueueConnection();
21: }
22:
23: public Connection createConnection(String name, String password)
24: throws JMSException {
25: return createQueueConnection();
26: }
27:
28: /**
29: * Returns the connection with the specified index
30: * or <code>null</code> if no such connection
31: * exists.
32: * @param index the index
33: * @return the connection
34: */
35: public MockQueueConnection getQueueConnection(int index) {
36: if (connections().size() <= index)
37: return null;
38: return (MockQueueConnection) connections().get(index);
39: }
40:
41: /**
42: * Returns the latest created connection
43: * or <code>null</code> if no such connection
44: * exists.
45: * @return the connection
46: */
47: public MockQueueConnection getLatestQueueConnection() {
48: if (connections().size() == 0)
49: return null;
50: return (MockQueueConnection) connections().get(
51: connections().size() - 1);
52: }
53: }
|