org.apache.qpid.test.framework.localcircuit
Class LocalCircuitImpl

java.lang.Object
  extended by org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl
All Implemented Interfaces:
Circuit

public class LocalCircuitImpl
extends Object
implements Circuit

LocalCircuitImpl provides an implementation of the test circuit. This is a local only circuit implementation that supports a single producer/consumer on each end of the circuit, with both ends of the circuit on the same JVM.

CRC Card
Responsibilities Collaborations
Supply the publishing and receiving ends of a test messaging circuit. LocalPublisherImpl, LocalReceiverImpl
Start the circuit running.
Close the circuit down.
Take a reading of the circuits state.
Apply assertions against the circuits state. Assertion
Send test messages over the circuit.
Perform the default test procedure on the circuit.
Provide access to connection and controlSession exception monitors. ExceptionMonitor


Constructor Summary
LocalCircuitImpl(org.apache.qpid.junit.extensions.util.ParsedProperties testProps, LocalPublisherImpl publisher, LocalReceiverImpl receiver, Connection connection, ExceptionMonitor connectionExceptionMonitor)
          Creates a test circuit using the specified test parameters.
 
Method Summary
 List<Assertion> applyAssertions(List<Assertion> assertions)
          Applied a list of assertions against the test circuit.
 void check()
          Checks the test circuit.
 void close()
          Closes the circuit.
 ExceptionMonitor getConnectionExceptionMonitor()
          Gets the exception monitor for the publishing ends connection.
 ExceptionMonitor getExceptionMonitor()
          Gets the exception monitor for the publishing ends controlSession.
 CircuitEnd getLocalPublisherCircuitEnd()
          Gets the local publishing circuit end, for direct manipulation.
 CircuitEnd getLocalReceiverCircuitEnd()
          Gets the local receiving circuit end, for direct manipulation.
 Publisher getPublisher()
          Gets the interface on the publishing end of the circuit.
 Receiver getReceiver()
          Gets the interface on the receiving end of the circuit.
protected  void send()
          Sends a message on the test circuit.
 void start()
          Connects and starts the circuit.
 List<Assertion> test(int numMessages, List<Assertion> assertions)
          Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalCircuitImpl

public LocalCircuitImpl(org.apache.qpid.junit.extensions.util.ParsedProperties testProps,
                        LocalPublisherImpl publisher,
                        LocalReceiverImpl receiver,
                        Connection connection,
                        ExceptionMonitor connectionExceptionMonitor)
Creates a test circuit using the specified test parameters. The publisher, receivers, connection and connection monitor must already have been created, to assemble the circuit.

Parameters:
testProps - The test parameters.
publisher - The test publisher.
receiver - The test receivers.
connection - The connection.
connectionExceptionMonitor - The connection exception monitor.
Method Detail

getPublisher

public Publisher getPublisher()
Gets the interface on the publishing end of the circuit.

Specified by:
getPublisher in interface Circuit
Returns:
The publishing end of the circuit.

getLocalPublisherCircuitEnd

public CircuitEnd getLocalPublisherCircuitEnd()
Gets the local publishing circuit end, for direct manipulation.

Returns:
The local publishing circuit end.

getReceiver

public Receiver getReceiver()
Gets the interface on the receiving end of the circuit.

Specified by:
getReceiver in interface Circuit
Returns:
The receiving end of the circuit.

getLocalReceiverCircuitEnd

public CircuitEnd getLocalReceiverCircuitEnd()
Gets the local receiving circuit end, for direct manipulation.

Returns:
The local receiving circuit end.

check

public void check()
Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit, into a report, against which assertions may be checked.

Specified by:
check in interface Circuit

applyAssertions

public List<Assertion> applyAssertions(List<Assertion> assertions)
Applied a list of assertions against the test circuit. The check() method should be called before doing this, to ensure that the circuit has gathered its state into a report to assert against.

Specified by:
applyAssertions in interface Circuit
Parameters:
assertions - The list of assertions to apply.
Returns:
Any assertions that failed.

start

public void start()
Connects and starts the circuit. After this method is called the circuit is ready to send messages.

Specified by:
start in interface Circuit

close

public void close()
Closes the circuit. All associated resources are closed.

Specified by:
close in interface Circuit

send

protected void send()
Sends a message on the test circuit. The exact nature of the message sent is controlled by the test parameters.


test

public List<Assertion> test(int numMessages,
                            List<Assertion> assertions)
Runs the default test procedure against the circuit, and checks that all of the specified assertions hold. The outline of the default test procedure is:

 Start the circuit.
 Send test messages.
 Request a status report.
 Assert conditions on the publishing end of the circuit.
 Assert conditions on the receiving end of the circuit.
 Close the circuit.
 Pass with no failed assertions or fail with a list of failed assertions.
 

Specified by:
test in interface Circuit
Parameters:
numMessages - The number of messages to send using the default test procedure.
assertions - The list of assertions to apply.
Returns:
Any assertions that failed.

getConnectionExceptionMonitor

public ExceptionMonitor getConnectionExceptionMonitor()
Gets the exception monitor for the publishing ends connection.

Returns:
The exception monitor for the publishing ends connection.

getExceptionMonitor

public ExceptionMonitor getExceptionMonitor()
Gets the exception monitor for the publishing ends controlSession.

Returns:
The exception monitor for the publishing ends controlSession.


Licensed to the Apache Software Foundation