diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-10-22 16:15:32 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-10-22 16:15:32 +0000 |
| commit | 986ee740324aa89b1da7c046d661a1f58e80b36c (patch) | |
| tree | b73b4a92841839aa27ced6dee4bd24b60807c50b /java | |
| parent | a1a24ac03f4662eedd76e36b8665c97cc5752fc6 (diff) | |
| download | qpid-python-986ee740324aa89b1da7c046d661a1f58e80b36c.tar.gz | |
Updated PersitentStoreTest so that it has its own sendMessages that does not commit before returning, updated JavaDoc on QTC and PST to describe the contract of sendMessages
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@828770 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java | 78 | ||||
| -rw-r--r-- | java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java | 44 |
2 files changed, 101 insertions, 21 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java b/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java index ac07372c68..65127e50ec 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java @@ -21,14 +21,18 @@ package org.apache.qpid.server.store; +import org.apache.qpid.test.utils.QpidTestCase; + import javax.jms.Connection; +import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; - -import org.apache.qpid.test.utils.QpidTestCase; +import java.util.ArrayList; +import java.util.List; public class PersistentStoreTest extends QpidTestCase { @@ -48,14 +52,12 @@ public class PersistentStoreTest extends QpidTestCase _destination = _session.createQueue(getTestQueueName()); _consumer = _session.createConsumer(_destination); _consumer.close(); - + sendMessage(_session, _destination, NUM_MESSAGES); _session.commit(); } - - /** - * Checks that a new consumer on a new connection can get NUM_MESSAGES from _destination - */ + + /** Checks that a new consumer on a new connection can get NUM_MESSAGES from _destination */ private void checkMessages() throws Exception, JMSException { _con = getConnection(); @@ -65,11 +67,11 @@ public class PersistentStoreTest extends QpidTestCase for (int i = 0; i < NUM_MESSAGES; i++) { Message msg = _consumer.receive(RECEIVE_TIMEOUT); - assertNotNull("Message "+i+" not received", msg); + assertNotNull("Message " + i + " not received", msg); } assertNull("No more messages should be received", _consumer.receive(100)); } - + // /** // * starts the server, sends 100 messages, restarts the server and gets 100 messages back // * the test formerly referred to as BDB-Qpid-1 @@ -81,11 +83,11 @@ public class PersistentStoreTest extends QpidTestCase // checkMessages(); // } - - /** + /** * starts the server, sends 100 messages, nukes then starts the server and gets 100 messages back * the test formerly referred to as BDB-Qpid-2 - * @throws Exception + * + * @throws Exception */ public void testForcibleStartStop() throws Exception { @@ -106,11 +108,12 @@ public class PersistentStoreTest extends QpidTestCase // checkMessages(); // } - /** - * starts the server, sends 100 committed messages, 5 uncommited ones, + /** + * starts the server, sends 100 committed messages, 5 uncommited ones, * nukes and starts the server and gets 100 messages back * the test formerly referred to as BDB-Qpid-6 - * @throws Exception + * + * @throws Exception */ public void testForcibleStartStopMidTransaction() throws Exception { @@ -119,13 +122,14 @@ public class PersistentStoreTest extends QpidTestCase checkMessages(); } - /** - * starts the server, sends 100 committed messages, 5 uncommited ones, + /** + * starts the server, sends 100 committed messages, 5 uncommited ones, * restarts the client and gets 100 messages back. * the test formerly referred to as BDB-Qpid-7 - * + * * FIXME: is this a PersistentStoreTest? Seems more like a transaction test to me.. aidan - * @throws Exception + * + * @throws Exception */ public void testClientDeathMidTransaction() throws Exception { @@ -133,7 +137,7 @@ public class PersistentStoreTest extends QpidTestCase _con.close(); checkMessages(); } - + // /** // * starts the server, sends 50 committed messages, copies $QPID_WORK to a new location, // * sends 10 messages, stops the server, nukes the store, restores the copy, starts the server @@ -143,5 +147,37 @@ public class PersistentStoreTest extends QpidTestCase // { // -- removing as this will leave 100msgs on a queue // } - + + /** + * This test requires that we can send messages without commiting. + * QTC always commits the messages sent via sendMessages. + * + * @param session the session to use for sending + * @param destination where to send them to + * @param count no. of messages to send + * + * @return the sent messges + * + * @throws Exception + */ + @Override + public List<Message> sendMessage(Session session, Destination destination, + int count) throws Exception + { + List<Message> messages = new ArrayList<Message>(count); + + MessageProducer producer = session.createProducer(destination); + + for (int i = 0;i < (count); i++) + { + Message next = createNextMessage(session, i); + + producer.send(next); + + messages.add(next); + } + + return messages; + } + } diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java index 6c1b1c7b8d..b7ca40213a 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java +++ b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java @@ -1080,18 +1080,62 @@ public class QpidTestCase extends TestCase return count; } + /** + * Send messages to the given destination. + * + * If session is transacted then messages will be commited before returning + * + * @param session the session to use for sending + * @param destination where to send them to + * @param count no. of messages to send + * + * @return the sent messges + * + * @throws Exception + */ public List<Message> sendMessage(Session session, Destination destination, int count) throws Exception { return sendMessage(session, destination, count, 0, 0); } + /** + * Send messages to the given destination. + * + * If session is transacted then messages will be commited before returning + * + * @param session the session to use for sending + * @param destination where to send them to + * @param count no. of messages to send + * + * @param batchSize the batchSize in which to commit, 0 means no batching, + * but a single commit at the end + * @return the sent messgse + * + * @throws Exception + */ public List<Message> sendMessage(Session session, Destination destination, int count, int batchSize) throws Exception { return sendMessage(session, destination, count, 0, batchSize); } + /** + * Send messages to the given destination. + * + * If session is transacted then messages will be commited before returning + * + * @param session the session to use for sending + * @param destination where to send them to + * @param count no. of messages to send + * + * @param offset offset allows the INDEX value of the message to be adjusted. + * @param batchSize the batchSize in which to commit, 0 means no batching, + * but a single commit at the end + * @return the sent messgse + * + * @throws Exception + */ public List<Message> sendMessage(Session session, Destination destination, int count, int offset, int batchSize) throws Exception { |
