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

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

package com.mockrunner.mock.jms;

import javax.jms.Connection;
import javax.jms.JMSException;

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

/**
 * Mock implementation of JMS QueueConnectionFactory.
 */
public class MockQueueConnectionFactory extends MockConnectionFactory
{
    public MockQueueConnectionFactory(DestinationManager destinationManager, ConfigurationManager configurationManager)
    {
        super(destinationManager, configurationManager);
    }
    
    public Connection createConnection() throws JMSException
    {
        return createQueueConnection();
    }

    public Connection createConnection(String name, String password) throws JMSException
    {
        return createQueueConnection();
    }
    
    /**
     * Returns the connection with the specified index
     * or null if no such connection
     * exists.
     * @param index the index
     * @return the connection
     */
    public MockQueueConnection getQueueConnection(int index)
    {
        if(connections().size() <= index) return null;
        return (MockQueueConnection)connections().get(index);
    }
    
    /**
     * Returns the latest created connection
     * or null if no such connection
     * exists.
     * @return the connection
     */
    public MockQueueConnection getLatestQueueConnection()
    {
        if(connections().size() == 0) return null;
        return (MockQueueConnection)connections().get(connections().size() - 1);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy