com.mockrunner.mock.jms
Class MockConnectionFactory

java.lang.Object
  extended by com.mockrunner.mock.jms.MockConnectionFactory
All Implemented Interfaces:
java.io.Serializable, javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory
Direct Known Subclasses:
MockQueueConnectionFactory, MockTopicConnectionFactory

public class MockConnectionFactory
extends java.lang.Object
implements javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory, java.io.Serializable

Mock implementation of JMS ConnectionFactory. Can be used as generic factory for JMS 1.1. Also implements QueueConnectionFactory and TopicConnectionFactory and can be used to create queue and topic connections as well as generic JMS 1.1 connections. It is recommended to use MockQueueConnectionFactory if you only use queues and MockTopicConnectionFactory if you only use topics. This implementation is primary for generic JMS 1.1 connections but can also be used, if a server provides one implementation for both domains (which is not portable).

See Also:
Serialized Form

Constructor Summary
MockConnectionFactory(DestinationManager destinationManager, ConfigurationManager configurationManager)
           
 
Method Summary
 void clearConnections()
          Clears the list of connections
protected  ConfigurationManager configurationManager()
           
protected  java.util.List connections()
           
 javax.jms.Connection createConnection()
           
 javax.jms.Connection createConnection(java.lang.String name, java.lang.String password)
           
 javax.jms.QueueConnection createQueueConnection()
           
 javax.jms.QueueConnection createQueueConnection(java.lang.String name, java.lang.String password)
           
 javax.jms.TopicConnection createTopicConnection()
           
 javax.jms.TopicConnection createTopicConnection(java.lang.String name, java.lang.String password)
           
protected  DestinationManager destinationManager()
           
protected  javax.jms.JMSException exception()
           
 MockConnection getConnection(int index)
          Returns the connection with the specified index or null if no such connection exists.
 MockConnection getLatestConnection()
          Returns the latest created connection or null if no such connection exists.
 void setJMSException(javax.jms.JMSException exception)
          Set an exception that will be passed to all created connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockConnectionFactory

public MockConnectionFactory(DestinationManager destinationManager,
                             ConfigurationManager configurationManager)
Method Detail

createConnection

public javax.jms.Connection createConnection()
                                      throws javax.jms.JMSException
Specified by:
createConnection in interface javax.jms.ConnectionFactory
Throws:
javax.jms.JMSException

createConnection

public javax.jms.Connection createConnection(java.lang.String name,
                                             java.lang.String password)
                                      throws javax.jms.JMSException
Specified by:
createConnection in interface javax.jms.ConnectionFactory
Throws:
javax.jms.JMSException

createQueueConnection

public javax.jms.QueueConnection createQueueConnection()
                                                throws javax.jms.JMSException
Specified by:
createQueueConnection in interface javax.jms.QueueConnectionFactory
Throws:
javax.jms.JMSException

createQueueConnection

public javax.jms.QueueConnection createQueueConnection(java.lang.String name,
                                                       java.lang.String password)
                                                throws javax.jms.JMSException
Specified by:
createQueueConnection in interface javax.jms.QueueConnectionFactory
Throws:
javax.jms.JMSException

createTopicConnection

public javax.jms.TopicConnection createTopicConnection()
                                                throws javax.jms.JMSException
Specified by:
createTopicConnection in interface javax.jms.TopicConnectionFactory
Throws:
javax.jms.JMSException

createTopicConnection

public javax.jms.TopicConnection createTopicConnection(java.lang.String name,
                                                       java.lang.String password)
                                                throws javax.jms.JMSException
Specified by:
createTopicConnection in interface javax.jms.TopicConnectionFactory
Throws:
javax.jms.JMSException

setJMSException

public void setJMSException(javax.jms.JMSException exception)
Set an exception that will be passed to all created connections. This can be used to simulate server errors. Check out MockConnection.setJMSException(javax.jms.JMSException) for details.

Parameters:
exception - the exception

clearConnections

public void clearConnections()
Clears the list of connections


getConnection

public MockConnection getConnection(int index)
Returns the connection with the specified index or null if no such connection exists.

Parameters:
index - the index
Returns:
the connection

getLatestConnection

public MockConnection getLatestConnection()
Returns the latest created connection or null if no such connection exists.

Returns:
the connection

destinationManager

protected DestinationManager destinationManager()

configurationManager

protected ConfigurationManager configurationManager()

connections

protected java.util.List connections()

exception

protected javax.jms.JMSException exception()