activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5705 - fix test regression. Make PublishedAddressPolicy vm scheme aware so such that is won't attempt a transform
Date Tue, 23 Jun 2015 10:40:27 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 26eb103b9 -> 37c46b9b4


https://issues.apache.org/jira/browse/AMQ-5705 - fix test regression. Make PublishedAddressPolicy
vm scheme aware so such that is won't attempt a transform


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/37c46b9b
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/37c46b9b
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/37c46b9b

Branch: refs/heads/master
Commit: 37c46b9b42c8e93378afb101815a857d1c86dc4e
Parents: 26eb103
Author: gtully <gary.tully@gmail.com>
Authored: Tue Jun 23 11:25:13 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Tue Jun 23 11:25:43 2015 +0100

----------------------------------------------------------------------
 .../activemq/broker/PublishedAddressPolicy.java |  9 ++++--
 .../transport/vm/VMTransportBrokerNameTest.java | 33 +++++++++++++++++++-
 2 files changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/37c46b9b/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java
index 9898482..f620185 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/PublishedAddressPolicy.java
@@ -22,6 +22,7 @@ import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Locale;
 
+import org.apache.activemq.transport.vm.VMTransport;
 import org.apache.activemq.util.InetAddressUtil;
 
 /**
@@ -69,6 +70,10 @@ public class PublishedAddressPolicy {
         }
 
         String scheme = connectorURI.getScheme();
+        if ("vm".equals(scheme)) {
+            return connectorURI;
+        }
+
         String userInfo = getPublishedUserInfoValue(connectorURI.getUserInfo());
         String host = getPublishedHostValue(connectorURI.getHost());
         int port = connectorURI.getPort();
@@ -193,14 +198,14 @@ public class PublishedAddressPolicy {
     }
 
     /**
-     * @param publishedHostStrategy the publishedHostStrategy to set
+     * @param strategy the publishedHostStrategy to set
      */
     public void setPublishedHostStrategy(PublishedHostStrategy strategy) {
         this.publishedHostStrategy = strategy;
     }
 
     /**
-     * @param publishedHostStrategy the publishedHostStrategy to set
+     * @param strategy the publishedHostStrategy to set
      */
     public void setPublishedHostStrategy(String strategy) {
         this.publishedHostStrategy = PublishedHostStrategy.getValue(strategy);

http://git-wip-us.apache.org/repos/asf/activemq/blob/37c46b9b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
index 50a81f6..50785da 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
@@ -18,19 +18,23 @@ package org.apache.activemq.transport.vm;
 
 import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 import javax.jms.Connection;
-import org.junit.Test;
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerRegistry;
+import org.apache.activemq.broker.PublishedAddressPolicy;
+import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportListener;
+import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -60,6 +64,33 @@ public class VMTransportBrokerNameTest {
     }
 
     @Test
+    public void testPublishableAddressUri() throws Exception {
+
+        PublishedAddressPolicy publishedAddressPolicy = new PublishedAddressPolicy();
+        final AtomicReference<URI> uriAtomicReference = new AtomicReference<>();
+
+        TransportConnector dummyTransportConnector = new TransportConnector() {
+            @Override
+            public URI getConnectUri() throws IOException, URISyntaxException {
+                return uriAtomicReference.get();
+            }
+        };
+        URI ok = new URI("vm://b1");
+        uriAtomicReference.set(ok);
+        assertEquals(uriAtomicReference.get(), publishedAddressPolicy.getPublishableConnectURI(dummyTransportConnector));
+
+        ok = new URI("vm://b1?async=false");
+        uriAtomicReference.set(ok);
+        assertEquals(uriAtomicReference.get(), publishedAddressPolicy.getPublishableConnectURI(dummyTransportConnector));
+
+
+        URI badHost = new URI("vm://b1_11");
+        uriAtomicReference.set(badHost);
+        assertEquals(uriAtomicReference.get(), publishedAddressPolicy.getPublishableConnectURI(dummyTransportConnector));
+
+    }
+
+    @Test
     public void testBrokerInfoReceiptClientAsync() throws Exception {
 
         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(vmUrl));


Mime
View raw message