From e7d54437156176ffac3b576749ec2e91bcd55abb Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Wed, 29 Feb 2012 23:47:22 +0000 Subject: 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 --- .../persistent/NoLocalAfterRecoveryTest.java | 65 +++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'qpid/java/systests') 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 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 receiveMessage(MessageConsumer messageConsumer, -- cgit v1.2.1