You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/01/27 15:42:44 UTC

[3/6] qpid-jms git commit: add test for setting properties on the connection factory

add test for setting properties on the connection factory


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

Branch: refs/heads/master
Commit: d1ce3ef047fe6e47ee0152ea3107af82ea354e54
Parents: 12decc4
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Jan 27 11:25:20 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Jan 27 14:42:04 2015 +0000

----------------------------------------------------------------------
 .../qpid/jms/JmsConnectionFactoryTest.java      | 45 +++++++++++++++++++-
 1 file changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d1ce3ef0/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 b5ee632..9546ec9 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
@@ -18,17 +18,53 @@ package org.apache.qpid.jms;
 
 import static org.apache.qpid.jms.SerializationTestSupport.roundTripSerialize;
 import static org.apache.qpid.jms.SerializationTestSupport.serialize;
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.qpid.jms.test.QpidJmsTestCase;
 import org.junit.Test;
 
-public class JmsConnectionFactoryTest {
+public class JmsConnectionFactoryTest extends QpidJmsTestCase {
+
+    @Test
+    public void testSetProperties() throws Exception {
+        String clientID = getTestName();
+        String queuePrefix = "q:";
+        String jmsOptionPrefix = "jms.";
+        String clientIDprop = "clientID";
+        String baseUri = "amqp://localhost:1234";
+        String uri = baseUri + "?" + jmsOptionPrefix + clientIDprop + "=" + clientID;
+
+        // Create a connection factory object
+        JmsConnectionFactory cf = new JmsConnectionFactory();
+
+        // Verify the outcome conditions have not been met already
+        assertNotEquals("value should not match yet", clientID, cf.getClientID());
+        assertNotEquals("value should not match yet", queuePrefix, cf.getQueuePrefix());
+        assertNotEquals("value should not match yet", baseUri, cf.getBrokerURI());
+
+        // Set the properties
+        Map<String, String> props = new HashMap<String, String>();
+        // Add the URI property, itself containing a property option in its query
+        props.put("brokerURI", uri);
+        // Add another property directly
+        props.put("queuePrefix", queuePrefix);
+        cf.setProperties(props);
+
+        // Verify the clientID property option from the URI was applied.
+        assertEquals("uri property query option not applied as expected", clientID, cf.getClientID());
+        // Verify the direct property was applied
+        assertEquals("direct property not applied as expected", queuePrefix, cf.getQueuePrefix());
+        // Verify the URI was filtered to remove the applied options
+        assertEquals("URI was filtered to remove options that were applied", baseUri, cf.getBrokerURI());
+    }
 
     @Test
     public void testSerializeThenDeserialize() throws Exception {
@@ -47,6 +83,11 @@ public class JmsConnectionFactoryTest {
         assertEquals("Properties were not equal", props, props2);
     }
 
+    /**
+     * The prefetch policy is maintained in a child-object, which we extract the properties from
+     * when serializing the factory. Ensure this functions by doing a round trip on a factory
+     * configured with some new prefetch configuration via the URI.
+     */
     @Test
     public void testSerializeThenDeserializeMaintainsPrefetchPolicy() throws Exception {
         String topicPrefetchValue = "17";


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