You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2016/05/25 22:19:01 UTC

qpid-jms git commit: NO-JIRA Add some additional tests for coverage.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 19128a577 -> e153f205e


NO-JIRA Add some additional tests for coverage.

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

Branch: refs/heads/master
Commit: e153f205e73ba746c1e68b2c433d70684f6a314d
Parents: 19128a5
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed May 25 18:18:52 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed May 25 18:18:52 2016 -0400

----------------------------------------------------------------------
 .../qpid/jms/JmsConnectionFactoryTest.java      | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e153f205/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
index 78e3164..48e6c63 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
@@ -39,6 +39,7 @@ import javax.jms.JMSException;
 
 import org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy;
 import org.apache.qpid.jms.test.QpidJmsTestCase;
+import org.apache.qpid.jms.util.IdGenerator;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -143,6 +144,54 @@ public class JmsConnectionFactoryTest extends QpidJmsTestCase {
     }
 
     @Test
+    public void testUserConnectionIDGeneratorIsUedToCreatedConnection() throws Exception {
+        IdGenerator userGenerator = new IdGenerator("TEST-ID:");
+
+        JmsConnectionFactory factory = new JmsConnectionFactory(new URI("mock://127.0.0.1:5763"));
+        factory.setConnectionIdGenerator(userGenerator);
+
+        JmsConnection connection = (JmsConnection) factory.createConnection();
+        assertNotNull(connection);
+        assertTrue("Connection ID = " + connection.getId(), connection.getId().toString().startsWith("TEST-ID:"));
+    }
+
+    @Test
+    public void testUserConnectionIDPrefixIsUedToCreatedConnection() throws Exception {
+        JmsConnectionFactory factory = new JmsConnectionFactory(new URI("mock://127.0.0.1:5763"));
+        factory.setConnectionIDPrefix("TEST-ID:");
+
+        JmsConnection connection = (JmsConnection) factory.createConnection();
+        assertNotNull(connection);
+        assertTrue("Connection ID = " + connection.getId(), connection.getId().toString().startsWith("TEST-ID:"));
+    }
+
+    @Test
+    public void testUserClientIDGeneratorIsUedToCreatedConnection() throws Exception {
+        IdGenerator userGenerator = new IdGenerator("TEST-ID:");
+
+        JmsConnectionFactory factory = new JmsConnectionFactory(new URI("mock://127.0.0.1:5763"));
+        factory.setClientIdGenerator(userGenerator);
+
+        JmsConnection connection = (JmsConnection) factory.createConnection();
+        connection.start();
+
+        assertNotNull(connection);
+        assertTrue("Connection ID = " + connection.getClientID(), connection.getClientID().startsWith("TEST-ID:"));
+    }
+
+    @Test
+    public void testUserClientIDPrefixIsUedToCreatedConnection() throws Exception {
+        JmsConnectionFactory factory = new JmsConnectionFactory(new URI("mock://127.0.0.1:5763"));
+        factory.setClientIDPrefix("TEST-ID:");
+
+        JmsConnection connection = (JmsConnection) factory.createConnection();
+        connection.start();
+
+        assertNotNull(connection);
+        assertTrue("Client ID = " + connection.getClientID(), connection.getClientID().startsWith("TEST-ID:"));
+    }
+
+    @Test
     public void testCreateConnectionBadProviderURI() throws Exception {
         JmsConnectionFactory factory = new JmsConnectionFactory(new URI("bad://127.0.0.1:5763"));
 
@@ -491,4 +540,12 @@ public class JmsConnectionFactoryTest extends QpidJmsTestCase {
 
         assertFalse(factory.isPopulateJMSXUserID());
     }
+
+    @Test
+    public void testConnectionFactoryCreateWithMalformedURI() {
+        try {
+            new JmsConnectionFactory("amqp:\\\\localhost:5672");
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {}
+    }
 }


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