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

com.mockrunner.mock.connector.cci.ConnectorMockObjectFactory Maven / Gradle / Ivy

There is a newer version: 2.0.7
Show newest version
package com.mockrunner.mock.connector.cci;

import com.mockrunner.connector.InteractionHandler;

/**
 * Used to create all types of JCA 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
 * MockConnectionFactory you have to bind them to 
 * the mock JNDI context with {@link com.mockrunner.ejb.EJBTestModule#bindToContext}.
 */
public class ConnectorMockObjectFactory
{
    private MockConnectionFactory connectionFactory;
    private MockConnection connection;
    private InteractionHandler interactionHandler;
    
    public ConnectorMockObjectFactory()
    {
        connectionFactory = createMockConnectionFactory();
        connection = createMockConnection();
        connectionFactory.setConnection(connection);
        interactionHandler = new InteractionHandler();
        connection.setInteractionHandler(interactionHandler);
    }

    /**
     * Creates the {@link com.mockrunner.mock.connector.cci.MockConnection} using new.
     * This method can be overridden to return a subclass of {@link com.mockrunner.mock.connector.cci.MockConnection}.
     * @return the {@link com.mockrunner.mock.connector.cci.MockConnection}
     */
    public MockConnection createMockConnection()
    {
        return new MockConnection();
    }

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

    /**
     * Returns the {@link com.mockrunner.mock.connector.cci.MockConnection}.
     * @return the {@link com.mockrunner.mock.connector.cci.MockConnection}
     */
    public MockConnection getMockConnection()
    {
        return connection;
    }

    /**
     * Returns the {@link com.mockrunner.mock.connector.cci.MockConnectionFactory}.
     * @return the {@link com.mockrunner.mock.connector.cci.MockConnectionFactory}
     */
    public MockConnectionFactory getMockConnectionFactory()
    {
        return connectionFactory;
    }

    /**
     * Returns the {@link com.mockrunner.connector.InteractionHandler}.
     * @return the {@link com.mockrunner.connector.InteractionHandler}
     */
    public InteractionHandler getInteractionHandler()
    {
        return interactionHandler;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy