001: package com.mockrunner.mock.jms;
002:
003: import com.mockrunner.jms.ConfigurationManager;
004: import com.mockrunner.jms.DestinationManager;
005:
006: /**
007: * Used to create all types of JMS mock objects.
008: * Maintains the necessary dependencies between the mock objects.
009: * If you use the mock objects returned by this
010: * factory in your tests you can be sure that they are all
011: * up to date. If you are using JNDI for obtaining the
012: * connection factories you have to bind them to the mock JNDI context
013: * with {@link com.mockrunner.ejb.EJBTestModule#bindToContext}.
014: */
015: public class JMSMockObjectFactory {
016: private DestinationManager destinationManager;
017: private ConfigurationManager configurationManager;
018: private MockQueueConnectionFactory queueConnectionFactory;
019: private MockTopicConnectionFactory topicConnectionFactory;
020: private MockConnectionFactory connectionFactory;
021:
022: /**
023: * Creates a new set of mock objects.
024: */
025: public JMSMockObjectFactory() {
026: destinationManager = new DestinationManager();
027: configurationManager = new ConfigurationManager();
028: queueConnectionFactory = createMockQueueConnectionFactory();
029: topicConnectionFactory = createMockTopicConnectionFactory();
030: connectionFactory = createMockConnectionFactory();
031: }
032:
033: /**
034: * Creates the {@link com.mockrunner.mock.jms.MockConnectionFactory} using <code>new</code>.
035: * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jms.MockConnectionFactory}.
036: * @return the {@link com.mockrunner.mock.jms.MockConnectionFactory}
037: */
038: public MockConnectionFactory createMockConnectionFactory() {
039: return new MockConnectionFactory(destinationManager,
040: configurationManager);
041: }
042:
043: /**
044: * Creates the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory} using <code>new</code>.
045: * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}.
046: * @return the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}
047: */
048: public MockTopicConnectionFactory createMockTopicConnectionFactory() {
049: return new MockTopicConnectionFactory(destinationManager,
050: configurationManager);
051: }
052:
053: /**
054: * Creates the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory} using <code>new</code>.
055: * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}.
056: * @return the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}
057: */
058: public MockQueueConnectionFactory createMockQueueConnectionFactory() {
059: return new MockQueueConnectionFactory(destinationManager,
060: configurationManager);
061: }
062:
063: /**
064: * Returns the {@link com.mockrunner.jms.ConfigurationManager}.
065: * @return the {@link com.mockrunner.jms.ConfigurationManager}
066: */
067: public ConfigurationManager getConfigurationManager() {
068: return configurationManager;
069: }
070:
071: /**
072: * Returns the {@link com.mockrunner.jms.DestinationManager}.
073: * @return the {@link com.mockrunner.jms.DestinationManager}
074: */
075: public DestinationManager getDestinationManager() {
076: return destinationManager;
077: }
078:
079: /**
080: * Returns the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}.
081: * @return the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}
082: */
083: public MockQueueConnectionFactory getMockQueueConnectionFactory() {
084: return queueConnectionFactory;
085: }
086:
087: /**
088: * Returns the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}.
089: * @return the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}
090: */
091: public MockTopicConnectionFactory getMockTopicConnectionFactory() {
092: return topicConnectionFactory;
093: }
094:
095: /**
096: * Returns the {@link com.mockrunner.mock.jms.MockConnectionFactory}.
097: * @return the {@link com.mockrunner.mock.jms.MockConnectionFactory}
098: */
099: public MockConnectionFactory getMockConnectionFactory() {
100: return connectionFactory;
101: }
102: }
|