qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject qpid-jms git commit: NO-JIRA Adds test for ConnectionFactory setClientID when invalid
Date Wed, 07 Jun 2017 15:37:19 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 8a1a498c6 -> ef7241eaa


NO-JIRA Adds test for ConnectionFactory setClientID when invalid

Tests that an in-use client ID set on the ConnectionFactory instance
will result in an InvalidClientIDException being thrown from
createConnection an doesn't wait until connection start or setClientID. 

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

Branch: refs/heads/master
Commit: ef7241eaa8e6bba065701b03ced3cba11a3a303a
Parents: 8a1a498
Author: Timothy Bish <tabish121@gmail.com>
Authored: Wed Jun 7 11:37:01 2017 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Wed Jun 7 11:37:01 2017 -0400

----------------------------------------------------------------------
 .../FailedConnectionsIntegrationTest.java       | 33 ++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ef7241ea/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/FailedConnectionsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/FailedConnectionsIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/FailedConnectionsIntegrationTest.java
index c501cfa..fd5819c 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/FailedConnectionsIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/FailedConnectionsIntegrationTest.java
@@ -142,6 +142,39 @@ public class FailedConnectionsIntegrationTest extends QpidJmsTestCase
{
     }
 
     @Test(timeout = 20000)
+    public void testConnectionFactoryCreateConnectionWithInvalidClientIdThrowsICIDEWhenInvalidContainerHintPresent()
throws Exception {
+        try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+            final String remoteURI = "amqp://localhost:" + testPeer.getServerPort();
+
+            Map<Symbol, Object> errorInfo = new HashMap<Symbol, Object>();
+            errorInfo.put(AmqpSupport.INVALID_FIELD, AmqpSupport.CONTAINER_ID);
+
+            testPeer.rejectConnect(AmqpError.INVALID_FIELD, "Client ID already in use", errorInfo);
+
+            Connection connection = null;
+            try {
+                JmsConnectionFactory factory = new JmsConnectionFactory(remoteURI);
+
+                // Setting on factory prompts the open to fire on create as opposed to waiting
+                // for the setClientID method or the start method on Connection to be called.
+                factory.setClientID("in-use-client-id");
+
+                connection = factory.createConnection();
+
+                fail("Should have thrown InvalidClientIDException");
+            } catch (InvalidClientIDException e) {
+                // Expected
+            } finally {
+                if (connection != null) {
+                    connection.close();
+                }
+            }
+
+            testPeer.waitForAllHandlersToComplete(1000);
+        }
+    }
+
+    @Test(timeout = 20000)
     public void testConnectSecurityViolation() throws Exception {
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             testPeer.rejectConnect(AmqpError.UNAUTHORIZED_ACCESS, "Anonymous connections
not allowed", null);


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


Mime
View raw message