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, they are all 011 * up to date. If you are using JNDI for obtaining the 012 * factories you have to bind them to the mock context 013 * with {@link com.mockrunner.ejb.EJBTestModule#bindToContext}. 014 */ 015 public class JMSMockObjectFactory 016 { 017 private DestinationManager destinationManager; 018 private ConfigurationManager configurationManager; 019 private MockQueueConnectionFactory queueConnectionFactory; 020 private MockTopicConnectionFactory topicConnectionFactory; 021 private MockConnectionFactory connectionFactory; 022 023 /** 024 * Creates a new set of mock objects. 025 */ 026 public JMSMockObjectFactory() 027 { 028 destinationManager = new DestinationManager(); 029 configurationManager = new ConfigurationManager(); 030 queueConnectionFactory = new MockQueueConnectionFactory(destinationManager, configurationManager); 031 topicConnectionFactory = new MockTopicConnectionFactory(destinationManager, configurationManager); 032 connectionFactory = new MockConnectionFactory(destinationManager, configurationManager); 033 } 034 035 /** 036 * Returns the {@link com.mockrunner.jms.ConfigurationManager}. 037 * @return the {@link com.mockrunner.jms.ConfigurationManager} 038 */ 039 public ConfigurationManager getConfigurationManager() 040 { 041 return configurationManager; 042 } 043 044 /** 045 * Returns the {@link com.mockrunner.jms.DestinationManager}. 046 * @return the {@link com.mockrunner.jms.DestinationManager} 047 */ 048 public DestinationManager getDestinationManager() 049 { 050 return destinationManager; 051 } 052 053 /** 054 * Returns the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}. 055 * @return the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory} 056 */ 057 public MockQueueConnectionFactory getMockQueueConnectionFactory() 058 { 059 return queueConnectionFactory; 060 } 061 062 /** 063 * Returns the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}. 064 * @return the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory} 065 */ 066 public MockTopicConnectionFactory getMockTopicConnectionFactory() 067 { 068 return topicConnectionFactory; 069 } 070 071 /** 072 * Returns the {@link com.mockrunner.mock.jms.MockConnectionFactory}. 073 * @return the {@link com.mockrunner.mock.jms.MockConnectionFactory} 074 */ 075 public MockConnectionFactory getMockConnectionFactory() 076 { 077 return connectionFactory; 078 } 079 }