mirror of https://github.com/apache/activemq.git
[no jira] remove hard coded 1099 dep to resolve ci failure in JmxAuditLogTest
This commit is contained in:
parent
2769298cf6
commit
3a0a7238b1
|
@ -18,6 +18,7 @@ package org.apache.activemq;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.Connection;
|
||||
|
@ -27,6 +28,7 @@ import javax.jms.Message;
|
|||
import javax.jms.TextMessage;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
import org.apache.activemq.broker.BrokerRegistry;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
|
|
|
@ -38,12 +38,16 @@ import org.apache.log4j.Logger;
|
|||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.apache.activemq.util.TestUtils.findOpenPort;
|
||||
|
||||
public class JmxAuditLogTest extends TestSupport
|
||||
{
|
||||
protected BrokerService broker;
|
||||
|
||||
protected ActiveMQQueue queue;
|
||||
|
||||
int portToUse;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
|
@ -55,7 +59,8 @@ public class JmxAuditLogTest extends TestSupport
|
|||
|
||||
broker = new BrokerService();
|
||||
broker.setUseJmx(true);
|
||||
broker.setManagementContext(createManagementContext("broker", 1099));
|
||||
portToUse = findOpenPort();
|
||||
broker.setManagementContext(createManagementContext("broker", portToUse));
|
||||
broker.setPopulateUserNameInMBeans(true);
|
||||
broker.setDestinations(createDestinations());
|
||||
broker.start();
|
||||
|
@ -126,7 +131,7 @@ public class JmxAuditLogTest extends TestSupport
|
|||
};
|
||||
log4jLogger.addAppender(appender);
|
||||
|
||||
MBeanServerConnection conn = createJMXConnector(1099);
|
||||
MBeanServerConnection conn = createJMXConnector(portToUse);
|
||||
ObjectName queueObjName = new ObjectName(broker.getBrokerObjectName() + ",destinationType=Queue,destinationName=" + queue.getQueueName());
|
||||
|
||||
Object[] params = {"body", "testUser", "testPassword"};
|
||||
|
|
|
@ -18,21 +18,6 @@
|
|||
package org.apache.activemq.proxy;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.JMSSecurityException;
|
||||
import javax.jms.Session;
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.broker.BrokerPlugin;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
|
@ -45,6 +30,18 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.JMSSecurityException;
|
||||
import javax.jms.Session;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.activemq.util.TestUtils.findOpenPort;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class AMQ4889Test {
|
||||
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(AMQ4889Test.class);
|
||||
|
@ -140,24 +137,4 @@ public class AMQ4889Test {
|
|||
assertEquals(val, proxyConnector.getConnectionCount());
|
||||
}
|
||||
|
||||
protected int findOpenPort() throws IOException {
|
||||
int openPort = 0;
|
||||
ServerSocket ss = null;
|
||||
try {
|
||||
ss = ServerSocketFactory.getDefault().createServerSocket(0);
|
||||
openPort = ss.getLocalPort();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Could not locate an open port: ", e);
|
||||
throw e;
|
||||
} finally {
|
||||
try {
|
||||
if (ss != null ) {
|
||||
ss.close();
|
||||
}
|
||||
} catch (IOException e) { // ignore
|
||||
}
|
||||
}
|
||||
|
||||
return openPort;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue