All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.mock.jms.JMSMockObjectFactory Maven / Gradle / Ivy

Go to download

Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions. It includes a JDBC a JMS and a JCA test framework and can be used to test EJB based applications.

The newest version!
package com.mockrunner.mock.jms;

import com.mockrunner.jms.ConfigurationManager;
import com.mockrunner.jms.DestinationManager;

/**
 * Used to create all types of JMS mock objects. 
 * Maintains the necessary dependencies between the mock objects.
 * If you use the mock objects returned by this
 * factory in your tests you can be sure that they are all
 * up to date. If you are using JNDI for obtaining the
 * connection factories you have to bind them to the mock JNDI context
 * with {@link com.mockrunner.ejb.EJBTestModule#bindToContext}.
 */
public class JMSMockObjectFactory
{
    private DestinationManager destinationManager;
    private ConfigurationManager configurationManager;
    private MockQueueConnectionFactory queueConnectionFactory;
    private MockTopicConnectionFactory topicConnectionFactory;
    private MockConnectionFactory connectionFactory;
    
    /**
     * Creates a new set of mock objects.
     */
    public JMSMockObjectFactory()
    {
        destinationManager = new DestinationManager();
        configurationManager = new ConfigurationManager();
        queueConnectionFactory = createMockQueueConnectionFactory();
        topicConnectionFactory = createMockTopicConnectionFactory();
        connectionFactory = createMockConnectionFactory();
    }

    /**
     * Creates the {@link com.mockrunner.mock.jms.MockConnectionFactory} using new.
     * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jms.MockConnectionFactory}.
     * @return the {@link com.mockrunner.mock.jms.MockConnectionFactory}
     */
    public MockConnectionFactory createMockConnectionFactory()
    {
        return new MockConnectionFactory(destinationManager, configurationManager);
    }

    /**
     * Creates the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory} using new.
     * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}.
     * @return the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}
     */
    public MockTopicConnectionFactory createMockTopicConnectionFactory()
    {
        return new MockTopicConnectionFactory(destinationManager, configurationManager);
    }

    /**
     * Creates the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory} using new.
     * This method can be overridden to return a subclass of {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}.
     * @return the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}
     */
    public MockQueueConnectionFactory createMockQueueConnectionFactory()
    {
        return new MockQueueConnectionFactory(destinationManager, configurationManager);
    }
    
    /**
     * Returns the {@link com.mockrunner.jms.ConfigurationManager}.
     * @return the {@link com.mockrunner.jms.ConfigurationManager}
     */
    public ConfigurationManager getConfigurationManager()
    {
        return configurationManager;
    }
    
    /**
     * Returns the {@link com.mockrunner.jms.DestinationManager}.
     * @return the {@link com.mockrunner.jms.DestinationManager}
     */
    public DestinationManager getDestinationManager()
    {
        return destinationManager;
    }
    
    /**
     * Returns the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}.
     * @return the {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}
     */
    public MockQueueConnectionFactory getMockQueueConnectionFactory()
    {
        return queueConnectionFactory;
    }
    
    /**
     * Returns the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}.
     * @return the {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}
     */
    public MockTopicConnectionFactory getMockTopicConnectionFactory()
    {
        return topicConnectionFactory;
    }
    
    /**
     * Returns the {@link com.mockrunner.mock.jms.MockConnectionFactory}.
     * @return the {@link com.mockrunner.mock.jms.MockConnectionFactory}
     */
    public MockConnectionFactory getMockConnectionFactory()
    {
        return connectionFactory;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy