You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/10/28 16:41:14 UTC
svn commit: r830634 - in
/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid:
server/store/PersistentStoreTest.java test/utils/QpidTestCase.java
Author: ritchiem
Date: Wed Oct 28 15:41:14 2009
New Revision: 830634
URL: http://svn.apache.org/viewvc?rev=830634&view=rev
Log:
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
Modified:
qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java
qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java?rev=830634&r1=830633&r2=830634&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java Wed Oct 28 15:41:14 2009
@@ -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 @@
_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 @@
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 @@
// 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 @@
// 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 @@
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 @@
_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 @@
// {
// -- 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;
+ }
+
}
Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=830634&r1=830633&r2=830634&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java Wed Oct 28 15:41:14 2009
@@ -1080,18 +1080,62 @@
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
{
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org