org.apache.qpid.test.framework.distributedtesting
Class TestClient

java.lang.Object
  extended by org.apache.qpid.test.framework.distributedtesting.TestClient
All Implemented Interfaces:
MessageListener

public class TestClient
extends Object
implements MessageListener

Implements a test client as described in the interop testing spec (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that reacts to control message sequences send by the test Coordinator.

Messages Handled by TestClient
Message Action
Invite(compulsory) Reply with Enlist.
Invite(test case) Reply with Enlist if test case available.
AssignRole(test case) Reply with Accept Role if matches an enlisted test. Keep test parameters.
Start Send test messages defined by test parameters. Send report on messages sent.
Status Request Send report on messages received.
Terminate Terminate the test client.
ClockSynch Synch clock against the supplied UDP address.

CRC Card
Responsibilities Collaborations
Handle all incoming control messages. TestClientControlledTest
Configure and look up test cases by name. TestClientControlledTest


Field Summary
static String CLIENT_NAME
          Holds the default identifying name of the test client.
protected  String clientName
          Holds the name of this client, with a default value.
(package private)  ClockSynchThread clockSynchThread
          Holds the clock synchronizer for the test node.
protected  Connection connection
          Holds the connection to the broker that the test is being coordinated on.
protected  TestClientControlledTest currentTestCase
          Holds the test case currently being run by this client.
protected  boolean join
          This flag indicates that the test client should attempt to join the currently running test case on start up.
protected  MessageProducer producer
          Holds the message producer to hold the test coordination over.
protected  Session session
          Holds the JMS controlSession for the test coordination.
(package private)  Map<String,TestClientControlledTest> testCases
          Holds all the test cases loaded from the classpath.
static org.apache.qpid.junit.extensions.util.ParsedProperties testContextProperties
          Holds the test context properties that provides the default test parameters, plus command line overrides.
 
Constructor Summary
TestClient(String pBrokerUrl, String pVirtualHost, String clientName, boolean join)
          Creates a new interop test client, listenting to the specified broker and virtual host, with the specified client identifying name.
 
Method Summary
static List<Class<? extends TestClientControlledTest>> loadTestCases(String... classNames)
          Parses a list of class names, and loads them if they are available on the class path.
static void main(String[] args)
          The entry point for the interop test coordinator.
 void onMessage(Message message)
          Handles all incoming control messages.
protected  void start(Collection<Class<? extends TestClientControlledTest>> testCaseClasses)
          Starts the interop test client running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_NAME

public static final String CLIENT_NAME
Holds the default identifying name of the test client.

See Also:
Constant Field Values

testContextProperties

public static org.apache.qpid.junit.extensions.util.ParsedProperties testContextProperties
Holds the test context properties that provides the default test parameters, plus command line overrides. This is initialized with the default test parameters, to which command line overrides may be applied.


testCases

Map<String,TestClientControlledTest> testCases
Holds all the test cases loaded from the classpath.


currentTestCase

protected TestClientControlledTest currentTestCase
Holds the test case currently being run by this client.


connection

protected Connection connection
Holds the connection to the broker that the test is being coordinated on.


producer

protected MessageProducer producer
Holds the message producer to hold the test coordination over.


session

protected Session session
Holds the JMS controlSession for the test coordination.


clientName

protected String clientName
Holds the name of this client, with a default value.


join

protected boolean join
This flag indicates that the test client should attempt to join the currently running test case on start up.


clockSynchThread

ClockSynchThread clockSynchThread
Holds the clock synchronizer for the test node.

Constructor Detail

TestClient

public TestClient(String pBrokerUrl,
                  String pVirtualHost,
                  String clientName,
                  boolean join)
Creates a new interop test client, listenting to the specified broker and virtual host, with the specified client identifying name.

Parameters:
pBrokerUrl - The url of the broker to connect to.
pVirtualHost - The virtual host to conect to.
clientName - The client name to use.
join - Flag to indicate that this client should attempt to join running tests.
Method Detail

main

public static void main(String[] args)
The entry point for the interop test coordinator. This client accepts the following command line arguments:

-b The broker URL. Optional.
-h The virtual host. Optional.
-n The test client name. Optional.
name=value Trailing argument define name/value pairs. Added to system properties. Optional.

Parameters:
args - The command line arguments.

loadTestCases

public static List<Class<? extends TestClientControlledTest>> loadTestCases(String... classNames)
Parses a list of class names, and loads them if they are available on the class path.

Parameters:
classNames - The names of the classes to load.
Returns:
A list of the loaded test case classes.

start

protected void start(Collection<Class<? extends TestClientControlledTest>> testCaseClasses)
              throws JMSException
Starts the interop test client running. This causes it to start listening for incoming test invites.

Parameters:
testCaseClasses - The classes of the available test cases. The test case names from these are used to matchin incoming test invites against.
Throws:
JMSException - Any underlying JMSExceptions are allowed to fall through.

onMessage

public void onMessage(Message message)
Handles all incoming control messages.

Specified by:
onMessage in interface MessageListener
Parameters:
message - The incoming message.


Licensed to the Apache Software Foundation