You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2007/05/08 14:04:39 UTC

svn commit: r536167 - in /incubator/qpid/trunk/qpid: ./ java/integrationtests/ java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/ java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/ java/integrationt...

Author: rgreig
Date: Tue May  8 05:04:37 2007
New Revision: 536167

URL: http://svn.apache.org/viewvc?view=rev&rev=536167
Log:
Merged revisions 534903-535308,535310-535808,535810-536007,536009-536140,536142-536164 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2

........
  r534903 | rgreig | 2007-05-03 16:09:18 +0100 (Thu, 03 May 2007) | 1 line
  
  More interop test stuff.
........
  r535254 | rgreig | 2007-05-04 15:27:53 +0100 (Fri, 04 May 2007) | 1 line
  
  First two test cases completed. Still to do pub/sub.
........
  r535874 | rgreig | 2007-05-07 14:13:06 +0100 (Mon, 07 May 2007) | 1 line
  
  Added remaining test case.
........
  r536163 | rgreig | 2007-05-08 12:21:35 +0100 (Tue, 08 May 2007) | 1 line
  
  Added XML logging of test results.
........
  r536164 | rgreig | 2007-05-08 12:39:51 +0100 (Tue, 08 May 2007) | 1 line
  
  Added inclusion of sender and receiver names in results.
........

Added:
    incubator/qpid/trunk/qpid/java/integrationtests/jar-with-dependencies.xml
      - copied unchanged from r535254, incubator/qpid/branches/M2/java/integrationtests/jar-with-dependencies.xml
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/XMLTestListener.java
      - copied unchanged from r536164, incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/XMLTestListener.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java
      - copied, changed from r535254, incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase3BasicPubSub.java
      - copied unchanged from r535874, incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase3BasicPubSub.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase3BasicPubSub.java
      - copied unchanged from r535874, incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase3BasicPubSub.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/util/ConversationFactory.java
      - copied unchanged from r535254, incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/util/ConversationFactory.java
Removed:
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/util/ConversationHelper.java
Modified:
    incubator/qpid/trunk/qpid/   (props changed)
    incubator/qpid/trunk/qpid/java/integrationtests/pom.xml
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/CoordinatingTestCase.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/Coordinator.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/InvitingTestDecorator.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/OptOutTestCase.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/TestClientDetails.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase2BasicP2P.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/InteropClientTestCase.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/TestClient.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase1DummyRun.java
    incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase2BasicP2P.java

Propchange: incubator/qpid/trunk/qpid/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/qpid/trunk/qpid/java/integrationtests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/pom.xml?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/pom.xml Tue May  8 05:04:37 2007
@@ -103,6 +103,19 @@
                     </execution>
                 </executions>
             </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.2-SNAPSHOT</version>
+                <configuration>
+                    <descriptors>
+                        <descriptor>jar-with-dependencies.xml</descriptor>
+                    </descriptors>
+                    <outputDirectory>target</outputDirectory>
+                    <workDirectory>target/assembly/work</workDirectory>
+                </configuration>
+            </plugin>
             
         </plugins>
 

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/CoordinatingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/CoordinatingTestCase.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/CoordinatingTestCase.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/CoordinatingTestCase.java Tue May  8 05:04:37 2007
@@ -22,14 +22,17 @@
 package org.apache.qpid.interop.coordinator;
 
 import java.util.Collection;
+import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.LinkedBlockingQueue;
 
-import javax.jms.JMSException;
-import javax.jms.Message;
+import javax.jms.*;
 
 import junit.framework.TestCase;
 
-import org.apache.qpid.util.ConversationHelper;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.util.ConversationFactory;
 
 /**
  * An CoordinatingTestCase is a JUnit test case extension that knows how to coordinate test clients that take part in a
@@ -60,19 +63,24 @@
  * <p><table id="crc"><caption>CRC Card</caption>
  * <tr><th> Responsibilities <th> Collaborations
  * <tr><td> Accept notification of test case participants. <td> {@link InvitingTestDecorator}
- * <tr><td> Coordinate the test sequence amongst participants. <td> {@link ConversationHelper}
+ * <tr><td> Accpet JMS Connection to carry out the coordination over.
+ * <tr><td> Coordinate the test sequence amongst participants. <td> {@link ConversationFactory}
  * <tr><td> Supply test properties
  * </table>
  */
 public abstract class CoordinatingTestCase extends TestCase
 {
+    /** Used for debugging. */
+    private static final Logger log = Logger.getLogger(CoordinatingTestCase.class);
+
     /** Holds the contact details for the sending test client. */
     TestClientDetails sender;
 
     /** Holds the contact details for the receving test client. */
     TestClientDetails receiver;
 
-    ConversationHelper conversation;
+    /** Holds the conversation factory over which to coordinate the test. */
+    ConversationFactory conversationFactory;
 
     /**
      * Creates a new coordinating test case with the specified name.
@@ -91,6 +99,8 @@
      */
     public void setSender(TestClientDetails sender)
     {
+        log.debug("public void setSender(TestClientDetails sender = " + sender + "): called");
+
         this.sender = sender;
     }
 
@@ -101,6 +111,8 @@
      */
     public void setReceiver(TestClientDetails receiver)
     {
+        log.debug("public void setReceiver(TestClientDetails receiver = " + receiver + "): called");
+
         this.receiver = receiver;
     }
 
@@ -125,6 +137,46 @@
     }
 
     /**
+     * Returns the name of the current test method of this test class, with the sending and receiving client names
+     * appended on to it, so that the resulting name unqiuely identifies the test and the clients that participated
+     * in it.
+     *
+     * @return The unique test and client name.
+     */
+    public String getName()
+    {
+        if ((sender == null) || (receiver == null))
+        {
+            return super.getName();
+        }
+        else
+        {
+            return super.getName() + "_sender_" + sender.clientName + "_receiver_" + receiver.clientName;
+        }
+    }
+
+    /**
+     * Should provide a translation from the junit method name of a test to its test case name as defined in the
+     * interop testing specification. For example the method "testP2P" might map onto the interop test case name
+     * "TC2_BasicP2P".
+     *
+     * @param methodName The name of the JUnit test method.
+     *
+     * @return The name of the corresponding interop test case.
+     */
+    public abstract String getTestCaseNameForTestMethod(String methodName);
+
+    /**
+     * Accepts the conversation factory over which to hold the test coordinating conversation.
+     *
+     * @param conversationFactory The conversation factory to coordinate the test over.
+     */
+    public void setConversationFactory(ConversationFactory conversationFactory)
+    {
+        this.conversationFactory = conversationFactory;
+    }
+
+    /**
      * Holds a test coordinating conversation with the test clients. This is the basic implementation of the inner
      * loop of Use Case 5. It consists of assigning the test roles, begining the test and gathering the test reports
      * from the participants.
@@ -135,44 +187,81 @@
      *
      * @throws JMSException All underlying JMSExceptions are allowed to fall through.
      */
