summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2012-02-29 23:47:22 +0000
committerRobert Godfrey <rgodfrey@apache.org>2012-02-29 23:47:22 +0000
commite7d54437156176ffac3b576749ec2e91bcd55abb (patch)
treeddfc9ae11c850a8591c0303d22fc160b7723dc98 /qpid/java/systests/src
parent3fb61f5354df0b77325e4fc88aa59213d3000a8e (diff)
downloadqpid-python-e7d54437156176ffac3b576749ec2e91bcd55abb.tar.gz
QPID-3605 : renamed method, corrected brace style for ifs, added tests (per Robbies review comments)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1295341 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests/src')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java65
1 files changed, 64 insertions, 1 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
index d5cbaaa203..9dfd3c912a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
@@ -42,7 +42,7 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
protected final String MY_TOPIC_SUBSCRIPTION_NAME = this.getName();
protected static final int SEND_COUNT = 10;
- public void test() throws Exception
+ public void testNoLocalNotQueued() throws Exception
{
if(!isBrokerStorePersistent())
{
@@ -73,6 +73,8 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
assertEquals("Normal Subscriber Received no messages",
SEND_COUNT, received.size());
session.commit();
+
+ normalSubscriber.close();
connection.close();
//We didn't receive the messages on the durable queue for the no-local subscriber
@@ -94,6 +96,67 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
session2.commit();
assertEquals("No Local Subscriber Received messages", 0, received.size());
+ noLocalSubscriber2.close();
+
+
+ }
+
+
+ public void testNonNoLocalQueued() throws Exception
+ {
+ if(!isBrokerStorePersistent())
+ {
+ fail("This test requires a broker with a persistent store");
+ }
+
+ Connection connection = getConnection();
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Topic topic = session.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
+
+ TopicSubscriber noLocalSubscriber =
+ session.createDurableSubscriber(topic, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal", null, true);
+
+
+ sendMessage(session, topic, SEND_COUNT);
+
+ // Check messages can be received as expected.
+ connection.start();
+
+ List<Message> received = receiveMessage(noLocalSubscriber, SEND_COUNT);
+ assertEquals("No Local Subscriber Received messages", 0, received.size());
+
+
+
+ session.commit();
+
+ Connection connection3 = getConnection();
+ Session session3 = connection3.createSession(true, Session.SESSION_TRANSACTED);
+ sendMessage(session3, topic, SEND_COUNT);
+
+
+ connection.close();
+
+ //We didn't receive the messages on the durable queue for the no-local subscriber
+ //so they are still on the broker. Restart the broker, prompting their recovery.
+ restartBroker();
+
+ Connection connection2 = getConnection();
+ connection2.start();
+
+ Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED);
+ Topic topic2 = session2.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
+
+ TopicSubscriber noLocalSubscriber2 =
+ session2.createDurableSubscriber(topic2, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal",null, true);
+
+ // The NO-local subscriber should receive messages sent from connection3
+ received = receiveMessage(noLocalSubscriber2, SEND_COUNT);
+ session2.commit();
+ assertEquals("No Local Subscriber did not receive expected messages", SEND_COUNT, received.size());
+
+ noLocalSubscriber2.close();
+
+
}
protected List<Message> receiveMessage(MessageConsumer messageConsumer,