mirror of https://github.com/apache/activemq.git
Speed up these tests by only creating the connector needed for the test
so we spend less time starting and stopping the broker for each test run.
This commit is contained in:
parent
359ec25e21
commit
6d8449f053
|
@ -19,8 +19,8 @@ package org.apache.activemq.transport.amqp;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
|
||||||
public class AmqpNioTest extends AmqpTestSupport {
|
public class AmqpNioTest extends AmqpTestSupport {
|
||||||
|
|
||||||
protected void addAMQPConnector(BrokerService brokerService) throws Exception {
|
protected void addAMQPConnector(BrokerService brokerService) throws Exception {
|
||||||
brokerService.addConnector("amqp+nio://localhost:1883?maxInactivityDuration=-1");
|
brokerService.addConnector("amqp+nio://localhost:1883?maxInactivityDuration=-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,6 @@ public class AmqpSslTest extends AmqpTestSupport {
|
||||||
brokerService.addConnector("amqp+ssl://localhost:8883");
|
brokerService.addConnector("amqp+ssl://localhost:8883");
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected AMQP createAMQPConnection() throws Exception {
|
|
||||||
// AMQP amqp = new AMQP();
|
|
||||||
// amqp.setHost("ssl://localhost:8883");
|
|
||||||
// SSLContext ctx = SSLContext.getInstance("TLS");
|
|
||||||
// ctx.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom());
|
|
||||||
// amqp.setSslContext(ctx);
|
|
||||||
// return amqp;
|
|
||||||
// }
|
|
||||||
|
|
||||||
static class DefaultTrustManager implements X509TrustManager {
|
static class DefaultTrustManager implements X509TrustManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,5 +56,4 @@ public class AmqpSslTest extends AmqpTestSupport {
|
||||||
return new X509Certificate[0];
|
return new X509Certificate[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,18 +117,44 @@ public class AmqpTestSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addAMQPConnector() throws Exception {
|
protected void addAMQPConnector() throws Exception {
|
||||||
TransportConnector connector = brokerService.addConnector("amqp+ssl://0.0.0.0:" + sslPort);
|
TransportConnector connector = null;
|
||||||
sslPort = connector.getConnectUri().getPort();
|
|
||||||
LOG.debug("Using amqp+ssl port " + sslPort);
|
if (isUseTcpConnector()) {
|
||||||
connector = brokerService.addConnector("amqp://0.0.0.0:" + port);
|
connector = brokerService.addConnector("amqp://0.0.0.0:" + port);
|
||||||
port = connector.getConnectUri().getPort();
|
port = connector.getConnectUri().getPort();
|
||||||
LOG.debug("Using amqp port " + port);
|
LOG.debug("Using amqp port " + port);
|
||||||
connector = brokerService.addConnector("amqp+nio://0.0.0.0:" + nioPort);
|
}
|
||||||
nioPort = connector.getConnectUri().getPort();
|
if (isUseSslConnector()) {
|
||||||
LOG.debug("Using amqp+nio port " + nioPort);
|
connector = brokerService.addConnector("amqp+ssl://0.0.0.0:" + sslPort);
|
||||||
connector = brokerService.addConnector("amqp+nio+ssl://0.0.0.0:" + nioPlusSslPort);
|
sslPort = connector.getConnectUri().getPort();
|
||||||
nioPlusSslPort = connector.getConnectUri().getPort();
|
LOG.debug("Using amqp+ssl port " + sslPort);
|
||||||
LOG.debug("Using amqp+nio+ssl port " + nioPlusSslPort);
|
}
|
||||||
|
if (isUseNioConnector()) {
|
||||||
|
connector = brokerService.addConnector("amqp+nio://0.0.0.0:" + nioPort);
|
||||||
|
nioPort = connector.getConnectUri().getPort();
|
||||||
|
LOG.debug("Using amqp+nio port " + nioPort);
|
||||||
|
}
|
||||||
|
if (isUseNioPlusSslConnector()) {
|
||||||
|
connector = brokerService.addConnector("amqp+nio+ssl://0.0.0.0:" + nioPlusSslPort);
|
||||||
|
nioPlusSslPort = connector.getConnectUri().getPort();
|
||||||
|
LOG.debug("Using amqp+nio+ssl port " + nioPlusSslPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isUseTcpConnector() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isUseSslConnector() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isUseNioConnector() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isUseNioPlusSslConnector() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startBroker() throws Exception {
|
public void startBroker() throws Exception {
|
||||||
|
|
|
@ -30,4 +30,19 @@ public class JMSClientNioPlusSslTest extends JMSClientSslTest {
|
||||||
LOG.debug("JMSClientNioPlusSslTest.getBrokerPort returning nioPlusSslPort {}", nioPlusSslPort);
|
LOG.debug("JMSClientNioPlusSslTest.getBrokerPort returning nioPlusSslPort {}", nioPlusSslPort);
|
||||||
return nioPlusSslPort;
|
return nioPlusSslPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseTcpConnector() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseNioPlusSslConnector() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTargetConnectorName() {
|
||||||
|
return "amqp+nio+ssl";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,19 @@ public class JMSClientNioTest extends JMSClientTest {
|
||||||
LOG.debug("JMSClientNioTest.getBrokerPort returning nioPort {}", nioPort);
|
LOG.debug("JMSClientNioTest.getBrokerPort returning nioPort {}", nioPort);
|
||||||
return nioPort;
|
return nioPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseTcpConnector() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseNioConnector() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTargetConnectorName() {
|
||||||
|
return "amqp+nio";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.transport.amqp;
|
package org.apache.activemq.transport.amqp;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import java.security.SecureRandom;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.net.ssl.KeyManager;
|
import javax.net.ssl.KeyManager;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import java.security.SecureRandom;
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the JMS client when connected to the SSL transport.
|
* Test the JMS client when connected to the SSL transport.
|
||||||
|
@ -51,4 +52,19 @@ public class JMSClientSslTest extends JMSClientTest {
|
||||||
LOG.debug("JMSClientSslTest.getBrokerPort returning sslPort {}", sslPort);
|
LOG.debug("JMSClientSslTest.getBrokerPort returning sslPort {}", sslPort);
|
||||||
return sslPort;
|
return sslPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseTcpConnector() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseSslConnector() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTargetConnectorName() {
|
||||||
|
return "amqp+ssl";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,7 +690,7 @@ public class JMSClientTest extends AmqpTestSupport {
|
||||||
public void testConnectionsAreClosed() throws Exception {
|
public void testConnectionsAreClosed() throws Exception {
|
||||||
ActiveMQAdmin.enableJMSFrameTracing();
|
ActiveMQAdmin.enableJMSFrameTracing();
|
||||||
|
|
||||||
final ConnectorViewMBean connector = getProxyToConnectionView("amqp");
|
final ConnectorViewMBean connector = getProxyToConnectionView(getTargetConnectorName());
|
||||||
LOG.info("Current number of Connections is: {}", connector.connectionCount());
|
LOG.info("Current number of Connections is: {}", connector.connectionCount());
|
||||||
|
|
||||||
ArrayList<Connection> connections = new ArrayList<Connection>();
|
ArrayList<Connection> connections = new ArrayList<Connection>();
|
||||||
|
@ -715,6 +715,10 @@ public class JMSClientTest extends AmqpTestSupport {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getTargetConnectorName() {
|
||||||
|
return "amqp";
|
||||||
|
}
|
||||||
|
|
||||||
@Test(timeout=30000)
|
@Test(timeout=30000)
|
||||||
public void testExecptionListenerCalledOnBrokerStop() throws Exception {
|
public void testExecptionListenerCalledOnBrokerStop() throws Exception {
|
||||||
ActiveMQAdmin.enableJMSFrameTracing();
|
ActiveMQAdmin.enableJMSFrameTracing();
|
||||||
|
|
|
@ -36,6 +36,16 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class AMQ4753Test extends AmqpTestSupport {
|
public class AMQ4753Test extends AmqpTestSupport {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseTcpConnector() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUseNioPlusSslConnector() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Test(timeout = 120 * 1000)
|
@Test(timeout = 120 * 1000)
|
||||||
public void testAmqpNioPlusSslSendReceive() throws JMSException{
|
public void testAmqpNioPlusSslSendReceive() throws JMSException{
|
||||||
Connection connection = createAMQPConnection(nioPlusSslPort, true);
|
Connection connection = createAMQPConnection(nioPlusSslPort, true);
|
||||||
|
|
Loading…
Reference in New Issue