-    protected Message[] sequenceTest(Properties testProperties) throws JMSException
+    protected Message[] sequenceTest(Map<String, Object> testProperties) throws JMSException
     {
+        log.debug("protected Message[] sequenceTest(Object... testProperties = " + testProperties + "): called");
+
+        Session session = conversationFactory.getSession();
+        Destination senderControlTopic = session.createTopic(sender.privateControlKey);
+        Destination receiverControlTopic = session.createTopic(receiver.privateControlKey);
+
+        ConversationFactory.Conversation senderConversation = conversationFactory.startConversation();
+        ConversationFactory.Conversation receiverConversation = conversationFactory.startConversation();
+
         // Assign the sender role to the sending test client.
-        Message assignSender = conversation.getSession().createMessage();
+        Message assignSender = conversationFactory.getSession().createMessage();
+        setPropertiesOnMessage(assignSender, testProperties);
         assignSender.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
         assignSender.setStringProperty("ROLE", "SENDER");
 
-        conversation.send(assignSender);
+        senderConversation.send(senderControlTopic, assignSender);
 
         // Assign the receiver role the receiving client.
-        Message assignReceiver = conversation.getSession().createMessage();
+        Message assignReceiver = session.createMessage();
+        setPropertiesOnMessage(assignReceiver, testProperties);
         assignReceiver.setStringProperty("CONTROL_TYPE", "ASSIGN_ROLE");
         assignReceiver.setStringProperty("ROLE", "RECEIVER");
 
-        conversation.send(assignReceiver);
+        receiverConversation.send(receiverControlTopic, assignReceiver);
 
         // Wait for the senders and receivers to confirm their roles.
-        conversation.receive();
-        conversation.receive();
+        senderConversation.receive();
+        receiverConversation.receive();
 
         // Start the test.
-        Message start = conversation.getSession().createMessage();
+        Message start = session.createMessage();
         start.setStringProperty("CONTROL_TYPE", "START");
 
-        conversation.send(start);
+        senderConversation.send(senderControlTopic, start);
 
         // Wait for the test sender to return its report.
-        Message senderReport = conversation.receive();
+        Message senderReport = senderConversation.receive();
+
+        try
+        {
+            Thread.sleep(500);
+        }
+        catch (InterruptedException e)
+        { }
 
         // Ask the receiver for its report.
-        Message statusRequest = conversation.getSession().createMessage();
+        Message statusRequest = session.createMessage();
         statusRequest.setStringProperty("CONTROL_TYPE", "STATUS_REQUEST");
 
-        conversation.send(statusRequest);
+        receiverConversation.send(receiverControlTopic, statusRequest);
 
         // Wait for the receiver to send its report.
-        Message receiverReport = conversation.receive();
+        Message receiverReport = receiverConversation.receive();
 
         return new Message[] { senderReport, receiverReport };
+    }
+
+    /**
+     * Sets properties of different types on a JMS Message.
+     *
+     * @param message    The message to set properties on.
+     * @param properties The property name/value pairs to set.
+     *
+     * @throws JMSException All underlying JMSExceptions are allowed to fall through.
+     */
+    public void setPropertiesOnMessage(Message message, Map<String, Object> properties) throws JMSException
+    {
+        for (Map.Entry<String, Object> entry : properties.entrySet())
+        {
+            String name = entry.getKey();
+            Object value = entry.getValue();
+
+            message.setObjectProperty(name, value);
+        }
     }
 }

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/Coordinator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/Coordinator.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/Coordinator.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/Coordinator.java Tue May  8 05:04:37 2007
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.interop.coordinator;
 
+import java.io.*;
 import java.util.*;
 import java.util.concurrent.LinkedBlockingQueue;
 
@@ -31,18 +32,18 @@
 
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.interop.coordinator.testcases.CoordinatingTestCase1DummyRun;
 import org.apache.qpid.interop.coordinator.testcases.CoordinatingTestCase2BasicP2P;
