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 2018/04/05 20:26:12 UTC

[1/2] qpid-jms git commit: QPIDJMS-374: Use PU.parseQuery(remoteURI) to avoid double encoding

Repository: qpid-jms
Updated Branches:
  refs/heads/master 7ce0c2916 -> f05c184cd


QPIDJMS-374: Use PU.parseQuery(remoteURI) to avoid double encoding


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

Branch: refs/heads/master
Commit: b96f4f2ab2ee635661c175b48e39cb3c65006b6a
Parents: 7ce0c29
Author: mibo <mi...@apache.org>
Authored: Thu Mar 29 08:52:29 2018 +0200
Committer: mibo <mi...@apache.org>
Committed: Wed Apr 4 22:02:58 2018 +0200

----------------------------------------------------------------------
 .../jms/provider/amqp/AmqpProviderFactory.java  |  2 +-
 .../qpid/jms/transports/TransportFactory.java   |  2 +-
 .../provider/amqp/AmqpProviderFactoryTest.java  | 14 +++++++++++++
 .../netty/NettySslTransportFactoryTest.java     | 22 ++++++++++++++++++++
 4 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b96f4f2a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactory.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactory.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactory.java
index 5675277..c141e26 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactory.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactory.java
@@ -38,7 +38,7 @@ public class AmqpProviderFactory extends ProviderFactory {
     @Override
     public AmqpProvider createProvider(URI remoteURI) throws Exception {
 
-        Map<String, String> map = PropertyUtil.parseQuery(remoteURI.getQuery());
+        Map<String, String> map = PropertyUtil.parseQuery(remoteURI);
         Map<String, String> providerOptions = PropertyUtil.filterProperties(map, "amqp.");
 
         // Clear off any amqp.X values from the transport before creation.

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b96f4f2a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/TransportFactory.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/TransportFactory.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/TransportFactory.java
index d3202e7..e5a56c8 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/TransportFactory.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/TransportFactory.java
@@ -48,7 +48,7 @@ public abstract class TransportFactory {
      * @throws Exception if an error occurs while creating the Transport instance.
      */
     public Transport createTransport(URI remoteURI) throws Exception {
-        Map<String, String> map = PropertyUtil.parseQuery(remoteURI.getQuery());
+        Map<String, String> map = PropertyUtil.parseQuery(remoteURI);
         Map<String, String> transportURIOptions = PropertyUtil.filterProperties(map, "transport.");
 
         remoteURI = PropertyUtil.replaceQuery(remoteURI, map);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b96f4f2a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
index e49e42e..0955767 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderFactoryTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.net.URI;
+import java.net.URLEncoder;
 
 import org.apache.qpid.jms.provider.Provider;
 import org.apache.qpid.jms.test.QpidJmsTestCase;
@@ -127,4 +128,17 @@ public class AmqpProviderFactoryTest extends QpidJmsTestCase {
         assertEquals(true, amqpProvider.isTraceFrames());
         assertEquals(32, amqpProvider.getChannelMax());
     }
+
+    @Test(timeout = 20000)
+    public void testCreateProviderEncodedVhost() throws IOException, Exception {
+        URI configuredURI = new URI(peerURI.toString() +
+            "?amqp.vhost=" + URLEncoder.encode("v+host", "utf-8"));
+        Provider provider = AmqpProviderFactory.create(configuredURI);
+        assertNotNull(provider);
+        assertTrue(provider instanceof AmqpProvider);
+
+        AmqpProvider amqpProvider = (AmqpProvider) provider;
+
+        assertEquals("v+host", amqpProvider.getVhost());
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b96f4f2a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportFactoryTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportFactoryTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportFactoryTest.java
index ed46d13..c37a29e 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportFactoryTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/transports/netty/NettySslTransportFactoryTest.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
+import java.net.URLEncoder;
 import java.util.Arrays;
 import java.util.List;
 
@@ -61,6 +62,8 @@ public class NettySslTransportFactoryTest {
     public static final boolean CUSTOM_TRUST_ALL = true;
     public static final boolean CUSTOM_VERIFY_HOST = false;
     public static final String CUSTOM_KEY_ALIAS = "myTestAlias";
+    public static final String CUSTOM_TRUST_STORE_LOCATION = "/home/user/store";
+    public static final String CUSTOM_TRUST_STORE_PASSWORD = "pass+word";
 
     @Test
     public void testCreateWithDefaultOptions() throws Exception {
@@ -233,4 +236,23 @@ public class NettySslTransportFactoryTest {
         assertEquals(CUSTOM_STORE_TYPE_PKCS12, sslOptions.getKeyStoreType());
         assertEquals(CUSTOM_STORE_TYPE, sslOptions.getTrustStoreType());
     }
+
+    @Test
+    public void testUrlEncodedTransportValues() throws Exception {
+        URI BASE_URI = new URI("tcp://localhost:5672");
+        final String encodedLocation = URLEncoder.encode(CUSTOM_TRUST_STORE_LOCATION, "utf-8");
+        final String encodedPassword = URLEncoder.encode(CUSTOM_TRUST_STORE_PASSWORD, "utf-8");
+        URI configuredURI = new URI(BASE_URI.toString() + "?" +
+                "transport.trustStoreLocation=" + encodedLocation + "&" +
+                "transport.trustStorePassword=" + encodedPassword);
+
+        NettySslTransportFactory factory = new NettySslTransportFactory();
+        Transport transport = factory.createTransport(configuredURI);
+        TransportOptions options = transport.getTransportOptions();
+        assertTrue(options instanceof TransportSslOptions);
+        TransportSslOptions sslOptions = (TransportSslOptions) options;
+
+        assertEquals(CUSTOM_TRUST_STORE_LOCATION, sslOptions.getTrustStoreLocation());
+        assertEquals(CUSTOM_TRUST_STORE_PASSWORD, sslOptions.getTrustStorePassword());
+    }
 }


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


[2/2] qpid-jms git commit: This closes #17

Posted by ta...@apache.org.
This closes #17


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

Branch: refs/heads/master
Commit: f05c184cda2093a12f518a8aa3a7d59622beac74
Parents: 7ce0c29 b96f4f2
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Apr 5 16:25:52 2018 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Apr 5 16:25:52 2018 -0400

----------------------------------------------------------------------
 .../jms/provider/amqp/AmqpProviderFactory.java  |  2 +-
 .../qpid/jms/transports/TransportFactory.java   |  2 +-
 .../provider/amqp/AmqpProviderFactoryTest.java  | 14 +++++++++++++
 .../netty/NettySslTransportFactoryTest.java     | 22 ++++++++++++++++++++
 4 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



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