summaryrefslogtreecommitdiff
path: root/java/integrationtests
diff options
context:
space:
mode:
authorRupert Smith <rupertlssmith@apache.org>2007-08-01 16:19:31 +0000
committerRupert Smith <rupertlssmith@apache.org>2007-08-01 16:19:31 +0000
commit6b54ebb02e87cc4cc0a7bcd1d9d820c463f76e7f (patch)
tree8d36febd23837f732c8c026abbdca5bcdcff7626 /java/integrationtests
parent326741e927301ccf036a3ec98718bc622ca9e435 (diff)
downloadqpid-python-6b54ebb02e87cc4cc0a7bcd1d9d820c463f76e7f.tar.gz
Extensive refactoring of the distributed test framework.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@561855 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/integrationtests')
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase1DummyRun.java12
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase2BasicP2P.java18
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase3BasicPubSub.java16
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/CircuitTestCase.java101
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase1DummyRun.java8
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase2BasicP2P.java8
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase3BasicPubSub.java8
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedClientTestCase.java13
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedTestCase.java8
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropClientTestCase.java101
-rw-r--r--java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java119
11 files changed, 138 insertions, 274 deletions
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase1DummyRun.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase1DummyRun.java
index b119d13a3d..45bbfcd148 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase1DummyRun.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase1DummyRun.java
@@ -22,7 +22,7 @@ package org.apache.qpid.interop.clienttestcases;
import org.apache.log4j.Logger;
-import org.apache.qpid.test.framework.distributedtesting.InteropClientTestCase;
+import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -41,7 +41,7 @@ import javax.jms.Session;
* <tr><td> Generate test reports.
* </table>
*/
-public class TestCase1DummyRun implements InteropClientTestCase
+public class TestCase1DummyRun implements TestClientControlledTest
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(TestCase1DummyRun.class);
@@ -94,8 +94,10 @@ public class TestCase1DummyRun implements InteropClientTestCase
/**
* Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
+ *
+ * @param numMessages The number of test messages to send.
*/
- public void start()
+ public void start(int numMessages)
{
log.debug("public void start(): called");
@@ -105,7 +107,7 @@ public class TestCase1DummyRun implements InteropClientTestCase
/**
* Gets a report on the actions performed by the test case in its assigned role.
*
- * @param session The session to create the report message in.
+ * @param session The controlSession to create the report message in.
*
* @return The report message.
*
@@ -113,7 +115,7 @@ public class TestCase1DummyRun implements InteropClientTestCase
*/
public Message getReport(Session session) throws JMSException
{
- log.debug("public Message getReport(Session session): called");
+ log.debug("public Message getReport(Session controlSession): called");
// Generate a dummy report, the coordinator expects a report but doesn't care what it is.
return session.createTextMessage("Dummy Run, Ok.");
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase2BasicP2P.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase2BasicP2P.java
index 080bd846ee..1d30ff7ca6 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase2BasicP2P.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase2BasicP2P.java
@@ -22,9 +22,9 @@ package org.apache.qpid.interop.clienttestcases;
import org.apache.log4j.Logger;
-import org.apache.qpid.test.framework.distributedtesting.InteropClientTestCase;
-import org.apache.qpid.test.framework.distributedtesting.TestClient;
import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.framework.distributedtesting.TestClient;
+import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
import javax.jms.*;
@@ -41,7 +41,7 @@ import javax.jms.*;
* <tr><td> Generate test reports.
* </table>
*/
-public class TestCase2BasicP2P implements InteropClientTestCase
+public class TestCase2BasicP2P implements TestClientControlledTest, MessageListener
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(TestCase2BasicP2P.class);
@@ -58,7 +58,7 @@ public class TestCase2BasicP2P implements InteropClientTestCase
/** The connection to send the test messages on. */
private Connection connection;
- /** The session to send the test messages on. */
+ /** The controlSession to send the test messages on. */
private Session session;
/** The producer to send the test messages with. */
@@ -147,9 +147,11 @@ public class TestCase2BasicP2P implements InteropClientTestCase
/**
* Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
*
+ * @param numMessages The number of test messages to send.
+ *
* @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
*/
- public void start() throws JMSException
+ public void start(int numMessages) throws JMSException
{
log.debug("public void start(): called");
@@ -158,7 +160,7 @@ public class TestCase2BasicP2P implements InteropClientTestCase
{
Message testMessage = session.createTextMessage("test");
- for (int i = 0; i < numMessages; i++)
+ for (int i = 0; i < this.numMessages; i++)
{
producer.send(testMessage);
@@ -171,7 +173,7 @@ public class TestCase2BasicP2P implements InteropClientTestCase
/**
* Gets a report on the actions performed by the test case in its assigned role.
*
- * @param session The session to create the report message in.
+ * @param session The controlSession to create the report message in.
*
* @return The report message.
*
@@ -179,7 +181,7 @@ public class TestCase2BasicP2P implements InteropClientTestCase
*/
public Message getReport(Session session) throws JMSException
{
- log.debug("public Message getReport(Session session): called");
+ log.debug("public Message getReport(Session controlSession): called");
// Close the test connection.
connection.close();
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase3BasicPubSub.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase3BasicPubSub.java
index a11d045e89..622ddc2f64 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase3BasicPubSub.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/interop/clienttestcases/TestCase3BasicPubSub.java
@@ -22,9 +22,9 @@ package org.apache.qpid.interop.clienttestcases;
import org.apache.log4j.Logger;
-import org.apache.qpid.test.framework.distributedtesting.InteropClientTestCase;
-import org.apache.qpid.test.framework.distributedtesting.TestClient;
import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.framework.distributedtesting.TestClient;
+import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
import javax.jms.*;
@@ -42,7 +42,7 @@ import javax.jms.*;
* <tr><td> Generate test reports.
* </table>
*/
-public class TestCase3BasicPubSub implements InteropClientTestCase
+public class TestCase3BasicPubSub implements TestClientControlledTest, MessageListener
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(TestCase3BasicPubSub.class);
@@ -174,9 +174,11 @@ public class TestCase3BasicPubSub implements InteropClientTestCase
/**
* Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
*
+ * @param numMessages The number of test messages to send.
+ *
* @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
*/
- public void start() throws JMSException
+ public void start(int numMessages) throws JMSException
{
log.debug("public void start(): called");
@@ -185,7 +187,7 @@ public class TestCase3BasicPubSub implements InteropClientTestCase
{
Message testMessage = session[0].createTextMessage("test");
- for (int i = 0; i < numMessages; i++)
+ for (int i = 0; i < this.numMessages; i++)
{
producer.send(testMessage);
@@ -198,7 +200,7 @@ public class TestCase3BasicPubSub implements InteropClientTestCase
/**
* Gets a report on the actions performed by the test case in its assigned role.
*
- * @param session The session to create the report message in.
+ * @param session The controlSession to create the report message in.
*
* @return The report message.
*
@@ -206,7 +208,7 @@ public class TestCase3BasicPubSub implements InteropClientTestCase
*/
public Message getReport(Session session) throws JMSException
{
- log.debug("public Message getReport(Session session): called");
+ log.debug("public Message getReport(Session controlSession): called");
// Close the test connections.
for (Connection conn : connection)
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/CircuitTestCase.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/CircuitTestCase.java
deleted file mode 100644
index 966a545e16..0000000000
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/CircuitTestCase.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.interop.testcases;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.test.framework.sequencers.TestCaseSequencer;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-
-import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
-import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
-
-/**
- * CircuitTestCase runs a test over a {@link Circuit} controlled by the test parameters.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
- * </table>
- *
- * @todo When working with test context properties, add overrides to defaults to the singleton instance, but when taking
- * a starting point to add specific test case parameters to, take a copy. Use the copy with test case specifics
- * to control the test.
- */
-public class CircuitTestCase extends FrameworkBaseCase
-{
- /** Used for debugging. */
- private static final Logger log = Logger.getLogger(CircuitTestCase.class);
-
- /**
- * Creates a new test case with the specified name.
- *
- * @param name The test case name.
- */
- public CircuitTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Performs the a basic P2P test case.
- *
- * @throws Exception Any exceptions are allowed to fall through and fail the test.
- */
- public void testBasicP2P() throws Exception
- {
- log.debug("public void testBasicP2P(): called");
-
- // Get the test parameters, any overrides on the command line will have been applied.
- ParsedProperties testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
-
- // Customize the test parameters.
- testProps.setProperty("TEST_NAME", "DEFAULT_CIRCUIT_TEST");
- testProps.setProperty(MessagingTestConfigProperties.SEND_DESTINATION_NAME_ROOT_PROPNAME, "testqueue");
-
- // Get the test sequencer to create test circuits and run the standard test procedure through.
- TestCaseSequencer sequencer = getTestSequencer();
-
- // Send the test messages, and check that there were no errors doing so.
- Circuit testCircuit = sequencer.createCircuit(testProps);
- sequencer.sequenceTest(testCircuit, assertionList(testCircuit.getPublisher().noExceptionsAssertion()), testProps);
-
- // Check that all of the message were sent.
- // Check that the receiving end got the same number of messages as the publishing end.
- }
-
- /**
- * Should provide a translation from the junit method name of a test to its test case name as known to the test
- * clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test
- * case name to place into the test invite. 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 "DEFAULT_CIRCUIT_TEST";
- }
-}
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase1DummyRun.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase1DummyRun.java
index 73e08b578e..60cd9f47f3 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase1DummyRun.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase1DummyRun.java
@@ -22,7 +22,7 @@ package org.apache.qpid.interop.testcases;
import org.apache.log4j.Logger;
-import org.apache.qpid.test.framework.distributedtesting.DistributedTestCase;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
import java.util.Properties;
@@ -33,10 +33,10 @@ import java.util.Properties;
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
* <tr><td> Exercises the interop testing framework without actually sending any test messages.
- * <td> {@link org.apache.qpid.test.framework.distributedtesting.DistributedTestCase}
+ * <td> {@link FrameworkBaseCase}
* </table>
*/
-public class InteropTestCase1DummyRun extends DistributedTestCase
+public class InteropTestCase1DummyRun extends FrameworkBaseCase
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(InteropTestCase1DummyRun.class);
@@ -63,7 +63,7 @@ public class InteropTestCase1DummyRun extends DistributedTestCase
Properties testConfig = new Properties();
testConfig.put("TEST_NAME", "TC1_DummyRun");
- /*Message[] reports =*/ getTestSequencer().sequenceTest(null, null, testConfig);
+ /*Message[] reports =*/ getCircuitFactory().sequenceTest(null, null, testConfig);
// Compare sender and receivers reports.
// Assert.assertEquals("Expected to get 2 dummy reports.", 2, reports.length);
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase2BasicP2P.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase2BasicP2P.java
index f77bbf032f..8983249daa 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase2BasicP2P.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase2BasicP2P.java
@@ -22,7 +22,7 @@ package org.apache.qpid.interop.testcases;
import org.apache.log4j.Logger;
-import org.apache.qpid.test.framework.distributedtesting.DistributedTestCase;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
import java.util.Properties;
@@ -33,10 +33,10 @@ import java.util.Properties;
*
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Setup p2p test parameters and compare with test output. <td> {@link DistributedTestCase}
+ * <tr><td> Setup p2p test parameters and compare with test output. <td> {@link FrameworkBaseCase}
* </table>
*/
-public class InteropTestCase2BasicP2P extends DistributedTestCase
+public class InteropTestCase2BasicP2P extends FrameworkBaseCase
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(InteropTestCase2BasicP2P.class);
@@ -65,7 +65,7 @@ public class InteropTestCase2BasicP2P extends DistributedTestCase
testConfig.setProperty("P2P_QUEUE_AND_KEY_NAME", "tc2queue");
testConfig.put("P2P_NUM_MESSAGES", 50);
- /*Message[] reports =*/ getTestSequencer().sequenceTest(null, null, testConfig);
+ /*Message[] reports =*/ getCircuitFactory().sequenceTest(null, null, testConfig);
// Compare sender and receivers reports.
/*int messagesSent = reports[0].getIntProperty("MESSAGE_COUNT");
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase3BasicPubSub.java b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase3BasicPubSub.java
index ad27ca63bd..6e87c3e3ee 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase3BasicPubSub.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/interop/testcases/InteropTestCase3BasicPubSub.java
@@ -22,17 +22,17 @@ package org.apache.qpid.interop.testcases;
import org.apache.log4j.Logger;
-import org.apache.qpid.test.framework.distributedtesting.DistributedTestCase;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
import java.util.Properties;
/**
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Setup pub/sub test parameters and compare with test output. <td> {@link DistributedTestCase}
+ * <tr><td> Setup pub/sub test parameters and compare with test output. <td> {@link FrameworkBaseCase}
* </table>
*/
-public class InteropTestCase3BasicPubSub extends DistributedTestCase
+public class InteropTestCase3BasicPubSub extends FrameworkBaseCase
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(InteropTestCase3BasicPubSub.class);
@@ -62,7 +62,7 @@ public class InteropTestCase3BasicPubSub extends DistributedTestCase
testConfig.put("PUBSUB_NUM_MESSAGES", 10);
testConfig.put("PUBSUB_NUM_RECEIVERS", 5);
- /*Message[] reports =*/ getTestSequencer().sequenceTest(null, null, testConfig);
+ /*Message[] reports =*/ getCircuitFactory().sequenceTest(null, null, testConfig);
// Compare sender and receivers reports.
/*int messagesSent = reports[0].getIntProperty("MESSAGE_COUNT");
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedClientTestCase.java b/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedClientTestCase.java
index 65e05fab4b..2764f2c3aa 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedClientTestCase.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedClientTestCase.java
@@ -57,7 +57,7 @@ import java.util.concurrent.CountDownLatch;
* <tr><td> Send required number of test messages using pub/sub. <tr><td> Generate test reports.
* </table>
*/
-public class SustainedClientTestCase extends TestCase3BasicPubSub implements ExceptionListener
+public class SustainedClientTestCase extends TestCase3BasicPubSub implements ExceptionListener, MessageListener
{
/** Used for debugging. */
private static final Logger log = Logger.getLogger(SustainedClientTestCase.class);
@@ -205,8 +205,9 @@ public class SustainedClientTestCase extends TestCase3BasicPubSub implements Exc
}
}
- /** Performs the test case actions. */
- public void start() throws JMSException
+ /** Performs the test case actions.
+ * @param numMessages*/
+ public void start(int numMessages) throws JMSException
{
log.debug("public void start(): called");
@@ -235,7 +236,7 @@ public class SustainedClientTestCase extends TestCase3BasicPubSub implements Exc
/**
* Gets a report on the actions performed by the test case in its assigned role.
*
- * @param session The session to create the report message in.
+ * @param session The controlSession to create the report message in.
*
* @return The report message.
*
@@ -243,7 +244,7 @@ public class SustainedClientTestCase extends TestCase3BasicPubSub implements Exc
*/
public Message getReport(Session session) throws JMSException
{
- log.debug("public Message getReport(Session session): called");
+ log.debug("public Message getReport(Session controlSession): called");
// Close the test connections.
for (int i = 0; i < connection.length; i++)
@@ -318,7 +319,7 @@ public class SustainedClientTestCase extends TestCase3BasicPubSub implements Exc
* @param clientname The _client id used to identify this connection.
* @param batchSize The number of messages that are to be sent per batch. Note: This is not used to
* control the interval between sending reports.
- * @param session The session used for communication.
+ * @param session The controlSession used for communication.
* @param sendDestination The destination that update reports should be sent to.
*
* @throws JMSException My occur if creatingthe Producer fails
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedTestCase.java b/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedTestCase.java
index 36f9b4eaf1..5979a459ec 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedTestCase.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedTestCase.java
@@ -23,8 +23,8 @@ package org.apache.qpid.sustained;
import org.apache.log4j.Logger;
import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.framework.distributedtesting.DistributedTestCase;
import org.apache.qpid.test.framework.DropInTest;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -32,7 +32,7 @@ import javax.jms.Message;
import java.util.Properties;
/**
- * SustainedTestCase is a {@link org.apache.qpid.test.framework.distributedtesting.DistributedTestCase} that runs the "Perf_SustainedPubSub" test case. This consists of one
+ * SustainedTestCase is a {@link FrameworkBaseCase} that runs the "Perf_SustainedPubSub" test case. This consists of one
* test client sending, and several receiving, and attempts to find the highest rate at which messages can be broadcast
* to the receivers. It is also a {@link DropInTest} to which more test clients may be added during a test run.
*
@@ -41,7 +41,7 @@ import java.util.Properties;
* <tr><td>
* </table>
*/
-public class SustainedTestCase extends DistributedTestCase implements DropInTest
+public class SustainedTestCase extends FrameworkBaseCase implements DropInTest
{
/** Used for debugging. */
Logger log = Logger.getLogger(SustainedTestCase.class);
@@ -78,7 +78,7 @@ public class SustainedTestCase extends DistributedTestCase implements DropInTest
log.info("Created Config: " + testConfig.entrySet().toArray());
- getTestSequencer().sequenceTest(null, null, testConfig);
+ getCircuitFactory().sequenceTest(null, null, testConfig);
}
/**
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropClientTestCase.java b/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropClientTestCase.java
deleted file mode 100644
index 5e6d61a9e0..0000000000
--- a/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropClientTestCase.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.test.framework.distributedtesting;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-
-/**
- * InteropClientTestCase provides an interface that classes implementing test cases from the interop testing spec
- * (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification) should implement. Implementations
- * must be Java beans, that is, to provide a default constructor and to implement the {@link #getName} method.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Supply the name of the test case that this implements.
- * <tr><td> Accept/Reject invites based on test parameters.
- * <tr><td> Adapt to assigned roles.
- * <tr><td> Perform test case actions.
- * <tr><td> Generate test reports.
- * </table>
- */
-public interface InteropClientTestCase extends MessageListener
-{
- /** Defines the possible test case roles that an interop test case can take on. */
- public enum Roles
- {
- /** Specifies the sender role. */
- SENDER,
-
- /** Specifies the receivers role. */
- RECEIVER
- }
-
- /**
- * Should provide the name of the test case that this class implements. The exact names are defined in the
- * interop testing spec.
- *
- * @return The name of the test case that this implements.
- */
- public String getName();
-
- /**
- * Determines whether the test invite that matched this test case is acceptable.
- *
- * @param inviteMessage The invitation to accept or reject.
- *
- * @return <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public boolean acceptInvite(Message inviteMessage) 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.
- *
- * @param role The role to be played; sender or receivers.
- * @param assignRoleMessage The role assingment message, contains the full test parameters.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public void assignRole(Roles role, Message assignRoleMessage) throws JMSException;
-
- /**
- * Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
- *
- * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- */
- public void start() throws JMSException;
-
- /**
- * Gets a report on the actions performed by the test case in its assigned role.
- *
- * @param session The session to create the report message in.
- *
- * @return The report message.
- *
- * @throws JMSException Any JMSExceptions resulting from creating the report are allowed to fall through.
- */
- public Message getReport(Session session) throws JMSException;
-}
diff --git a/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java b/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
index 12c0d0aa69..6e726c53bb 100644
--- a/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
+++ b/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
@@ -21,6 +21,7 @@
package org.apache.qpid.test.framework.distributedtesting;
import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
import org.apache.qpid.interop.clienttestcases.TestCase1DummyRun;
import org.apache.qpid.interop.clienttestcases.TestCase2BasicP2P;
@@ -28,17 +29,14 @@ import org.apache.qpid.interop.clienttestcases.TestCase3BasicPubSub;
import org.apache.qpid.sustained.SustainedClientTestCase;
import org.apache.qpid.test.framework.MessagingTestConfigProperties;
import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.framework.distributedcircuit.TestClientCircuitEnd;
import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
import javax.jms.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
/**
* Implements a test client as described in the interop testing spec
@@ -57,8 +55,8 @@ import java.util.Map;
*
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Handle all incoming control messages. <td> {@link InteropClientTestCase}
- * <tr><td> Configure and look up test cases by name. <td> {@link InteropClientTestCase}
+ * <tr><td> Handle all incoming control messages. <td> {@link TestClientControlledTest}
+ * <tr><td> Configure and look up test cases by name. <td> {@link TestClientControlledTest}
* </table>
*/
public class TestClient implements MessageListener
@@ -86,10 +84,10 @@ public class TestClient implements MessageListener
TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
/** Holds all the test cases loaded from the classpath. */
- Map<String, InteropClientTestCase> testCases = new HashMap<String, InteropClientTestCase>();
+ Map<String, TestClientControlledTest> testCases = new HashMap<String, TestClientControlledTest>();
/** Holds the test case currently being run by this client. */
- protected InteropClientTestCase currentTestCase;
+ protected TestClientControlledTest currentTestCase;
/** Holds the connection to the broker that the test is being coordinated on. */
protected Connection connection;
@@ -97,7 +95,7 @@ public class TestClient implements MessageListener
/** Holds the message producer to hold the test coordination over. */
protected MessageProducer producer;
- /** Holds the JMS session for the test coordination. */
+ /** Holds the JMS controlSession for the test coordination. */
protected Session session;
/** Holds the name of this client, with a default value. */
@@ -113,11 +111,12 @@ public class TestClient implements MessageListener
* @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.
+ * @param join Flag to indicate that this client should attempt to join running tests.
*/
public TestClient(String brokerUrl, String virtualHost, String clientName, boolean join)
{
- log.debug("public SustainedTestClient(String brokerUrl = " + brokerUrl + ", String virtualHost = " + virtualHost
- + ", String clientName = " + clientName + "): called");
+ log.debug("public TestClient(String brokerUrl = " + brokerUrl + ", String virtualHost = " + virtualHost
+ + ", String clientName = " + clientName + ", boolean join = " + join + "): called");
// Retain the connection parameters.
this.brokerUrl = brokerUrl;
@@ -140,6 +139,9 @@ public class TestClient implements MessageListener
*/
public static void main(String[] args)
{
+ log.debug("public static void main(String[] args = " + Arrays.toString(args) + "): called");
+ console.info("Qpid Distributed Test Client.");
+
// Override the default broker url to be localhost:5672.
testContextProperties.setProperty(MessagingTestConfigProperties.BROKER_PROPNAME, "tcp://localhost:5672");
@@ -163,18 +165,22 @@ public class TestClient implements MessageListener
String brokerUrl = options.getProperty("b");
String virtualHost = options.getProperty("h");
String clientName = options.getProperty("n");
+ clientName = (clientName == null) ? CLIENT_NAME : clientName;
boolean join = options.getPropertyAsBoolean("j");
+ // To distinguish logging output set up an NDC on the client name.
+ NDC.push(clientName);
+
// Create a test client and start it running.
- TestClient client = new TestClient(brokerUrl, virtualHost, (clientName == null) ? CLIENT_NAME : clientName, join);
+ TestClient client = new TestClient(brokerUrl, virtualHost, clientName, join);
// Use a class path scanner to find all the interop test case implementations.
// Hard code the test classes till the classpath scanner is fixed.
- Collection<Class<? extends InteropClientTestCase>> testCaseClasses =
- new ArrayList<Class<? extends InteropClientTestCase>>();
- // ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
+ Collection<Class<? extends TestClientControlledTest>> testCaseClasses =
+ new ArrayList<Class<? extends TestClientControlledTest>>();
+ // ClasspathScanner.getMatches(TestClientControlledTest.class, "^TestCase.*", true);
Collections.addAll(testCaseClasses, TestCase1DummyRun.class, TestCase2BasicP2P.class, TestCase3BasicPubSub.class,
- SustainedClientTestCase.class);
+ SustainedClientTestCase.class, TestClientCircuitEnd.class);
try
{
@@ -183,6 +189,7 @@ public class TestClient implements MessageListener
catch (Exception e)
{
log.error("The test client was unable to start.", e);
+ console.info(e.getMessage());
System.exit(1);
}
}
@@ -195,16 +202,17 @@ public class TestClient implements MessageListener
*
* @throws JMSException Any underlying JMSExceptions are allowed to fall through.
*/
- protected void start(Collection<Class<? extends InteropClientTestCase>> testCaseClasses) throws JMSException
+ protected void start(Collection<Class<? extends TestClientControlledTest>> testCaseClasses) throws JMSException
{
- log.debug("private void start(): called");
+ log.debug("protected void start(Collection<Class<? extends TestClientControlledTest>> testCaseClasses = "
+ + testCaseClasses + "): called");
// Create all the test case implementations and index them by the test names.
- for (Class<? extends InteropClientTestCase> nextClass : testCaseClasses)
+ for (Class<? extends TestClientControlledTest> nextClass : testCaseClasses)
{
try
{
- InteropClientTestCase testCase = nextClass.newInstance();
+ TestClientControlledTest testCase = nextClass.newInstance();
testCases.put(testCase.getName(), testCase);
}
catch (InstantiationException e)
@@ -259,6 +267,7 @@ public class TestClient implements MessageListener
*/
public void onMessage(Message message)
{
+ NDC.push(clientName);
log.debug("public void onMessage(Message message = " + message + "): called");
try
@@ -266,7 +275,7 @@ public class TestClient implements MessageListener
String controlType = message.getStringProperty("CONTROL_TYPE");
String testName = message.getStringProperty("TEST_NAME");
- log.info("onMessage(Message message = " + message + "): for '" + controlType + "' to '" + testName + "'");
+ log.debug("Received control of type '" + controlType + "' for the test '" + testName + "'");
// Check if the message is a test invite.
if ("INVITE".equals(controlType))
@@ -280,13 +289,21 @@ public class TestClient implements MessageListener
log.debug("Got an invite to test: " + testName);
// Check if the requested test case is available.
- InteropClientTestCase testCase = testCases.get(testName);
+ TestClientControlledTest testCase = testCases.get(testName);
if (testCase != null)
{
+ log.debug("Found implementing class for test '" + testName + "', enlisting for it.");
+
+ // Check if the test case will accept the invitation.
+ enlist = testCase.acceptInvite(message);
+
+ log.debug("The test case "
+ + (enlist ? " accepted the invite, enlisting for it."
+ : " did not accept the invite, not enlisting."));
+
// Make the requested test case the current test case.
currentTestCase = testCase;
- enlist = true;
}
else
{
@@ -295,7 +312,7 @@ public class TestClient implements MessageListener
}
else
{
- log.debug("Got a compulsory invite.");
+ log.debug("Got a compulsory invite, enlisting for it.");
enlist = true;
}
@@ -309,7 +326,20 @@ public class TestClient implements MessageListener
enlistMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
enlistMessage.setJMSCorrelationID(message.getJMSCorrelationID());
- log.info("Sending Message '" + enlistMessage + "'. to " + message.getJMSReplyTo());
+ log.debug("Sending enlist message '" + enlistMessage + "' to " + message.getJMSReplyTo());
+
+ producer.send(message.getJMSReplyTo(), enlistMessage);
+ }
+ else
+ {
+ // Reply with the client name in an Decline message.
+ Message enlistMessage = session.createMessage();
+ enlistMessage.setStringProperty("CONTROL_TYPE", "DECLINE");
+ enlistMessage.setStringProperty("CLIENT_NAME", clientName);
+ enlistMessage.setStringProperty("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
+ enlistMessage.setJMSCorrelationID(message.getJMSCorrelationID());
+
+ log.debug("Sending decline message '" + enlistMessage + "' to " + message.getJMSReplyTo());
producer.send(message.getJMSReplyTo(), enlistMessage);
}
@@ -321,15 +351,18 @@ public class TestClient implements MessageListener
log.debug("Got a role assignment to role: " + roleName);
- InteropClientTestCase.Roles role = Enum.valueOf(InteropClientTestCase.Roles.class, roleName);
+ TestClientControlledTest.Roles role = Enum.valueOf(TestClientControlledTest.Roles.class, roleName);
currentTestCase.assignRole(role, message);
// Reply by accepting the role in an Accept Role message.
Message acceptRoleMessage = session.createMessage();
+ acceptRoleMessage.setStringProperty("CLIENT_NAME", clientName);
acceptRoleMessage.setStringProperty("CONTROL_TYPE", "ACCEPT_ROLE");
acceptRoleMessage.setJMSCorrelationID(message.getJMSCorrelationID());
+ log.debug("Sending accept role message '" + acceptRoleMessage + "' to " + message.getJMSReplyTo());
+
producer.send(message.getJMSReplyTo(), acceptRoleMessage);
}
else if ("START".equals(controlType) || "STATUS_REQUEST".equals(controlType))
@@ -338,8 +371,21 @@ public class TestClient implements MessageListener
{
log.debug("Got a start notification.");
+ // Extract the number of test messages to send from the start notification.
+ int numMessages;
+
+ try
+ {
+ numMessages = message.getIntProperty("MESSAGE_COUNT");
+ }
+ catch (JMSException e)
+ {
+ // If the number of messages is not specified, use the default of one.
+ numMessages = 1;
+ }
+
// Start the current test case.
- currentTestCase.start();
+ currentTestCase.start(numMessages);
}
else
{
@@ -348,9 +394,12 @@ public class TestClient implements MessageListener
// Generate the report from the test case and reply with it as a Report message.
Message reportMessage = currentTestCase.getReport(session);
+ reportMessage.setStringProperty("CLIENT_NAME", clientName);
reportMessage.setStringProperty("CONTROL_TYPE", "REPORT");
reportMessage.setJMSCorrelationID(message.getJMSCorrelationID());
+ log.debug("Sending report message '" + reportMessage + "' to " + message.getJMSReplyTo());
+
producer.send(message.getJMSReplyTo(), reportMessage);
}
else if ("TERMINATE".equals(controlType))
@@ -370,8 +419,18 @@ public class TestClient implements MessageListener
catch (JMSException e)
{
// Log a warning about this, but otherwise ignore it.
- log.warn("A JMSException occurred whilst handling a message.");
- log.debug("Got JMSException whilst handling message: " + message, e);
+ log.warn("Got JMSException whilst handling message: " + message, e);
+ }
+ // Log any runtimes that fall through this message handler. These are fatal errors for the test client.
+ catch (RuntimeException e)
+ {
+ log.error("The test client message handler got an unhandled exception: ", e);
+ console.info("The message handler got an unhandled exception, terminating the test client.");
+ System.exit(1);
+ }
+ finally
+ {
+ NDC.pop();
}
}
}