-import org.apache.qpid.interop.testclient.InteropClientTestCase;
+import org.apache.qpid.interop.coordinator.testcases.CoordinatingTestCase3BasicPubSub;
 import org.apache.qpid.interop.testclient.TestClient;
-import org.apache.qpid.interop.testclient.testcases.TestCase1DummyRun;
-import org.apache.qpid.interop.testclient.testcases.TestCase2BasicP2P;
-import org.apache.qpid.util.ClasspathScanner;
 import org.apache.qpid.util.CommandLineParser;
-import org.apache.qpid.util.ConversationHelper;
+import org.apache.qpid.util.ConversationFactory;
 import org.apache.qpid.util.PrettyPrintingUtils;
 
-import uk.co.thebadgerset.junit.extensions.TestRunnerImprovedErrorHandling;
+import uk.co.thebadgerset.junit.extensions.TKTestResult;
+import uk.co.thebadgerset.junit.extensions.TKTestRunner;
 import uk.co.thebadgerset.junit.extensions.WrappedSuiteTestDecorator;
+import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
 
 /**
  * <p/>Implements the coordinator client described in the interop testing specification
@@ -51,13 +52,13 @@
  *
  * <p><table id="crc"><caption>CRC Card</caption>
  * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Find out what test clients are available. <td> {@link ConversationHelper}
+ * <tr><td> Find out what test clients are available. <td> {@link ConversationFactory}
  * <tr><td> Decorate available tests to run all available clients. <td> {@link InvitingTestDecorator}
  * <tr><td> Attach XML test result logger.
  * <tr><td> Terminate the interop testing framework.
  * </table>
  */
-public class Coordinator extends TestRunnerImprovedErrorHandling
+public class Coordinator extends TKTestRunner
 {
     private static final Logger log = Logger.getLogger(Coordinator.class);
 
@@ -73,10 +74,21 @@
     Set<TestClientDetails> enlistedClients = new HashSet<TestClientDetails>();
 
     /** Holds the conversation helper for the control conversation. */
-    private ConversationHelper conversation;
+    private ConversationFactory conversationFactory;
+
+    /** Holds the connection that the coordinating messages are sent over. */
     private Connection connection;
 
     /**
+     * Holds the name of the class of the test currently being run. Ideally passed into the {@link #createTestResult}
+     * method, but as the signature is already fixed for this, the current value gets pushed here as a member variable.
+     */
+    private String currentTestClassName;
+
+    /** Holds the path of the directory to output test results too, if one is defined. */
+    private static String reportDir;
+
+    /**
      * Creates an interop test coordinator on the specified broker and virtual host.
      *
      * @param brokerUrl   The URL of the broker to connect to.
@@ -114,19 +126,26 @@
                         new String[][]
                         {
                             { "b", "The broker URL.", "broker", "false" },
-                            { "h", "The virtual host to use.", "virtual host", "false" }
+                            { "h", "The virtual host to use.", "virtual host", "false" },
+                            { "o", "The name of the directory to output test timings to.", "dir", "false" }
                         }));
 
             // Extract the command line options.
             String brokerUrl = options.getProperty("b");
             String virtualHost = options.getProperty("h");
+            reportDir = options.getProperty("o");
 
             // Scan for available test cases using a classpath scanner.
             Collection<Class<? extends CoordinatingTestCase>> testCaseClasses =
                 new ArrayList<Class<? extends CoordinatingTestCase>>();
             // ClasspathScanner.getMatches(CoordinatingTestCase.class, "^Test.*", true);
             // Hard code the test classes till the classpath scanner is fixed.
-            Collections.addAll(testCaseClasses, new Class[] { CoordinatingTestCase2BasicP2P.class });
+            Collections.addAll(testCaseClasses,
+                new Class[]
+                {
+                    CoordinatingTestCase1DummyRun.class, CoordinatingTestCase2BasicP2P.class,
+                    CoordinatingTestCase3BasicPubSub.class
+                });
 
             // Check that some test classes were actually found.
             if ((testCaseClasses == null) || testCaseClasses.isEmpty())
@@ -145,9 +164,12 @@
 
             // Create a coordinator and begin its test procedure.
             Coordinator coordinator = new Coordinator(brokerUrl, virtualHost);
+
+            boolean failure = false;
+
             TestResult testResult = coordinator.start(testClassNames);
 
-            if (!testResult.wasSuccessful())
+            if (failure)
             {
                 System.exit(FAILURE_EXIT);
             }
@@ -176,7 +198,7 @@
     public TestResult start(String[] testClassNames) throws Exception
     {
         log.debug("public TestResult start(String[] testClassNames = " + PrettyPrintingUtils.printArray(testClassNames)
-            + "): called");
+            + ": called");
 
         // Connect to the broker.
         connection = TestClient.createConnection(DEFAULT_CONNECTION_PROPS_RESOURCE, brokerUrl, virtualHost);
@@ -185,28 +207,39 @@
         Destination controlTopic = session.createTopic("iop.control");
         Destination responseQueue = session.createQueue("coordinator");
 
-        conversation = new ConversationHelper(connection, controlTopic, responseQueue, LinkedBlockingQueue.class);
+        conversationFactory = new ConversationFactory(connection, responseQueue, LinkedBlockingQueue.class);
+        ConversationFactory.Conversation conversation = conversationFactory.startConversation();
+
+        connection.start();
 
         // Broadcast the compulsory invitation to find out what clients are available to test.
         Message invite = session.createMessage();
         invite.setStringProperty("CONTROL_TYPE", "INVITE");
         invite.setJMSReplyTo(responseQueue);
 
-        conversation.send(invite);
+        conversation.send(controlTopic, invite);
 
         // Wait for a short time, to give test clients an opportunity to reply to the invitation.
-        Collection<Message> enlists = conversation.receiveAll(0, 10000);
+        Collection<Message> enlists = conversation.receiveAll(0, 3000);
 
         enlistedClients = extractEnlists(enlists);
 
-        // Run all of the tests in the suite using JUnit.
-        TestResult result = super.start(testClassNames);
+        // Run the test in the suite using JUnit.
+        TestResult result = null;
+
+        for (String testClassName : testClassNames)
+        {
+            // Record the current test class, so that the test results can be output to a file incorporating this name.
+            this.currentTestClassName = testClassName;
+
+            result = super.start(new String[] { testClassName });
+        }
 
         // At this point in time, all tests have completed. Broadcast the shutdown message.
         Message terminate = session.createMessage();
         terminate.setStringProperty("CONTROL_TYPE", "TERMINATE");
 
-        conversation.send(terminate);
+        conversation.send(controlTopic, terminate);
 
         return result;
     }
@@ -283,8 +316,69 @@
         }
 
         // Wrap the tests in an inviting test decorator, to perform the invite/test cycle.
-        targetTest = new InvitingTestDecorator(targetTest, enlistedClients, conversation);
+        targetTest = new InvitingTestDecorator(targetTest, enlistedClients, conversationFactory, connection);
+
+        TestSuite suite = new TestSuite();
+        suite.addTest(targetTest);
+
+        // Wrap the tests in a scaled test decorator to them them as a 'batch' in one thread.
+        // targetTest = new ScaledTestDecorator(targetTest, new int[] { 1 });
+
+        return super.doRun(suite, wait);
+    }
+
+    /**
+     * Creates the TestResult object to be used for test runs.
+     *
+     * @return An instance of the test result object.
+     */
+    protected TestResult createTestResult()
+    {
+        log.debug("protected TestResult createTestResult(): called");
+
+        TKTestResult result = new TKTestResult(fPrinter.getWriter(), delay, verbose, testCaseName);
+
+        // Check if a directory to output reports to has been specified and attach test listeners if so.
+        if (reportDir != null)
+        {
+            // Create the report directory if it does not already exist.
+            File reportDirFile = new File(reportDir);
+
+            if (!reportDirFile.exists())
+            {
+                reportDirFile.mkdir();
+            }
 
-        return super.doRun(targetTest, wait);
+            // Create the timings file (make the name of this configurable as a command line parameter).
+            Writer timingsWriter = null;
+
+            try
+            {
+                File timingsFile = new File(reportDirFile, "TEST." + currentTestClassName + ".xml");
+                timingsWriter = new BufferedWriter(new FileWriter(timingsFile), 20000);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException("Unable to create the log file to write test results to: " + e, e);
+            }
+
+            // Set up a CSV results listener to output the timings to the results file.
+            XMLTestListener listener = new XMLTestListener(timingsWriter, currentTestClassName);
+            result.addListener(listener);
+            result.addTKTestListener(listener);
+
+            // Register the results listeners shutdown hook to flush its data if the test framework is shutdown
+            // prematurely.
+            // registerShutdownHook(listener);
+
+            // Record the start time of the batch.
+            // result.notifyStartBatch();
+
+            // At this point in time the test class has been instantiated, giving it an opportunity to read its parameters.
+            // Inform any test listers of the test properties.
+            result.notifyTestProperties(TestContextProperties.getAccessedProps());
+        }
+
+        return result;
     }
 }

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/InvitingTestDecorator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/InvitingTestDecorator.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/InvitingTestDecorator.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/InvitingTestDecorator.java Tue May  8 05:04:37 2007
@@ -23,6 +23,8 @@
 import java.util.*;
 import java.util.concurrent.LinkedBlockingQueue;
 
+import javax.jms.Connection;
+import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
 
@@ -32,14 +34,14 @@
 
 import org.apache.log4j.Logger;
 
-import org.apache.qpid.util.ConversationHelper;
+import org.apache.qpid.util.ConversationFactory;
 
 import uk.co.thebadgerset.junit.extensions.WrappedSuiteTestDecorator;
 
 /**
  * <p><table id="crc"><caption>CRC Card</caption>
  * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Broadcast test invitations and collect enlists. <td> {@link ConversationHelper}.
+ * <tr><td> Broadcast test invitations and collect enlists. <td> {@link ConversationFactory}.
  * <tr><td> Output test failures for clients unwilling to run the test case. <td> {@link Coordinator}
  * <tr><td> Execute coordinated test cases. <td> {@link CoordinatingTestCase}
  * </table>
@@ -52,7 +54,10 @@
     Set<TestClientDetails> allClients;
 
     /** Holds the conversation helper for the control level conversation for coordinating the test through. */
-    ConversationHelper conversation;
+    ConversationFactory conversationFactory;
+
+    /** Holds the connection that the control conversation is held over. */
+    Connection connection;
 
     /** Holds the underlying {@link CoordinatingTestCase}s that this decorator wraps. */
     WrappedSuiteTestDecorator testSuite;
@@ -61,11 +66,12 @@
      * Creates a wrapped suite test decorator from another one.
      *
      * @param suite               The test suite.
-     * @param availableClients          The list of all clients that responded to the compulsory invite.
+     * @param availableClients    The list of all clients that responded to the compulsory invite.
      * @param controlConversation The conversation helper for the control level, test coordination conversation.
