org.apache.qpid.test.framework.distributedcircuit
Class TestClientCircuitEnd

java.lang.Object
  extended by org.apache.qpid.test.framework.distributedcircuit.TestClientCircuitEnd
All Implemented Interfaces:
CircuitEnd, TestClientControlledTest

public class TestClientCircuitEnd
extends Object
implements CircuitEnd, TestClientControlledTest

A TestClientCircuitEnd is a CircuitEnd that may be controlled from a TestClient, and that forms a single publishing or receiving end point in a distributed test Circuit.

When operating in the SENDER role, this circuit end is capable of acting as part of the default circuit test procedure (described in the class comment for Circuit). That is, it will send the number of test messages required, using the test configuration parameters given in the test invite, and return a report on its activities to the circuit controller.

When operation in the RECEIVER role, this circuit end acts as part of the default circuit test procedure. It will receive test messages, on the setup specified in the test configuration parameters, and keep count of the messages received, and time taken to receive them. When requested by the circuit controller to provide a report, it will return this report of its activities.

CRC Card
Responsibilities Collaborations
Provide a message producer for sending messages. CircuitEnd, LocalCircuitFactory, TestUtils
Provide a message consumer for receiving messages. CircuitEnd, LocalCircuitFactory, TestUtils
Supply the name of the test case that this implements.
Accept/Reject invites based on test parameters. MessagingTestConfigProperties
Adapt to assigned roles. TestClientControlledTest.Roles
Perform test case actions. MessageMonitor
Generate test reports. MessageMonitor


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest
TestClientControlledTest.Roles
 
Field Summary
(package private)  CircuitEnd circuitEnd
          Holds the circuit end for this test.
(package private)  MessageMonitor messageMonitor
          Holds a message monitor for this circuit end, either the monitor on the consumer when in RECEIVER more, or a monitor updated on every message sent, when acting as a SENDER.
(package private)  org.apache.qpid.junit.extensions.util.ParsedProperties testProps
          Holds the test parameters.
 
Constructor Summary
TestClientCircuitEnd()
           
 
Method Summary
 boolean acceptInvite(Message inviteMessage)
          Determines whether the test invite that matched this test case is acceptable.
 void assignRole(TestClientControlledTest.Roles role, Message assignRoleMessage)
          Assigns the role to be played by this test case.
 void close()
          Closes the message producers and consumers and the sessions, associated with this circuit end point.
 MessageConsumer getConsumer()
          Gets the message consumer at this circuit end point.
 ExceptionMonitor getExceptionMonitor()
          Returns the exception monitor for reporting on exceptions received on this circuit end.
 MessageMonitor getMessageMonitor()
          Returns the message monitor for reporting on received messages on this circuit end.
 String getName()
          Should provide the name of the test case that this class implements.
 MessageProducer getProducer()
          Gets the message producer at this circuit end point.
 Message getReport(Session session)
          Gets a report on the actions performed by the test case in its assigned role.
 Session getSession()
          Gets the JMS Session associated with this circuit end point.
 void send(Message message)
          Send the specified message over the producer at this end point.
 void start(int numMessages)
          Performs the test case actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testProps

org.apache.qpid.junit.extensions.util.ParsedProperties testProps
Holds the test parameters.


circuitEnd

CircuitEnd circuitEnd
Holds the circuit end for this test.


messageMonitor

MessageMonitor messageMonitor
Holds a message monitor for this circuit end, either the monitor on the consumer when in RECEIVER more, or a monitor updated on every message sent, when acting as a SENDER.

Constructor Detail

TestClientCircuitEnd

public TestClientCircuitEnd()
Method Detail

getName

public String getName()
Should provide the name of the test case that this class implements. The exact names are defined in the interop testing spec.

Specified by:
getName in interface TestClientControlledTest
Returns:
The name of the test case that this implements.

acceptInvite

public boolean acceptInvite(Message inviteMessage)
                     throws JMSException
Determines whether the test invite that matched this test case is acceptable.

Specified by:
acceptInvite in interface TestClientControlledTest
Parameters:
inviteMessage - The invitation to accept or reject.
Returns:
true to accept the invitation, false to reject it.
Throws:
JMSException - Any JMSException resulting from reading the message are allowed to fall through.

assignRole

public void assignRole(TestClientControlledTest.Roles role,
                       Message assignRoleMessage)
                throws JMSException
Assigns the role to be played by this test case. The test parameters are fully specified in the assignment message. When this method return the test case will be ready to execute.

Specified by:
assignRole in interface TestClientControlledTest
Parameters:
role - The role to be played; sender or receivers.
assignRoleMessage - The role assingment message, contains the full test parameters.
Throws:
JMSException - Any JMSException resulting from reading the message are allowed to fall through.

start

public void start(int numMessages)
           throws JMSException
Performs the test case actions. Returning from here, indicates that the sending role has completed its test.

Specified by:
start in interface TestClientControlledTest
Parameters:
numMessages - The number of test messages to send.
Throws:
JMSException - Any JMSException resulting from reading the message are allowed to fall through.
Todo:
Add round robin on destinations where multiple destinations being used., Add rate limiting when rate limit specified on publishers., Add Max pending message size protection. The receiver will have to send back some acks once in a while, to notify the publisher that its messages are being consumed. This makes the safety valve harder to implement than in the single VM case. For example, if the limit is 1000 messages, might want to get back an ack every 500, to notify the publisher that it can keep sending. What about pub/sub tests? Will it be necessary to wait for an ack from every receiver? This will have the effect of rate limiting to slow consumers too., Add commits on every commit batch size boundary.

getReport

public Message getReport(Session session)
                  throws JMSException
Gets a report on the actions performed by the test case in its assigned role.

Specified by:
getReport in interface TestClientControlledTest
Parameters:
session - The controlSession to create the report message in.
Returns:
The report message.
Throws:
JMSException - Any JMSExceptions resulting from creating the report are allowed to fall through.

getProducer

public MessageProducer getProducer()
Gets the message producer at this circuit end point.

Specified by:
getProducer in interface CircuitEnd
Returns:
The message producer at with this circuit end point.

getConsumer

public MessageConsumer getConsumer()
Gets the message consumer at this circuit end point.

Specified by:
getConsumer in interface CircuitEnd
Returns:
The message consumer at this circuit end point.

send

public void send(Message message)
          throws JMSException
Send the specified message over the producer at this end point.

Specified by:
send in interface CircuitEnd
Parameters:
message - The message to send.
Throws:
JMSException - Any JMS exception occuring during the send is allowed to fall through.

getSession

public Session getSession()
Gets the JMS Session associated with this circuit end point.

Specified by:
getSession in interface CircuitEnd
Returns:
The JMS Session associated with this circuit end point.

close

public void close()
           throws JMSException
Closes the message producers and consumers and the sessions, associated with this circuit end point.

Specified by:
close in interface CircuitEnd
Throws:
JMSException - Any JMSExceptions occurring during the close are allowed to fall through.

getMessageMonitor

public MessageMonitor getMessageMonitor()
Returns the message monitor for reporting on received messages on this circuit end.

Specified by:
getMessageMonitor in interface CircuitEnd
Returns:
The message monitor for this circuit end.

getExceptionMonitor

public ExceptionMonitor getExceptionMonitor()
Returns the exception monitor for reporting on exceptions received on this circuit end.

Specified by:
getExceptionMonitor in interface CircuitEnd
Returns:
The exception monitor for this circuit end.


Licensed to the Apache Software Foundation