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;
|
||||
|
||||
public class AmqpNioTest extends AmqpTestSupport {
|
||||
|
||||
protected void addAMQPConnector(BrokerService brokerService) throws Exception {
|
||||
brokerService.addConnector("amqp+nio://localhost:1883?maxInactivityDuration=-1");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,15 +41,6 @@ public class AmqpSslTest extends AmqpTestSupport {
|
|||
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 {
|
||||
|
||||
@Override
|
||||
|
@ -65,5 +56,4 @@ public class AmqpSslTest extends AmqpTestSupport {
|
|||
return new X509Certificate[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -117,19 +117,45 @@ public class AmqpTestSupport {
|
|||
}
|
||||
|
||||
protected void addAMQPConnector() throws Exception {
|
||||
TransportConnector connector = brokerService.addConnector("amqp+ssl://0.0.0.0:" + sslPort);
|
||||
sslPort = connector.getConnectUri().getPort();
|
||||
LOG.debug("Using amqp+ssl port " + sslPort);
|
||||
TransportConnector connector = null;
|
||||
|
||||
if (isUseTcpConnector()) {
|
||||
connector = brokerService.addConnector("amqp://0.0.0.0:" + port);
|
||||
port = connector.getConnectUri().getPort();
|
||||
LOG.debug("Using amqp port " + port);
|
||||
}
|
||||
if (isUseSslConnector()) {
|
||||
connector = brokerService.addConnector("amqp+ssl://0.0.0.0:" + sslPort);
|
||||
sslPort = connector.getConnectUri().getPort();
|
||||
LOG.debug("Using amqp+ssl port " + sslPort);
|
||||
}
|
||||
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 {
|
||||
if (brokerService != null) {
|
||||
|
|
|
@ -30,4 +30,19 @@ public class JMSClientNioPlusSslTest extends JMSClientSslTest {
|
|||
LOG.debug("JMSClientNioPlusSslTest.getBrokerPort returning nioPlusSslPort {}", 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);
|
||||
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;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.JMSException;
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.SSLContext;
|
||||
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.
|
||||
|
@ -51,4 +52,19 @@ public class JMSClientSslTest extends JMSClientTest {
|
|||
LOG.debug("JMSClientSslTest.getBrokerPort returning sslPort {}", 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 {
|
||||
ActiveMQAdmin.enableJMSFrameTracing();
|
||||
|
||||
final ConnectorViewMBean connector = getProxyToConnectionView("amqp");
|
||||
final ConnectorViewMBean connector = getProxyToConnectionView(getTargetConnectorName());
|
||||
LOG.info("Current number of Connections is: {}", connector.connectionCount());
|
||||
|
||||
ArrayList<Connection> connections = new ArrayList<Connection>();
|
||||
|
@ -715,6 +715,10 @@ public class JMSClientTest extends AmqpTestSupport {
|
|||
}));
|
||||
}
|
||||
|
||||
protected String getTargetConnectorName() {
|
||||
return "amqp";
|
||||
}
|
||||
|
||||
@Test(timeout=30000)
|
||||
public void testExecptionListenerCalledOnBrokerStop() throws Exception {
|
||||
ActiveMQAdmin.enableJMSFrameTracing();
|
||||
|
|
|
@ -36,6 +36,16 @@ import org.junit.Test;
|
|||
|
||||
public class AMQ4753Test extends AmqpTestSupport {
|
||||
|
||||
@Override
|
||||
protected boolean isUseTcpConnector() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isUseNioPlusSslConnector() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Test(timeout = 120 * 1000)
|
||||
public void testAmqpNioPlusSslSendReceive() throws JMSException{
|
||||
Connection connection = createAMQPConnection(nioPlusSslPort, true);
|
||||
|
|
Loading…
Reference in New Issue