From bb1e03c0798439ce22523f7bcb55b281f8781d16 Mon Sep 17 00:00:00 2001 From: Howard Gao Date: Tue, 11 Aug 2015 16:06:46 +0800 Subject: [PATCH] Openwire test fix: Fixed issues with TcpTransportBrokerTest removed one irrelevant test Not all tests in it are passing however that'll fix 125 of total 128 tests. --- .../apache/activemq/broker/BrokerService.java | 17 +++++++++++++++++ .../artemiswrapper/ArtemisBrokerWrapper.java | 8 +++++++- .../org/apache/activemq/broker/BrokerTest.java | 4 ---- .../transport/TransportBrokerTestSupport.java | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java index b46c3461c4..a3dce7f7ba 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -633,6 +634,22 @@ public class BrokerService implements Service { map.clear(); return runningBrokers; } + + public URI getConnectURI() { + URI uri = null; + try { + if (this.extraConnectors.size() > 0) { + Integer port = extraConnectors.iterator().next(); + uri = new URI("tcp://localhost:" + port); + } else { + uri = new URI(this.getDefaultUri()); + } + } catch (URISyntaxException e) { + //ignore + } + return uri; + } + } diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java index 31da179ebf..bf92a9cbed 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java @@ -199,6 +199,12 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase { settings.setSlowConsumerCheckPeriod(1); settings.setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY); } + if (entry.isProducerFlowControl()) { + settings.setMaxSizeBytes(10240).setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); + if (bservice.getSystemUsage().isSendFailIfNoSpace()) { + settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL); + } + } } PolicyEntry defaultEntry = policyMap.getDefaultEntry(); @@ -209,7 +215,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase { settingsMap.put("#", defSettings); } if (defaultEntry.isProducerFlowControl()) { - defSettings.setMaxSizeBytes(1).setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); + defSettings.setMaxSizeBytes(10240).setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); if (bservice.getSystemUsage().isSendFailIfNoSpace()) { defSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java index e225f00f8a..8ec55b7945 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java @@ -1653,10 +1653,6 @@ public class BrokerTest extends BrokerTestSupport { connection.request(createAck(consumerInfo, m3, 1, MessageAck.DELIVERED_ACK_TYPE)); } - public void testGetServices() throws Exception { - assertTrue(broker.getServices().length != 0); - } - public static Test suite() { return suite(BrokerTest.class); } diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java index 501c2a020e..a40e87331b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java @@ -25,6 +25,7 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerTest; import org.apache.activemq.broker.StubConnection; import org.apache.activemq.broker.TransportConnector; +import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper; public abstract class TransportBrokerTestSupport extends BrokerTest { @@ -65,7 +66,7 @@ public abstract class TransportBrokerTestSupport extends BrokerTest { // Note: on platforms like OS X we cannot bind to the actual hostname, so we // instead use the original host name (typically localhost) to bind to - URI actualURI = connector.getServer().getConnectURI(); + URI actualURI = this.broker.getConnectURI(); URI connectURI = new URI(actualURI.getScheme(), actualURI.getUserInfo(), bindURI.getHost(), actualURI.getPort(), actualURI.getPath(), bindURI.getQuery(), bindURI.getFragment()); Transport transport = TransportFactory.connect(connectURI);