mirror of https://github.com/apache/activemq.git
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
This commit is contained in:
parent
26eb103b92
commit
37c46b9b42
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -59,6 +63,33 @@ public class VMTransportBrokerNameTest {
|
|||
c2.close();
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue