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 2015/01/29 22:23:36 UTC

[1/3] qpid-jms git commit: Make toString produce a meaningful value.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 4f380e2a5 -> d76e0afd3


Make toString produce a meaningful value.

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

Branch: refs/heads/master
Commit: b042a3360afb1b2d628cd98c572f543da6456656
Parents: 4f380e2
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Jan 29 16:01:56 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Jan 29 16:01:56 2015 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/qpid/jms/meta/JmsSessionInfo.java    | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b042a336/qpid-jms-client/src/main/java/org/apache/qpid/jms/meta/JmsSessionInfo.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/meta/JmsSessionInfo.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/meta/JmsSessionInfo.java
index bab15bf..a88e5e7 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/meta/JmsSessionInfo.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/meta/JmsSessionInfo.java
@@ -18,6 +18,8 @@ package org.apache.qpid.jms.meta;
 
 import javax.jms.Session;
 
+import org.apache.qpid.jms.util.ToStringSupport;
+
 public final class JmsSessionInfo implements JmsResource, Comparable<JmsSessionInfo> {
 
     private final JmsSessionId sessionId;
@@ -80,6 +82,11 @@ public final class JmsSessionInfo implements JmsResource, Comparable<JmsSessionI
     }
 
     @Override
+    public String toString() {
+        return ToStringSupport.toString(this);
+    }
+
+    @Override
     public int hashCode() {
         return sessionId.hashCode();
     }


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


[3/3] qpid-jms git commit: Move these to the client and use a Mock'd provider as we are just testing the contract of the methods based on state.

Posted by ta...@apache.org.
Move these to the client and use a Mock'd provider as we are just
testing the contract of the methods based on state.  

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

Branch: refs/heads/master
Commit: d76e0afd3cb160b0c06527ecfae9fec75d85fb14
Parents: f33aba2
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Jan 29 16:23:22 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Jan 29 16:23:22 2015 -0500

----------------------------------------------------------------------
 .../qpid/jms/JmsConnectionClosedTest.java       | 175 +++++++++++++++++++
 .../qpid/jms/JmsConnectionFailedTest.java       |  58 ++++++
 .../java/org/apache/qpid/jms/test/Wait.java     |   4 +-
 .../qpid/jms/JmsConnectionClosedTest.java       | 107 ------------
 .../qpid/jms/JmsConnectionFailedTest.java       |  60 -------
 5 files changed, 235 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d76e0afd/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java
