diff options
| author | Aidan Skinner <aidan@apache.org> | 2008-08-19 10:03:07 +0000 |
|---|---|---|
| committer | Aidan Skinner <aidan@apache.org> | 2008-08-19 10:03:07 +0000 |
| commit | 4de98efcdae4926ac062397cabeeed59a35beddd (patch) | |
| tree | 2d188d8e7744dd7bd7dc06ffc297dfaf9e0836d5 /java/systests | |
| parent | e4540065984e2a791a3869826e0c03d596fce7eb (diff) | |
| download | qpid-python-4de98efcdae4926ac062397cabeeed59a35beddd.tar.gz | |
QPID-1202: Rebind durable subscriptions if the arguments have changed
TopicExchange: take field arguments into account when determining if topic binding already exists when binding, but not for regular isBound().
DurableSubscriptionTest: add test case for QPID-1202
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@687010 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/systests')
| -rw-r--r-- | java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java index fe7b97a47d..03f380243e 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java @@ -348,6 +348,66 @@ public class DurableSubscriptionTest extends QpidTestCase session.unsubscribe("testDurableWithInvalidDestinationsub"); } + /** + * Tests QPID-1202 + * Creates a durable subscription with a selector, then changes that selector on resubscription + * @throws Exception + */ + public void testResubscribeWithChangedSelector() throws Exception + { + Connection conn = getConnection(); + conn.start(); + Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); + AMQTopic topic = new AMQTopic((AMQConnection) conn, "testResubscribeWithChangedSelector"); + MessageProducer producer = session.createProducer(topic); + + // Create durable subscriber that matches A + TopicSubscriber subA = session.createDurableSubscriber(topic, + "testResubscribeWithChangedSelector", + "Match = True", false); + + // Send 1 matching message and 1 non-matching message + sendMatchingAndNonMatchingMessage(session, producer); + + Message rMsg = subA.receive(1000); + assertNotNull(rMsg); + assertEquals("Content was wrong", + "testResubscribeWithChangedSelector1", + ((TextMessage) rMsg).getText()); + + rMsg = subA.receive(250); + assertNull(rMsg); + + // Disconnect subscriber + subA.close(); + + // Reconnect with new selector that matches B + TopicSubscriber subB = session.createDurableSubscriber(topic, + "testResubscribeWithChangedSelector","Match = False", false); + + + // Check messages are recieved properly + sendMatchingAndNonMatchingMessage(session, producer); + rMsg = subB.receive(1000); + assertNotNull(rMsg); + assertEquals("Content was wrong", + "testResubscribeWithChangedSelector2", + ((TextMessage) rMsg).getText()); + + rMsg = subB.receive(250); + assertNull(rMsg); + } + + private void sendMatchingAndNonMatchingMessage(Session session, MessageProducer producer) throws JMSException + { + TextMessage msg = session.createTextMessage("testResubscribeWithChangedSelector1"); + msg.setBooleanProperty("Match", true); + producer.send(msg); + msg = session.createTextMessage("testResubscribeWithChangedSelector2"); + msg.setBooleanProperty("Match", false); + producer.send(msg); + } + public static junit.framework.Test suite() { return new junit.framework.TestSuite(DurableSubscriptionTest.class); |