+     * @param controlConnection   The connection that the coordination messages are sent over.
      */
     public InvitingTestDecorator(WrappedSuiteTestDecorator suite, Set<TestClientDetails> availableClients,
-        ConversationHelper controlConversation)
+        ConversationFactory controlConversation, Connection controlConnection)
     {
         super(suite);
 
@@ -74,7 +80,8 @@
 
         testSuite = suite;
         allClients = availableClients;
-        conversation = controlConversation;
+        conversationFactory = controlConversation;
+        connection = controlConnection;
     }
 
     /**
@@ -103,14 +110,17 @@
             Set<TestClientDetails> enlists = null;
             try
             {
-                Message invite = conversation.getSession().createMessage();
+                Message invite = conversationFactory.getSession().createMessage();
+                Destination controlTopic = conversationFactory.getSession().createTopic("iop.control");
+                ConversationFactory.Conversation conversation = conversationFactory.startConversation();
+
                 invite.setStringProperty("CONTROL_TYPE", "INVITE");
-                invite.setStringProperty("TEST_NAME", coordTest.getName());
+                invite.setStringProperty("TEST_NAME", coordTest.getTestCaseNameForTestMethod(coordTest.getName()));
 
-                conversation.send(invite);
+                conversation.send(controlTopic, invite);
 
                 // Wait for a short time, to give test clients an opportunity to reply to the invitation.
-                Collection<Message> replies = conversation.receiveAll(allClients.size(), 10000);
+                Collection<Message> replies = conversation.receiveAll(allClients.size(), 3000);
                 enlists = Coordinator.extractEnlists(replies);
             }
             catch (JMSException e)
@@ -143,10 +153,23 @@
                 coordTest.setSender(enlistedPair.get(0));
                 coordTest.setReceiver(enlistedPair.get(1));
 
+                // Pass down the connection to hold the coordination conversation over.
+                coordTest.setConversationFactory(conversationFactory);
+
                 // Execute the test case.
                 coordTest.run(testResult);
             }
         }
+    }
+
+    /**
+     * Prints a string summarizing this test decorator, mainly for debugging purposes.
+     *
+     * @return String representation for debugging purposes.
+     */
+    public String toString()
+    {
+        return "InvitingTestDecorator: [ testSuite = " + testSuite + " ]";
     }
 
     /**

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/OptOutTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/OptOutTestCase.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/OptOutTestCase.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/OptOutTestCase.java Tue May  8 05:04:37 2007
@@ -49,4 +49,17 @@
     {
         Assert.fail("One of " + getSender() + " and " + getReceiver() + " opted out of the test.");
     }
+
+    /**
+     * Should provide a translation from the junit method name of a test to its test case name as defined in the
+     * interop testing specification. For example the method "testP2P" might map onto the interop test case name
+     * "TC2_BasicP2P".
+     *
+     * @param methodName The name of the JUnit test method.
+     * @return The name of the corresponding interop test case.
+     */
+    public String getTestCaseNameForTestMethod(String methodName)
+    {
+        return "OptOutTest";
+    }
 }

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/TestClientDetails.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/TestClientDetails.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/TestClientDetails.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/TestClientDetails.java Tue May  8 05:04:37 2007
@@ -82,6 +82,6 @@
      */
     public String toString()
     {
-        return "clientName = " + clientName + ", privateControlKey = " + privateControlKey;
+        return "TestClientDetails: [ clientName = " + clientName + ", privateControlKey = " + privateControlKey + " ]";
     }
 }