new file mode 100644
index 0000000..1be9605
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.jms;
+
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.apache.qpid.jms.meta.JmsResource;
+import org.apache.qpid.jms.provider.Provider;
+import org.apache.qpid.jms.provider.ProviderFuture;
+import org.apache.qpid.jms.provider.ProviderListener;
+import org.apache.qpid.jms.test.QpidJmsTestCase;
+import org.apache.qpid.jms.util.IdGenerator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test Connection methods contracts when state is closed.
+ */
+public class JmsConnectionClosedTest extends QpidJmsTestCase {
+
+    private static final Logger LOG = LoggerFactory.getLogger(JmsConnectionClosedTest.class);
+
+    protected Destination destination;
+
+    private final Provider provider = Mockito.mock(Provider.class);
+    private final IdGenerator clientIdGenerator = new IdGenerator();
+
+    protected JmsConnection connection;
+    protected ProviderListener providerListener;
+
+    protected JmsConnection createConnectionToMockProvider() throws Exception {
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                if (args[0] instanceof JmsResource) {
+                    LOG.debug("Handling provider create resource: {}", args[0]);
+                    ProviderFuture request = (ProviderFuture) args[1];
+                    request.onSuccess();
+                }
+                return null;
+            }
+        }).when(provider).create(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                if (args[0] instanceof JmsResource) {
+                    LOG.debug("Handling provider destroy resource: {}", args[0]);
+                    ProviderFuture request = (ProviderFuture) args[1];
+                    request.onSuccess();
+                }
+                return null;
+            }
+        }).when(provider).destroy(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                if (args[0] instanceof ProviderListener) {
+                    providerListener = (ProviderListener) args[0];
+                }
+                return null;
+            }
+        }).when(provider).setProviderListener(Mockito.any(ProviderListener.class));
+
+        JmsConnection connection = new JmsConnection("ID:TEST:1", provider, clientIdGenerator);
+        return connection;
+    }
+
+    protected JmsConnection createConnection() throws Exception {
+        connection = createConnectionToMockProvider();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        destination = session.createTopic("test");
+        connection.close();
+        return connection;
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        connection = createConnection();
+    }
+
+    @Override
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (connection != null) {
+            connection.close();
+        }
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testGetClientIdFails() throws Exception {
+        connection.getClientID();
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testSetClientIdFails() throws Exception {
+        connection.setClientID("test");
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testGetMetaData() throws Exception {
+        connection.getMetaData();
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testGetExceptionListener() throws Exception {
+        connection.getExceptionListener();
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testSetExceptionListener() throws Exception {
+        connection.setExceptionListener(new ExceptionListener() {
+            @Override
+            public void onException(JMSException exception) {
+            }
+        });
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testStartFails() throws Exception {
+        connection.start();
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testStopFails() throws Exception {
+        connection.stop();
+    }
+
+    @Test(timeout=30000)
+    public void testClose() throws Exception {
+        connection.close();
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testCreateConnectionConsumerFails() throws Exception {
+        connection.createConnectionConsumer(destination, "", null, 1);
+    }
+
+    @Test(timeout=30000, expected=JMSException.class)
+    public void testCreateDurableConnectionConsumerFails() throws Exception {
+        connection.createDurableConnectionConsumer((Topic) destination, "id", "", null, 1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d76e0afd/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java
new file mode 100644
index 0000000..809cf97
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.jms;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+
+import org.apache.qpid.jms.test.Wait;
+
+/**
+ * Test Connection methods contracts when connection has failed.
+ */
+public class JmsConnectionFailedTest extends JmsConnectionClosedTest {
+
+    @Override
+    protected JmsConnection createConnection() throws Exception {
+        connection = createConnectionToMockProvider();
+        connection.setExceptionListener(new ExceptionListener() {
+
+            @Override
+            public void onException(JMSException exception) {
+            }
+        });
+        connection.start();
+
+        providerListener.onConnectionFailure(new IOException());
+
+        final JmsConnection jmsConnection = connection;
+        assertTrue(Wait.waitFor(new Wait.Condition() {
+
+            @Override
+            public boolean isSatisified() throws Exception {
+                return !jmsConnection.isConnected();
+            }
+        }, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(10)));
+
+        return connection;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d76e0afd/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/Wait.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/Wait.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/Wait.java
index e95a2a9..bfb6053 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/Wait.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/Wait.java
@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
 public class Wait {
 
     public static final long MAX_WAIT_MILLIS = 30 * 1000;
-    public static final int SLEEP_MILLIS = 1000;
+    public static final long SLEEP_MILLIS = 1000;
 
     public interface Condition {
         boolean isSatisified() throws Exception;
@@ -35,7 +35,7 @@ public class Wait {
         return waitFor(condition, duration, SLEEP_MILLIS);
     }
 
-    public static boolean waitFor(final Condition condition, final long duration, final int sleepMillis) throws Exception {
+    public static boolean waitFor(final Condition condition, final long duration, final long sleepMillis) throws Exception {
 
         final long expiry = System.currentTimeMillis() + duration;
         boolean conditionSatisified = condition.isSatisified();

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d76e0afd/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java
deleted file mode 100644
index f5d2892..0000000
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionClosedTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.Topic;
-
-import org.apache.qpid.jms.support.AmqpTestSupport;
-import org.junit.Test;
-
-/**
- * Test Connection methods contracts when state is closed.
- */
-public class JmsConnectionClosedTest extends AmqpTestSupport {
-
-    protected Destination destination;
-
-    protected Connection createConnection() throws Exception {
-        connection = createAmqpConnection();
-        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        destination = session.createTopic("test");
-        connection.close();
-        return connection;
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testGetClientIdFails() throws Exception {
-        createConnection();
-        connection.getClientID();
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testSetClientIdFails() throws Exception {
-        createConnection();
-        connection.setClientID("test");
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testGetMetaData() throws Exception {
-        createConnection();
-        connection.getMetaData();
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testGetExceptionListener() throws Exception {
-        createConnection();
-        connection.getExceptionListener();
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testSetExceptionListener() throws Exception {
-        createConnection();
-        connection.setExceptionListener(new ExceptionListener() {
-            @Override
-            public void onException(JMSException exception) {
-            }
-        });
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testStartFails() throws Exception {
-        createConnection();
-        connection.start();
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testStopFails() throws Exception {
-        createConnection();
-        connection.stop();
-    }
-
-    @Test(timeout=30000)
-    public void testClose() throws Exception {
-        createConnection();
-        connection.close();
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testCreateConnectionConsumerFails() throws Exception {
-        createConnection();
-        connection.createConnectionConsumer(destination, "", null, 1);
-    }
-
-    @Test(timeout=30000, expected=JMSException.class)
-    public void testCreateDurableConnectionConsumerFails() throws Exception {
-        createConnection();
-        connection.createDurableConnectionConsumer((Topic) destination, "id", "", null, 1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d76e0afd/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java
deleted file mode 100644
index b14792e..0000000
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/JmsConnectionFailedTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-
-import org.apache.qpid.jms.JmsConnection;
-import org.apache.qpid.jms.support.Wait;
-
-/**
- * Test Connection methods contracts when connection has failed.
- */
-public class JmsConnectionFailedTest extends JmsConnectionClosedTest {
-
-    @Override
-    protected Connection createConnection() throws Exception {
-        final CountDownLatch latch = new CountDownLatch(1);
-        connection = createAmqpConnection();
-        connection.setExceptionListener(new ExceptionListener() {
-
-            @Override
-            public void onException(JMSException exception) {
-                latch.countDown();
-            }
-        });
-        connection.start();
-        stopPrimaryBroker();
-        assertTrue(latch.await(20, TimeUnit.SECONDS));
-        final JmsConnection jmsConnection = (JmsConnection) connection;
-        assertTrue(Wait.waitFor(new Wait.Condition() {
-
-            @Override
-            public boolean isSatisified() throws Exception {
-                return !jmsConnection.isConnected();
-            }
-        }));
-        return connection;
-    }
-}


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


[2/3] qpid-jms git commit: Tidy up a bit.

Posted by ta...@apache.org.
Tidy up a bit.

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

Branch: refs/heads/master
Commit: f33aba299baec997d4460fac255eeb004d6645bf
Parents: b042a33
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Jan 29 16:04:52 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Jan 29 16:04:52 2015 -0500

----------------------------------------------------------------------
 .../org/apache/qpid/jms/util/PropertyUtil.java  | 96 +++++++++++---------
 1 file changed, 55 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f33aba29/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/PropertyUtil.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/PropertyUtil.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/PropertyUtil.java
index ecc3fd5..4abb778 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/PropertyUtil.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/util/PropertyUtil.java
@@ -45,8 +45,7 @@ public class PropertyUtil {
      * Creates a URI from the original URI and the given parameters.
      *
      * @param originalURI
-     *        The URI whose current parameters are remove and replaced with the given remainder
-     *        value.
+     *        The URI whose current parameters are removed and replaced with the given remainder value.
      * @param params
      *        The URI params that should be used to replace the current ones in the target.
      *
@@ -212,21 +211,21 @@ public class PropertyUtil {
      * Given a map of properties, filter out only those prefixed with the given value, the
      * values filtered are returned in a new Map instance.
      *
-     * @param props
+     * @param properties
      *        The map of properties to filter.
      * @param optionPrefix
      *        The prefix value to use when filtering.
      *
      * @return a filter map with only values that match the given prefix.
      */
-    public static Map<String, String> filterProperties(Map<String, String> props, String optionPrefix) {
-        if (props == null) {
-            throw new IllegalArgumentException("props was null.");
+    public static Map<String, String> filterProperties(Map<String, String> properties, String optionPrefix) {
+        if (properties == null) {
+            throw new IllegalArgumentException("The given properties object was null.");
         }
 
-        HashMap<String, String> rc = new HashMap<String, String>(props.size());
+        HashMap<String, String> rc = new HashMap<String, String>(properties.size());
 
-        for (Iterator<Entry<String, String>> iter = props.entrySet().iterator(); iter.hasNext();) {
+        for (Iterator<Entry<String, String>> iter = properties.entrySet().iterator(); iter.hasNext();) {
             Entry<String, String> entry = iter.next();
             if (entry.getKey().startsWith(optionPrefix)) {
                 String name = entry.getKey().substring(optionPrefix.length());
@@ -239,47 +238,61 @@ public class PropertyUtil {
     }
 
     /**
-     * Add bean properties to a URI
+     * Enumerate the properties of the target object and add them as additional entries
+     * to the query string of the given string URI.
      *
      * @param uri
+     *        The string URI value to append the object properties to.
      * @param bean
-     * @return <Code>Map</Code> of properties
-     * @throws Exception
+     *        The Object whose properties will be added to the target URI.
+     *
+     * @return a new String value that is the original URI with the added bean properties.
+     *
+     * @throws Exception if an error occurs while enumerating the bean properties.
      */
     public static String addPropertiesToURIFromBean(String uri, Object bean) throws Exception {
-        Map<String, String> props = PropertyUtil.getProperties(bean);
-        return PropertyUtil.addPropertiesToURI(uri, props);
+        Map<String, String> properties = PropertyUtil.getProperties(bean);
+        return PropertyUtil.addPropertiesToURI(uri, properties);
     }
 
     /**
-     * Add properties to a URI
+     * Enumerate the properties of the target object and add them as additional entries
+     * to the query string of the given URI.
      *
      * @param uri
-     * @param props
-     * @return uri with properties on
-     * @throws Exception
+     *        The URI value to append the object properties to.
+     * @param bean
+     *        The Object whose properties will be added to the target URI.
+     *
+     * @return a new String value that is the original URI with the added bean properties.
+     *
+     * @throws Exception if an error occurs while enumerating the bean properties.
      */
-    public static String addPropertiesToURI(URI uri, Map<String, String> props) throws Exception {
-        return addPropertiesToURI(uri.toString(), props);
+    public static String addPropertiesToURI(URI uri, Map<String, String> properties) throws Exception {
+        return addPropertiesToURI(uri.toString(), properties);
     }
 
     /**
-     * Add properties to a URI
+     * Append the given properties to the query portion of the given URI.
      *
      * @param uri
-     * @param props
-     * @return uri with properties on
-     * @throws Exception
+     *        The string URI value to append the object properties to.
+     * @param bean
+     *        The properties that will be added to the target URI.
+     *
+     * @return a new String value that is the original URI with the added properties.
+     *
+     * @throws Exception if an error occurs while building the new URI string.
      */
-    public static String addPropertiesToURI(String uri, Map<String, String> props) throws Exception {
+    public static String addPropertiesToURI(String uri, Map<String, String> properties) throws Exception {
         String result = uri;
-        if (uri != null && props != null) {
+        if (uri != null && properties != null) {
             StringBuilder base = new StringBuilder(stripBefore(uri, '?'));
             Map<String, String> map = parseParameters(uri);
             if (!map.isEmpty()) {
-                map.putAll(props);
+                map.putAll(properties);
             } else {
-                map = props;
+                map = properties;
             }
             if (!map.isEmpty()) {
                 base.append('?');
@@ -303,28 +316,28 @@ public class PropertyUtil {
      *
      * @param target
      *        the object whose properties are to be set from the map options.
-     * @param props
+     * @param properties
      *        the properties that should be applied to the given object.
      *
-     * @return true if all values in the props map were applied to the target object.
+     * @return true if all values in the properties map were applied to the target object.
      */
-    public static boolean setProperties(Object target, Map<String, String> props) {
+    public static boolean setProperties(Object target, Map<String, String> properties) {
         if (target == null) {
             throw new IllegalArgumentException("target object cannot be null");
         }
-        if (props == null) {
+        if (properties == null) {
             throw new IllegalArgumentException("Given Properties object cannot be null");
         }
 
         int setCounter = 0;
 
-        for (Map.Entry<String, String> entry : props.entrySet()) {
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
             if (setProperty(target, entry.getKey(), entry.getValue())) {
                 setCounter++;
             }
         }
 
-        return setCounter == props.size();
+        return setCounter == properties.size();
     }
 
     /**
@@ -336,19 +349,19 @@ public class PropertyUtil {
      * @param props
      *        the properties that should be applied to the given object.
      *
-     * @return true if all values in the props map were applied to the target object.
+     * @return an unmodifiable map with any values that could not be applied to the target.
      */
-    public static Map<String, Object> setProperties(Object target, Properties props) {
+    public static Map<String, Object> setProperties(Object target, Properties properties) {
         if (target == null) {
             throw new IllegalArgumentException("target object cannot be null");
         }
-        if (props == null) {
+        if (properties == null) {
             throw new IllegalArgumentException("Given Properties object cannot be null");
         }
 
         Map<String, Object> unmatched = new HashMap<String, Object>();
 
-        for (Map.Entry<Object, Object> entry : props.entrySet()) {
+        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
             if (!setProperty(target, (String) entry.getKey(), entry.getValue())) {
                 unmatched.put((String) entry.getKey(), entry.getValue());
             }
@@ -373,7 +386,7 @@ public class PropertyUtil {
             return Collections.emptyMap();
         }
 
-        Map<String, String> props = new LinkedHashMap<String, String>();
+        Map<String, String> properties = new LinkedHashMap<String, String>();
         BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
         Object[] NULL_ARG = {};
         PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
@@ -384,20 +397,21 @@ public class PropertyUtil {
                     Object value = pd.getReadMethod().invoke(object, NULL_ARG);
                     if (value != null) {
                         if (value instanceof Boolean || value instanceof Number || value instanceof String || value instanceof URI || value instanceof URL) {
-                            props.put(pd.getName(), ("" + value));
+                            properties.put(pd.getName(), ("" + value));
                         } else if (value instanceof SSLContext) {
                             // ignore this one..
                         } else {
                             Map<String, String> inner = getProperties(value);
                             for (Map.Entry<String, String> entry : inner.entrySet()) {
-                                props.put(pd.getName() + "." + entry.getKey(), entry.getValue());
+                                properties.put(pd.getName() + "." + entry.getKey(), entry.getValue());
                             }
                         }
                     }
                 }
             }
         }
-        return props;
+
+        return properties;
     }
 
     /**


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