From ec4c1d241cff98d690cb4031446815056b078d66 Mon Sep 17 00:00:00 2001 From: Rupert Smith Date: Fri, 13 Jul 2007 15:02:06 +0000 Subject: Completed javadoc for test framework. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@556024 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/exchange/ImmediateMessageTest.java | 30 ++++++++++++------ .../qpid/server/exchange/MandatoryMessageTest.java | 26 +++++++++++----- .../apache/qpid/test/framework/AssertionBase.java | 2 +- .../org/apache/qpid/test/framework/Circuit.java | 2 -- .../apache/qpid/test/framework/CircuitImpl.java | 31 +++++++++++-------- .../qpid/test/framework/ExceptionMonitor.java | 36 +++++++++++++++++++--- .../apache/qpid/test/framework/MessageMonitor.java | 12 +++++++- .../framework/MultiProducerConsumerPairImpl.java | 1 - .../org/apache/qpid/test/framework/Publisher.java | 7 +++++ .../apache/qpid/test/framework/PublisherImpl.java | 9 +++++- .../org/apache/qpid/test/framework/Receiver.java | 6 ++++ .../apache/qpid/test/framework/ReceiverImpl.java | 8 ++++- .../org/apache/qpid/test/framework/TestUtils.java | 5 ++- 13 files changed, 133 insertions(+), 42 deletions(-) (limited to 'java') diff --git a/java/systests/src/main/java/org/apache/qpid/server/exchange/ImmediateMessageTest.java b/java/systests/src/main/java/org/apache/qpid/server/exchange/ImmediateMessageTest.java index 7d6e7d044c..c2b7a2094f 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/exchange/ImmediateMessageTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/exchange/ImmediateMessageTest.java @@ -39,14 +39,24 @@ import uk.co.thebadgerset.junit.extensions.util.TestContextProperties; * Responsibilities Collaborations * Check that an immediate message is sent succesfully not using transactions when a consumer is connected. * Check that an immediate message is committed succesfully in a transaction when a consumer is connected. - * Check that an immediate message results in no consumers code, not using transactions, when no consumer is + * Check that an immediate message results in no consumers code, not using transactions, when a consumer is + * disconnected. + * Check that an immediate message results in no consumers code, in a transaction, when a consumer is + * disconnected. + * Check that an immediate message results in no route code, not using transactions, when no outgoing route is * connected. - * Check that an immediate message results in no consumers code, upon transaction commit, when a consumer is + * Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is * connected. + * Check that an immediate message is sent succesfully not using transactions when a consumer is connected. + * Check that an immediate message is committed succesfully in a transaction when a consumer is connected. * Check that an immediate message results in no consumers code, not using transactions, when a consumer is * disconnected. - *
Check that an immediate message results in no consumers code, in a transaction, when a consumer is + * Check that an immediate message results in no consumers code, in a transaction, when a consumer is * disconnected. + * Check that an immediate message results in no route code, not using transactions, when no outgoing route is + * connected. + * Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is + * connected. * * * @todo All of these test cases will be generated by a test generator that thoroughly tests all combinations of test @@ -115,7 +125,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noConsumersAssertion()))); } - /** Check that an immediate message results in no consumers code, not using transactions, when no consumer is connected. */ + /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */ public void test_QPID_517_ImmediateFailsNoRouteNoTxP2P() { // Ensure transactional sessions are off. @@ -128,11 +138,11 @@ public class ImmediateMessageTest extends FrameworkBaseCase Circuit testCircuit = CircuitImpl.createCircuit(testProps); - // Send one message and get a linked no consumers exception. + // Send one message and get a linked no route exception. assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noRouteAssertion()))); } - /** Check that an immediate message results in no consumers code, upon transaction commit, when a consumer is connected. */ + /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */ public void test_QPID_517_ImmediateFailsNoRouteTxP2P() { // Ensure transactional sessions are on. @@ -213,7 +223,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noConsumersAssertion()))); } - /** Check that an immediate message results in no consumers code, not using transactions, when no consumer is connected. */ + /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */ public void test_QPID_517_ImmediateFailsNoRouteNoTxPubSub() { // Ensure transactional sessions are off. @@ -226,11 +236,11 @@ public class ImmediateMessageTest extends FrameworkBaseCase Circuit testCircuit = CircuitImpl.createCircuit(testProps); - // Send one message and get a linked no consumers exception. + // Send one message and get a linked no route exception. assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noRouteAssertion()))); } - /** Check that an immediate message results in no consumers code, upon transaction commit, when a consumer is connected. */ + /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */ public void test_QPID_517_ImmediateFailsNoRouteTxPubSub() { // Ensure transactional sessions are on. @@ -243,7 +253,7 @@ public class ImmediateMessageTest extends FrameworkBaseCase Circuit testCircuit = CircuitImpl.createCircuit(testProps); - // Send one message and get a linked no consumers exception. + // Send one message and get a linked no route exception. assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noRouteAssertion()))); } diff --git a/java/systests/src/main/java/org/apache/qpid/server/exchange/MandatoryMessageTest.java b/java/systests/src/main/java/org/apache/qpid/server/exchange/MandatoryMessageTest.java index 75257cc508..1bfc97838c 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/exchange/MandatoryMessageTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/exchange/MandatoryMessageTest.java @@ -37,16 +37,26 @@ import uk.co.thebadgerset.junit.extensions.util.TestContextProperties; * *

*
Check that a mandatory message is send successfully, in a transactions, when a consumer is - * disconnected but when the route exists. *
CRC Card
Responsibilities Collaborations - *
Check that a mandatory message is sent succesfully not using transactions when a consumer is connected. - *
Check that a mandatory message is committed succesfully in a transaction when a consumer is connected. - *
Check that a mandatory message results in no route code, not using transactions, when no consumer is + *
Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. + *
Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. + *
Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected + * but the route exists. + *
Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but + * the route exists. + *
Check that an mandatory message results in no route code, not using transactions, when no consumer is * connected. - *
Check that a mandatory message results in no route code, upon transaction commit, when a consumer is + *
Check that an mandatory message results in no route code, upon transaction commit, when a consumer is + * connected. + *
Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. + *
Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. + *
Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected + * but the route exists. + *
Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but + * the route exists. + *
Check that an mandatory message results in no route code, not using transactions, when no consumer is + * connected. + *
Check that an mandatory message results in no route code, upon transaction commit, when a consumer is * connected. - *
Check that a mandatory message is sent succesfully, not using transactions, when a consumer is - * disconnected but the route exists. - *
* * @todo All of these test cases will be generated by a test generator that thoroughly tests all combinations of test diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java b/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java index e939b66c31..3d83224513 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/AssertionBase.java @@ -29,7 +29,7 @@ import java.util.List; * *

*
CRC Card
Responsibilities Collaborations - *
+ *
Collect error messages. *
*/ public abstract class AssertionBase implements Assertion diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java b/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java index 83a6d7279b..74c14ee6c5 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/Circuit.java @@ -20,8 +20,6 @@ */ package org.apache.qpid.test.framework; -import uk.co.thebadgerset.junit.extensions.util.ParsedProperties; - import java.util.List; /** diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitImpl.java index 936ac57a4b..70bd16353c 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitImpl.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitImpl.java @@ -34,15 +34,20 @@ import java.util.List; import java.util.concurrent.atomic.AtomicLong; /** + * CircuitImpl provides an implementation of the test circuit. This is a first prototype implementation and only supports + * a single producer/consumer on each end of the circuit, with both ends of the circuit on the same JVM. + * *

*
CRC Card
Responsibilities Collaborations *
Supply the publishing and receiving ends of a test messaging circuit. + * {@link PublisherImpl}, {@link ReceiverImpl} *
Start the circuit running. *
Close the circuit down. *
Take a reading of the circuits state. - *
Apply assertions against the circuits state. + *
Apply assertions against the circuits state. {@link Assertion} *
Send test messages over the circuit. - *
Perform the default test procedue on the circuit. + *
Perform the default test procedure on the circuit. + *
Provide access to connection and session exception monitors {@link ExceptionMonitor} *
*/ public class CircuitImpl implements Circuit @@ -246,7 +251,17 @@ public class CircuitImpl implements Circuit */ public List applyAssertions(List assertions) { - return null; + List failures = new LinkedList(); + + for (Assertion assertion : assertions) + { + if (!assertion.apply()) + { + failures.add(assertion); + } + } + + return failures; } /** @@ -331,15 +346,7 @@ public class CircuitImpl implements Circuit check(); // Apply all of the requested assertions, keeping record of any that fail. - List failures = new LinkedList(); - - for (Assertion assertion : assertions) - { - if (!assertion.apply()) - { - failures.add(assertion); - } - } + List failures = applyAssertions(assertions); // Clean up the publisher/receiver/session/connections. close(); diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java b/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java index 9f4e8b2142..606f2eabda 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java @@ -29,30 +29,55 @@ import java.util.ArrayList; import java.util.List; /** + * An exception monitor, listens for JMS exception on a connection or consumer. It record all exceptions that it receives + * and provides methods to test the number and type of exceptions received. + * *

-*
CRC Card
Responsibilities Collaborations -*
-*
-*/ + * Responsibilities Collaborations + * Record all exceptions received. {@link ExceptionListener} + * + */ public class ExceptionMonitor implements ExceptionListener { + /** Holds the received exceptions. */ List exceptions = new ArrayList(); + /** + * Receives incoming exceptions. + * + * @param e The exception to record. + */ public void onException(JMSException e) { exceptions.add(e); } + /** + * Checks that no exceptions have been received. + * + * @return true if no exceptions have been received, false otherwise. + */ public boolean assertNoExceptions() { return exceptions.isEmpty(); } + /** + * Checks that exactly one exception has been received. + * + * @return true if exactly one exception been received, false otherwise. + */ public boolean assertOneJMSException() { return exceptions.size() == 1; } + /** + * Checks that exactly one exception, with a linked cause of the specified type, has been received. + * + * @return true if exactly one exception, with a linked cause of the specified type, been received, + * false otherwise. + */ public boolean assertOneJMSExceptionWithLinkedCause(Class aClass) { if (exceptions.size() == 1) @@ -80,6 +105,9 @@ public class ExceptionMonitor implements ExceptionListener return exceptions.size(); } + /** + * Clears the record of received exceptions. + */ public void reset() { exceptions = new ArrayList(); diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java b/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java index 63ff99826b..873f876012 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java @@ -24,13 +24,23 @@ import javax.jms.Message; import javax.jms.MessageListener; /** + * MessageMonitor is used to record information about messages received. This will provide methods to check various + * properties, such as the type, number and content of messages received in order to verify the correct behaviour of + * tests. + * + *

At the moment this monitor does not do anything. + * *

*
CRC Card
Responsibilities Collaborations - *
*
*/ public class MessageMonitor implements MessageListener { + /** + * Handles received messages. Does Nothing. + * + * @param message The message. Ignored. + */ public void onMessage(Message message) { } } diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/MultiProducerConsumerPairImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/MultiProducerConsumerPairImpl.java index 55bf141f93..88617555d3 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/MultiProducerConsumerPairImpl.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/MultiProducerConsumerPairImpl.java @@ -28,7 +28,6 @@ import javax.jms.*; */ public class MultiProducerConsumerPairImpl implements CircuitEnd { - /** * Gets the message producer at this circuit end point. * diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java b/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java index eed2edfb5e..59aa9065dd 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/Publisher.java @@ -23,6 +23,13 @@ package org.apache.qpid.test.framework; /** * A Publisher is a {@link CircuitEnd} that represents one end of a test circuit. Its main purpose is to * provide assertions that can be applied to test the behaviour of the publisher. + * + *

+ *
CRC Card
Responsibilities + *
Provide assertion that the publisher received no exceptions. + *
Provide assertion that the publisher received a no consumers error code. + *
Provide assertion that the publisher received a no route error code. + *
*/ public interface Publisher extends CircuitEnd { diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/PublisherImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/PublisherImpl.java index 46427ce89f..48bb9187fb 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/PublisherImpl.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/PublisherImpl.java @@ -28,9 +28,16 @@ import javax.jms.MessageProducer; import javax.jms.Session; /** + * Provides an implementation of the {@link Publisher} interface that wraps a single message producer and consumer on + * a single session. + * *

*
CRC Card
Responsibilities Collaborations - *
+ *
Provide a message producer for sending messages. + *
Provide a message consumer for receiving messages. + *
Provide assertion that the publisher received no exceptions. + *
Provide assertion that the publisher received a no consumers error code. + *
Provide assertion that the publisher received a no route error code. *
*/ public class PublisherImpl extends CircuitEndBase implements Publisher diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java b/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java index 526537349a..a79e29ef67 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/Receiver.java @@ -23,6 +23,12 @@ package org.apache.qpid.test.framework; /** * A Receiver is a {@link CircuitEnd} that represents one end of a test circuit. Its main purpose is to * provide assertions that can be applied to test the behaviour of the receiver. + * + *

+ *
CRC Card
Responsibilities + *
Provide assertion that the receiver received no exceptions. + *
Provide assertion that the receiver received all test messages sent to it. + *
*/ public interface Receiver extends CircuitEnd { diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/ReceiverImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/ReceiverImpl.java index 5f0cb83e63..06ca8e8cc3 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/ReceiverImpl.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/ReceiverImpl.java @@ -25,9 +25,15 @@ import javax.jms.MessageProducer; import javax.jms.Session; /** + * Provides an implementation of the {@link Receiver} interface that wraps a single message producer and consumer on + * a single session. + * *

*
CRC Card
Responsibilities Collaborations - *
+ *
Provide a message producer for sending messages. + *
Provide a message consumer for receiving messages. + *
Provide assertion that the receiver received no exceptions. + *
Provide assertion that the receiver received all test messages sent to it. *
*/ public class ReceiverImpl extends CircuitEndBase implements Receiver diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java b/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java index 60dd4b0f5b..c3d68ce66c 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java @@ -32,9 +32,12 @@ import javax.naming.InitialContext; import javax.naming.NamingException; /** + * TestUtils provides static helper methods that are usefull for writing tests against QPid. + * *

*
CRC Card
Responsibilities Collaborations - *
+ *
Create connections from test properties. {@link MessagingTestConfigProperties} + *
Inject a short pause in a test. *
*/ public class TestUtils -- cgit v1.2.1