org.apache.qpid.test.framework
Class LocalCircuitFactory

java.lang.Object
  extended by org.apache.qpid.test.framework.LocalCircuitFactory
All Implemented Interfaces:
CircuitFactory
Direct Known Subclasses:
LocalAMQPCircuitFactory

public class LocalCircuitFactory
extends Object
implements CircuitFactory

LocalCircuitFactory is a circuit factory that creates test circuits with publishing and receiving ends rooted on the same JVM. The ends of the circuit are presented as Publisher and Receiver interfaces, which in turn provide methods to apply assertions to the circuit. The creation of the circuit ends, and the presentation of the ends as publisher/receiver interfaces, are designed to be overriden, so that circuits and assertions that use messaging features not available in JMS can be written. This provides an extension point for writing tests against proprietary features of JMS implementations.

CRC Card
Responsibilities Collaborations
Provide a standard test procedure over a test circuit.
Construct test circuits appropriate to a tests context.


Field Summary
protected static AtomicLong uniqueDestsId
          Used to create unique destination names for each test.
 
Constructor Summary
LocalCircuitFactory()
           
 
Method Summary
 Circuit createCircuit(Connection connection, org.apache.qpid.junit.extensions.util.ParsedProperties testProperties)
          Creates a test circuit for the test, configered by the test parameters specified.
 CircuitEndBase createPublisherCircuitEnd(Connection connection, org.apache.qpid.junit.extensions.util.ParsedProperties testProps, long uniqueId)
          Builds a circuit end suitable for the publishing side of a test circuit, from standard test parameters.
protected  LocalPublisherImpl createPublisherFromCircuitEnd(CircuitEndBase publisherEnd)
          Creates a local Publisher from a CircuitEnd.
 CircuitEndBase createReceiverCircuitEnd(Connection connection, org.apache.qpid.junit.extensions.util.ParsedProperties testProps, long uniqueId)
          Builds a circuit end suitable for the receiving side of a test circuit, from standard test parameters.
protected  LocalReceiverImpl createReceiverFromCircuitEnd(CircuitEndBase receiverEnd)
          Creates a local Receiver from a CircuitEnd.
 List<TestClientDetails> getReceivers()
          Supplies the receiving test client.
 TestClientDetails getSender()
          Supplies the sending test client.
 void sequenceTest(Circuit testCircuit, List<Assertion> assertions, Properties testProperties)
          Holds a test coordinating conversation with the test clients.
 void setConversationFactory(ConversationFactory conversationFactory)
          Accepts the conversation factory over which to hold the test coordinating conversation.
 void setReceiver(TestClientDetails receiver)
          Sets the receiving test client to coordinate the test with.
 void setSender(TestClientDetails sender)
          Sets the sender test client to coordinate the test with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uniqueDestsId

protected static AtomicLong uniqueDestsId
Used to create unique destination names for each test.

Constructor Detail

LocalCircuitFactory

public LocalCircuitFactory()
Method Detail

sequenceTest

public void sequenceTest(Circuit testCircuit,
                         List<Assertion> assertions,
                         Properties testProperties)
Holds a test coordinating conversation with the test clients. This should consist of assigning the test roles, begining the test and gathering the test reports from the participants.

Specified by:
sequenceTest in interface CircuitFactory
Parameters:
testCircuit - The test circuit.
assertions - The list of assertions to apply to the test circuit.
testProperties - The test case definition.

createCircuit

public Circuit createCircuit(Connection connection,
                             org.apache.qpid.junit.extensions.util.ParsedProperties testProperties)
Creates a test circuit for the test, configered by the test parameters specified.

Specified by:
createCircuit in interface CircuitFactory
Parameters:
testProperties - The test parameters.
Returns:
A test circuit.

createReceiverFromCircuitEnd

protected LocalReceiverImpl createReceiverFromCircuitEnd(CircuitEndBase receiverEnd)
Creates a local Receiver from a CircuitEnd. Sub-classes may override this to provide more specialized receivers if necessary.

Parameters:
receiverEnd - The receiving circuit end.
Returns:
A Receiver.

createPublisherFromCircuitEnd

protected LocalPublisherImpl createPublisherFromCircuitEnd(CircuitEndBase publisherEnd)
Creates a local Publisher from a CircuitEnd. Sub-classes may override this to provide more specialized receivers if necessary.

Parameters:
publisherEnd - The publishing circuit end.
Returns:
A Receiver.

createPublisherCircuitEnd

public CircuitEndBase createPublisherCircuitEnd(Connection connection,
                                                org.apache.qpid.junit.extensions.util.ParsedProperties testProps,
                                                long uniqueId)
                                         throws JMSException
Builds a circuit end suitable for the publishing side of a test circuit, from standard test parameters.

Parameters:
connection - The connection to build the circuit end on.
testProps - The test parameters to configure the circuit end construction.
uniqueId - A unique number to being numbering destinations from, to make this circuit unique.
Returns:
A circuit end suitable for the publishing side of a test circuit.
Throws:
JMSException - Any underlying JMSExceptions are allowed to fall through and fail the creation.

createReceiverCircuitEnd

public CircuitEndBase createReceiverCircuitEnd(Connection connection,
                                               org.apache.qpid.junit.extensions.util.ParsedProperties testProps,
                                               long uniqueId)
                                        throws JMSException
Builds a circuit end suitable for the receiving side of a test circuit, from standard test parameters.

Parameters:
connection - The connection to build the circuit end on.
testProps - The test parameters to configure the circuit end construction.
uniqueId - A unique number to being numbering destinations from, to make this circuit unique.
Returns:
A circuit end suitable for the receiving side of a test circuit.
Throws:
JMSException - Any underlying JMSExceptions are allowed to fall through and fail the creation.

setSender

public void setSender(TestClientDetails sender)
Sets the sender test client to coordinate the test with.

Specified by:
setSender in interface CircuitFactory
Parameters:
sender - The contact details of the sending client in the test.

setReceiver

public void setReceiver(TestClientDetails receiver)
Sets the receiving test client to coordinate the test with.

Specified by:
setReceiver in interface CircuitFactory
Parameters:
receiver - The contact details of the sending client in the test.

getSender

public TestClientDetails getSender()
Supplies the sending test client.

Specified by:
getSender in interface CircuitFactory
Returns:
The sending test client.

getReceivers

public List<TestClientDetails> getReceivers()
Supplies the receiving test client.

Specified by:
getReceivers in interface CircuitFactory
Returns:
The receiving test client.

setConversationFactory

public void setConversationFactory(ConversationFactory conversationFactory)
Accepts the conversation factory over which to hold the test coordinating conversation.

Specified by:
setConversationFactory in interface CircuitFactory
Parameters:
conversationFactory - The conversation factory to coordinate the test over.


Licensed to the Apache Software Foundation