qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [07/11] qpid-jms git commit: add tests for refusing consumer link creation, make related producer tests look for more specific exception
Date Tue, 24 Feb 2015 16:00:08 GMT
add tests for refusing consumer link creation, make related producer tests look for more specific
exception


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/72e601e8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/72e601e8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/72e601e8

Branch: refs/heads/master
Commit: 72e601e867164401ae0de1608c5eeb05e8270f47
Parents: 159bfaa
Author: Robert Gemmell <robbie@apache.org>
Authored: Tue Feb 24 14:48:54 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Tue Feb 24 14:48:54 2015 +0000

----------------------------------------------------------------------
 .../jms/integration/SessionIntegrationTest.java | 46 +++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/72e601e8/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
index dad3ada..4144cb9 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
@@ -35,6 +35,7 @@ import java.io.IOException;
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.IllegalStateException;
+import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -156,6 +157,49 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
     }
 
     @Test(timeout = 5000)
+    public void testCreateConsumerFailsWhenLinkRefusedAndAttachResponseWriteIsNotDeferred()
throws Exception {
+        doCreateConsumerFailsWhenLinkRefusedTestImpl(false);
+    }
+
+    @Test(timeout = 5000)
+    public void testCreateConsumerFailsWhenLinkRefusedAndAttachResponseWriteIsDeferred()
throws Exception {
+        doCreateConsumerFailsWhenLinkRefusedTestImpl(true);
+    }
+
+    private void doCreateConsumerFailsWhenLinkRefusedTestImpl(boolean deferAttachResponseWrite)
throws Exception {
+        try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+            Connection connection = testFixture.establishConnecton(testPeer);
+            connection.start();
+
+            testPeer.expectBegin(true);
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            String topicName = "myTopic";
+            Topic dest = session.createTopic(topicName);
+
+            //Expect a link to a topic node, which we will then refuse
+            SourceMatcher targetMatcher = new SourceMatcher();
+            targetMatcher.withAddress(equalTo(topicName));
+            targetMatcher.withDynamic(equalTo(false));
+            targetMatcher.withDurable(equalTo(TerminusDurability.NONE));
+
+            testPeer.expectReceiverAttach(notNullValue(), targetMatcher, true, deferAttachResponseWrite);
+            //Expect the detach response to the test peer closing the consumer link after
refusal.
+            testPeer.expectDetach(true, false, false);
+
+            try {
+                //Create a consumer, expect it to throw exception due to the link-refusal
+                session.createConsumer(dest);
+                fail("Producer creation should have failed when link was refused");
+            } catch(InvalidDestinationException ide) {
+                //Expected
+            }
+
+            testPeer.waitForAllHandlersToComplete(1000);
+        }
+    }
+
+    @Test(timeout = 5000)
     public void testCreateTemporaryQueue() throws Exception {
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             Connection connection = testFixture.establishConnecton(testPeer);
@@ -680,7 +724,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
                 //Create a producer, expect it to throw exception due to the link-refusal
                 session.createProducer(dest);
                 fail("Producer creation should have failed when link was refused");
-            } catch(JMSException jmse) {
+            } catch(InvalidDestinationException ide) {
                 //Expected
             }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message