Copied: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java (from r535254, incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java?view=diff&rev=536167&p1=incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java&r1=535254&p2=incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java&r2=536167
==============================================================================
--- incubator/qpid/branches/M2/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase1DummyRun.java Tue May  8 05:04:37 2007
@@ -2,7 +2,6 @@
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
 
 import javax.jms.Message;
 
@@ -22,7 +21,7 @@
 public class CoordinatingTestCase1DummyRun extends CoordinatingTestCase
 {
     /** Used for debugging. */
-    private static final Logger log = Logger.getLogger(CoordinatingTestCase2BasicP2P.class);
+    private static final Logger log = Logger.getLogger(CoordinatingTestCase1DummyRun.class);
 
     /**
      * Creates a new coordinating test case with the specified name.
@@ -62,5 +61,4 @@
     {
         return "TC1_DummyRun";
     }
-
 }

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase2BasicP2P.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase2BasicP2P.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase2BasicP2P.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/coordinator/testcases/CoordinatingTestCase2BasicP2P.java Tue May  8 05:04:37 2007
@@ -1,11 +1,14 @@
 package org.apache.qpid.interop.coordinator.testcases;
 
-import java.util.Properties;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.jms.Message;
 
 import junit.framework.Assert;
 
+import org.apache.log4j.Logger;
+
 import org.apache.qpid.interop.coordinator.CoordinatingTestCase;
 
 /**
@@ -16,6 +19,9 @@
  */
 public class CoordinatingTestCase2BasicP2P extends CoordinatingTestCase
 {
+    /** Used for debugging. */
+    private static final Logger log = Logger.getLogger(CoordinatingTestCase2BasicP2P.class);
+
     /**
      * Creates a new coordinating test case with the specified name.
      *
@@ -31,10 +37,12 @@
      */
     public void testBasicP2P() throws Exception
     {
-        Properties testConfig = new Properties();
-        testConfig.setProperty("TEST_CASE", "TC2_BasicP2P");
-        testConfig.setProperty("P2P_QUEUE_AND_KEY_NAME", "tc2queue");
-        testConfig.setProperty("P2P_NUM_MESSAGES", "50");
+        log.debug("public void testBasicP2P(): called");
+
+        Map<String, Object> testConfig = new HashMap<String, Object>();
+        testConfig.put("TEST_NAME", "TC2_BasicP2P");
+        testConfig.put("P2P_QUEUE_AND_KEY_NAME", "tc2queue");
+        testConfig.put("P2P_NUM_MESSAGES", 50);
 
         Message[] reports = sequenceTest(testConfig);
 
@@ -44,5 +52,18 @@
 
         Assert.assertEquals("The requested number of messages were not sent.", 50, messagesSent);
         Assert.assertEquals("Sender and receiver messages sent did not match up.", messagesSent, messagesReceived);
+    }
+
+    /**
+     * Should provide a translation from the junit method name of a test to its test case name as defined in the
+     * interop testing specification. For example the method "testP2P" might map onto the interop test case name
+     * "TC2_BasicP2P".
+     *
+     * @param methodName The name of the JUnit test method.
+     * @return The name of the corresponding interop test case.
+     */
+    public String getTestCaseNameForTestMethod(String methodName)
+    {
+        return "TC2_BasicP2P";
     }
 }

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/InteropClientTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/InteropClientTestCase.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/InteropClientTestCase.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/InteropClientTestCase.java Tue May  8 05:04:37 2007
@@ -79,8 +79,10 @@
 
     /**
      * Performs the test case actions.
+     *
+     * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
      */
-    public void start();
+    public void start() throws JMSException;
 
     /**
      * Gets a report on the actions performed by the test case in its assigned role.

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/TestClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/TestClient.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/TestClient.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/TestClient.java Tue May  8 05:04:37 2007
@@ -21,10 +21,7 @@
 package org.apache.qpid.interop.testclient;
 
 import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 
 import javax.jms.*;
 import javax.naming.Context;
@@ -33,6 +30,9 @@
 
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.interop.testclient.testcases.TestCase1DummyRun;
+import org.apache.qpid.interop.testclient.testcases.TestCase2BasicP2P;
+import org.apache.qpid.interop.testclient.testcases.TestCase3BasicPubSub;
 import org.apache.qpid.util.ClasspathScanner;
 import org.apache.qpid.util.CommandLineParser;
 import org.apache.qpid.util.PropertiesUtils;
@@ -61,41 +61,53 @@
 {
     private static Logger log = Logger.getLogger(TestClient.class);
 
+    public static final String CONNECTION_PROPERTY = "connectionfactory.broker";
+    public static final String CONNECTION_NAME = "broker";
+    public static final String CLIENT_NAME = "java";
+    public static final String DEFAULT_CONNECTION_PROPS_RESOURCE = "org/apache/qpid/interop/connection.properties";
+
     /** Holds the URL of the broker to run the tests on. */
-    String brokerUrl;
+    public static String brokerUrl;
 
     /** Holds the virtual host to run the tests on. If <tt>null</tt>, then the default virtual host is used. */
-    String virtualHost;
+    public static String virtualHost;
 
     /** Holds all the test cases loaded from the classpath. */
     Map<String, InteropClientTestCase> testCases = new HashMap<String, InteropClientTestCase>();
 
     InteropClientTestCase currentTestCase;
 
-    public static final String CONNECTION_PROPERTY = "connectionfactory.broker";
-    public static final String CONNECTION_NAME = "broker";
-    public static final String CLIENT_NAME = "java";
-    public static final String DEFAULT_CONNECTION_PROPS_RESOURCE = "org/apache/qpid/interop/connection.properties";
-
     private MessageProducer producer;
     private Session session;
 
-    public TestClient(String brokerUrl, String virtualHost)
+    private String clientName = CLIENT_NAME;
+
+    /**
+     * Creates a new interop test client, listenting to the specified broker and virtual host, with the specified
+     * client identifying name.
+     *
+     * @param brokerUrl   The url of the broker to connect to.
+     * @param virtualHost The virtual host to conect to.
+     * @param clientName  The client name to use.
+     */
+    public TestClient(String brokerUrl, String virtualHost, String clientName)
     {
         log.debug("public TestClient(String brokerUrl = " + brokerUrl + ", String virtualHost = " + virtualHost
-                  + "): called");
+            + ", String clientName = " + clientName + "): called");
 
         // Retain the connection parameters.
         this.brokerUrl = brokerUrl;
         this.virtualHost = virtualHost;
+        this.clientName = clientName;
     }
 
     /**
      * The entry point for the interop test coordinator. This client accepts the following command line arguments:
      *
      * <p/><table>
-     * <tr><td> -b         <td> The broker URL.   <td> Mandatory.
-     * <tr><td> -h         <td> The virtual host. <td> Optional.
+     * <tr><td> -b         <td> The broker URL.       <td> Optional.
+     * <tr><td> -h         <td> The virtual host.     <td> Optional.
+     * <tr><td> -n         <td> The test client name. <td> Optional.
      * <tr><td> name=value <td> Trailing argument define name/value pairs. Added to system properties. <td> Optional.
      * </table>
      *
@@ -105,11 +117,13 @@
     {
         // Use the command line parser to evaluate the command line.
         CommandLineParser commandLine =
-            new CommandLineParser(new String[][]
-                                  {
-                                      { "b", "The broker URL.", "broker", "false" },
-                                      { "h", "The virtual host to use.", "virtual host", "false" }
-                                  });
+            new CommandLineParser(
+                new String[][]
+                {
+                    { "b", "The broker URL.", "broker", "false" },
+                    { "h", "The virtual host to use.", "virtual host", "false" },
+                    { "n", "The test client name.", "name", "false" }
+                });
 
         // Capture the command line arguments or display errors and correct usage and then exit.
         Properties options = null;
@@ -128,13 +142,14 @@
         // Extract the command line options.
         String brokerUrl = options.getProperty("b");
         String virtualHost = options.getProperty("h");
+        String clientName = options.getProperty("n");
 
         // Add all the trailing command line options (name=value pairs) to system properties. Tests may pick up
         // overridden values from there.
         commandLine.addCommandLineToSysProperties();
 
         // Create a test client and start it running.
-        TestClient client = new TestClient(brokerUrl, virtualHost);
+        TestClient client = new TestClient(brokerUrl, virtualHost, (clientName == null) ? CLIENT_NAME : clientName);
 
         try
         {
@@ -147,13 +162,22 @@
         }
     }
 
+    /**
+     * Starts the interop test client running. This causes it to start listening for incoming test invites.
+     *
+     * @throws JMSException Any underlying JMSExceptions are allowed to fall through.
+     */
     private void start() throws JMSException
     {
         log.debug("private void start(): called");
 
         // Use a class path scanner to find all the interop test case implementations.
         Collection<Class<? extends InteropClientTestCase>> testCaseClasses =
-            ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
+            new ArrayList<Class<? extends InteropClientTestCase>>();
+        // ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
+        // Hard code the test classes till the classpath scanner is fixed.
+        Collections.addAll(testCaseClasses,
+            new Class[] { TestCase1DummyRun.class, TestCase2BasicP2P.class, TestCase3BasicPubSub.class });
 
         // Create all the test case implementations and index them by the test names.
         for (Class<? extends InteropClientTestCase> nextClass : testCaseClasses)
@@ -181,9 +205,12 @@
         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         // Set this up to listen for control messages.
-        MessageConsumer consumer = session.createConsumer(session.createTopic("iop.control." + CLIENT_NAME));
+        MessageConsumer consumer = session.createConsumer(session.createTopic("iop.control." + clientName));
         consumer.setMessageListener(this);
 
+        MessageConsumer consumer2 = session.createConsumer(session.createTopic("iop.control"));
+        consumer2.setMessageListener(this);
+
         // Create a producer to send replies with.
         producer = session.createProducer(null);
 
@@ -209,13 +236,13 @@
     public static Connection createConnection(String connectionPropsResource, String brokerUrl, String virtualHost)
     {
         log.debug("public static Connection createConnection(String connectionPropsResource = " + connectionPropsResource
-                  + ", String brokerUrl = " + brokerUrl + ", String virtualHost = " + virtualHost + "): called");
+            + ", String brokerUrl = " + brokerUrl + ", String virtualHost = " + virtualHost + "): called");
 
         try
         {
             Properties connectionProps =
                 PropertiesUtils.getProperties(TestClient.class.getClassLoader().getResourceAsStream(
-                                                  connectionPropsResource));
+                        connectionPropsResource));
 
             if (brokerUrl != null)
             {
@@ -270,6 +297,8 @@
 
                 if (testCaseName != null)
                 {
+                    log.debug("Got an invite to test: " + testCaseName);
+
                     // Check if the requested test case is available.
                     InteropClientTestCase testCase = testCases.get(testCaseName);
 
@@ -282,6 +311,8 @@
                 }
                 else
                 {
+                    log.debug("Got a compulsory invite.");
+
                     enlist = true;
                 }
 
@@ -290,8 +321,8 @@
                     // Reply with the client name in an Enlist message.
                     Message enlistMessage = session.createMessage();
                     enlistMessage.setStringProperty("CONTROL_TYPE", "ENLIST");
-                    enlistMessage.setStringProperty("CLIENT_NAME", CLIENT_NAME);
-                    enlistMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + CLIENT_NAME);
+                    enlistMessage.setStringProperty("CLIENT_NAME", clientName);
+                    enlistMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
                     enlistMessage.setJMSCorrelationID(message.getJMSCorrelationID());
 
                     producer.send(message.getJMSReplyTo(), enlistMessage);
@@ -300,7 +331,10 @@
             else if ("ASSIGN_ROLE".equals(controlType))
             {
                 // Assign the role to the current test case.
-                String roleName = message.getStringProperty("");
+                String roleName = message.getStringProperty("ROLE");
+
+                log.debug("Got a role assignment to role: " + roleName);
+
                 InteropClientTestCase.Roles role = Enum.valueOf(InteropClientTestCase.Roles.class, roleName);
 
                 currentTestCase.assignRole(role, message);
@@ -316,9 +350,15 @@
             {
                 if ("START".equals(controlType))
                 {
+                    log.debug("Got a start notification.");
+
                     // Start the current test case.
                     currentTestCase.start();
                 }
+                else
+                {
+                    log.debug("Got a status request.");
+                }
 
                 // Generate the report from the test case and reply with it as a Report message.
                 Message reportMessage = currentTestCase.getReport(session);
@@ -327,10 +367,17 @@
 
                 producer.send(message.getJMSReplyTo(), reportMessage);
             }
+            else if ("TERMINATE".equals(controlType))
+            {
+                System.out.println("Received termination instruction from coordinator.");
+
+                // Is a cleaner shutdown needed?
+                System.exit(0);
+            }
             else
             {
                 // Log a warning about this but otherwise ignore it.
-                log.warn("Got an unknown control message: " + message);
+                log.warn("Got an unknown control message, controlType = " + controlType + ", message = " + message);
             }
         }
         catch (JMSException e)

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase1DummyRun.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase1DummyRun.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase1DummyRun.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase1DummyRun.java Tue May  8 05:04:37 2007
@@ -84,6 +84,8 @@
 
     public void onMessage(Message message)
     {
+        log.debug("public void onMessage(Message message = " + message + "): called");
+
         // Ignore any messages.
     }
 }

