You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/03/16 16:22:22 UTC
[53/61] [abbrv] activemq-artemis git commit: tests cleanup,
added some more debug information
tests cleanup, added some more debug information
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0ac40d31
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0ac40d31
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0ac40d31
Branch: refs/heads/refactor-openwire
Commit: 0ac40d311aa0be1350acefdb1d245e9a781e3232
Parents: 8005e01
Author: Howard Gao <ho...@gmail.com>
Authored: Mon Feb 29 22:25:17 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Mar 16 11:19:15 2016 -0400
----------------------------------------------------------------------
.../apache/activemq/broker/BrokerService.java | 4 +--
.../artemiswrapper/ArtemisBrokerWrapper.java | 2 +-
.../transport/tcp/TcpTransportFactory.java | 30 ++++++++++++++------
.../apache/activemq/CombinationTestSupport.java | 2 +-
...ExclusiveConsumerStartupDestinationTest.java | 1 +
.../apache/activemq/ExclusiveConsumerTest.java | 2 ++
.../activemq/JmsTransactionTestSupport.java | 1 +
...sTopicSendReceiveWithTwoConnectionsTest.java | 2 ++
.../transport/tcp/SslBrokerServiceTest.java | 1 +
9 files changed, 33 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
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 cbf41e1..b6acee4 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
@@ -101,7 +101,6 @@ public class BrokerService implements Service {
private Throwable startException = null;
private boolean startAsync = false;
public Set<ConnectorInfo> extraConnectors = new HashSet<>();
-// public Set<Integer> sslConnectors = new HashSet<>();
private List<TransportConnector> transportConnectors = new ArrayList<>();
private File dataDirectoryFile;
@@ -591,12 +590,13 @@ public class BrokerService implements Service {
return port;
}
- private static boolean checkPort(final int port) {
+ public static boolean checkPort(final int port) {
ServerSocket ssocket = null;
try {
ssocket = new ServerSocket(port);
}
catch (Exception e) {
+ LOG.info("port " + port + " is being used.");
return false;
}
finally {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
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 83c12db..1a0e297 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
@@ -96,7 +96,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
}
if (this.bservice.enableSsl()) {
//default
- addServerAcceptor(serverConfig, new BrokerService.ConnectorInfo(61611));
+ addServerAcceptor(serverConfig, new BrokerService.ConnectorInfo(61611, true));
}
for (BrokerService.ConnectorInfo info : bservice.extraConnectors) {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index 5b07f48..c44dd72 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -31,6 +31,7 @@ import org.apache.activemq.TransportLoggerSupport;
import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
import org.apache.activemq.broker.BrokerRegistry;
import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper;
import org.apache.activemq.openwire.OpenWireFormat;
import org.apache.activemq.transport.*;
import org.apache.activemq.util.IOExceptionSupport;
@@ -44,12 +45,7 @@ public class TcpTransportFactory extends TransportFactory {
private static final Logger LOG = LoggerFactory.getLogger(TcpTransportFactory.class);
- private static volatile String brokerService = null;
-
- //if a broker is started or stopped it should set this.
- public static void setBrokerName(String name) {
- brokerService = name;
- }
+ private static volatile InternalServiceInfo brokerService = null;
@Override
public Transport doConnect(URI location) throws Exception {
@@ -59,11 +55,11 @@ public class TcpTransportFactory extends TransportFactory {
URI location1 = URISupport.createRemainingURI(location, Collections.EMPTY_MAP);
LOG.info("deciding whether starting an internal broker: " + brokerService + " flag: " + BrokerService.disableWrapper);
- if (brokerService == null && !BrokerService.disableWrapper) {
+ if (brokerService == null && !BrokerService.disableWrapper && BrokerService.checkPort(location1.getPort())) {
LOG.info("starting internal broker: " + location1);
ArtemisBrokerHelper.startArtemisBroker(location1);
- brokerService = location.toString();
+ brokerService = new InternalServiceInfo(location.toString());
if (brokerId != null) {
BrokerRegistry.getInstance().bind(brokerId, ArtemisBrokerHelper.getBroker());
@@ -185,6 +181,7 @@ public class TcpTransportFactory extends TransportFactory {
//remember call this if the test is using the internal broker.
public static void clearService() {
+ LOG.info("#### clearing internal service " + brokerService);
if (brokerService != null) {
try {
ArtemisBrokerHelper.stopArtemisBroker();
@@ -197,4 +194,21 @@ public class TcpTransportFactory extends TransportFactory {
}
}
}
+
+ //added createTime for debugging
+ private static class InternalServiceInfo {
+ private String internalService;
+ private long createTime;
+
+ public InternalServiceInfo(String brokerService) {
+ this.internalService = brokerService;
+ this.createTime = System.currentTimeMillis();
+ LOG.info("just created " + this);
+ }
+
+ @Override
+ public String toString() {
+ return internalService + "@" + createTime;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
index d7caafa..dc8f138 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
@@ -116,7 +116,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport {
public static void checkStopped() throws Exception {
ArtemisBrokerHelper.stopArtemisBroker();
boolean notStopped = BrokerService.checkStopped();
- TcpTransportFactory.setBrokerName(null);
+ TcpTransportFactory.clearService();
if (notStopped) {
fail("brokers not stopped see exceptions above");
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
index 06fbbbe..1e0555c 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
@@ -98,6 +98,7 @@ public class ExclusiveConsumerStartupDestinationTest extends EmbeddedBrokerTestS
}
}
+ //Exclusive consumer not implemented yet.
public void testFailoverToAnotherExclusiveConsumerCreatedFirst() throws JMSException, InterruptedException {
Connection conn = createConnection(true);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
index b2c1d8a..5bc647e 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
@@ -28,6 +28,7 @@ import junit.framework.TestCase;
import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
public class ExclusiveConsumerTest extends TestCase {
@@ -44,6 +45,7 @@ public class ExclusiveConsumerTest extends TestCase {
@Override
protected void tearDown() throws Exception {
+ TcpTransportFactory.clearService();
super.tearDown();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
index dfcf302..abaf52d 100755
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
@@ -36,6 +36,7 @@ import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.test.JmsResourceProvider;
import org.apache.activemq.test.TestSupport;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
index 00452d1..1f8d8da 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
@@ -23,6 +23,7 @@ import javax.jms.MessageConsumer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,6 +104,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes
receiveSession.close();
sendConnection.close();
receiveConnection.close();
+ TcpTransportFactory.clearService();
}
/**
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ac40d31/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
index 3a1c9a4..d380246 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
@@ -124,6 +124,7 @@ public class SslBrokerServiceTest extends TransportBrokerTestSupport {
private void makeSSLConnection(SSLContext context,
String enabledSuites[],
TransportConnector connector) throws Exception, UnknownHostException, SocketException {
+ System.out.println("-----connector: " + connector);
SSLSocket sslSocket = (SSLSocket) context.getSocketFactory().createSocket("localhost", connector.getUri().getPort());
if (enabledSuites != null) {