Modified: incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase2BasicP2P.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase2BasicP2P.java?view=diff&rev=536167&r1=536166&r2=536167
==============================================================================
--- incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase2BasicP2P.java (original)
+++ incubator/qpid/trunk/qpid/java/integrationtests/src/main/java/org/apache/qpid/interop/testclient/testcases/TestCase2BasicP2P.java Tue May  8 05:04:37 2007
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.interop.testclient.testcases;
 
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
+import javax.jms.*;
+
+import org.apache.log4j.Logger;
 
 import org.apache.qpid.interop.testclient.InteropClientTestCase;
+import org.apache.qpid.interop.testclient.TestClient;
 
 /**
  * Implements test case 2, basic P2P. Sends/received a specified number of messages to a specified route on the
@@ -41,6 +42,30 @@
  */
 public class TestCase2BasicP2P implements InteropClientTestCase
 {
+    /** Used for debugging. */
+    private static final Logger log = Logger.getLogger(TestCase2BasicP2P.class);
+
+    /** Holds the count of test messages received. */
+    private int messageCount;
+
+    /** The role to be played by the test. */
+    private Roles role;
+
+    /** The number of test messages to send. */
+    private int numMessages;
+
+    /** The routing key to send them to on the default direct exchange. */
+    private Destination sendDestination;
+
+    /** The connection to send the test messages on. */
+    private Connection connection;
+
+    /** The session to send the test messages on. */
+    private Session session;
+
+    /** The producer to send the test messages with. */
+    MessageProducer producer;
+
     /**
      * Should provide the name of the test case that this class implements. The exact names are defined in the
      * interop testing spec.
@@ -49,6 +74,8 @@
      */
     public String getName()
     {
+        log.debug("public String getName(): called");
+
         return "TC2_BasicP2P";
     }
 
@@ -63,6 +90,8 @@
      */
     public boolean acceptInvite(Message inviteMessage) throws JMSException
     {
+        log.debug("public boolean acceptInvite(Message inviteMessage = " + inviteMessage + "): called");
+
         // All invites are acceptable.
         return true;
     }
@@ -79,27 +108,65 @@
      */
     public void assignRole(Roles role, Message assignRoleMessage) throws JMSException
     {
+        log.debug("public void assignRole(Roles role = " + role + ", Message assignRoleMessage = " + assignRoleMessage
+            + "): called");
+
+        // Reset the message count for a new test.
+        messageCount = 0;
+
         // Take note of the role to be played.
+        this.role = role;
+
+        // Create a new connection to pass the test messages on.
+        connection =
+            TestClient.createConnection(TestClient.DEFAULT_CONNECTION_PROPS_RESOURCE, TestClient.brokerUrl,
+                TestClient.virtualHost);
+        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         // Extract and retain the test parameters.
+        numMessages = assignRoleMessage.getIntProperty("P2P_NUM_MESSAGES");
+        sendDestination = session.createQueue(assignRoleMessage.getStringProperty("P2P_QUEUE_AND_KEY_NAME"));
 
-        // Create a new connection to pass the test messages on.
+        log.debug("numMessages = " + numMessages);
+        log.debug("sendDestination = " + sendDestination);
+        log.debug("role = " + role);
 
-        // Check if the sender role is being assigned, and set up a message producer if so.
+        switch (role)
         {
-        }
+        // Check if the sender role is being assigned, and set up a message producer if so.
+        case SENDER:
+            producer = session.createProducer(sendDestination);
+            break;
+
         // Otherwise the receiver role is being assigned, so set this up to listen for messages.
-        {
+        case RECEIVER:
+            MessageConsumer consumer = session.createConsumer(sendDestination);
+            consumer.setMessageListener(this);
+            break;
         }
+
+        connection.start();
     }
 
     /**
      * Performs the test case actions.
      */
-    public void start()
+    public void start() throws JMSException
     {
+        log.debug("public void start(): called");
+
         // Check that the sender role is being performed.
+        if (role.equals(Roles.SENDER))
         {
+            Message testMessage = session.createTextMessage("test");
+
+            for (int i = 0; i < numMessages; i++)
+            {
+                producer.send(testMessage);
+
+                // Increment the message count.
+                messageCount++;
+            }
         }
     }
 
@@ -114,11 +181,17 @@
      */
     public Message getReport(Session session) throws JMSException
     {
+        log.debug("public Message getReport(Session session): called");
+
         // Close the test connection.
+        connection.close();
 
         // Generate a report message containing the count of the number of messages passed.
+        Message report = session.createMessage();
+        report.setStringProperty("CONTROL_TYPE", "REPORT");
+        report.setIntProperty("MESSAGE_COUNT", messageCount);
 
-        return null;
+        return report;
     }
 
     /**
@@ -128,6 +201,9 @@
      */
     public void onMessage(Message message)
     {
+        log.debug("public void onMessage(Message message = " + message + "): called");
+
         // Increment the message count.
+        messageCount++;
     }
 }