提交 9a48c10d 编写于 作者: C Chris Beams

Segregate tests that depend on the jmxmp: protocol

This commit introduces TestGroup#JMXMP and adds assumptions to related
tests accordingly. These tests require the jmxoptional_remote jar on the
classpath, and are run nightly in the SPR-PERF build.

Issue: SPR-8089
上级 10648942
......@@ -25,18 +25,21 @@ import org.junit.Before;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.tests.TestGroup;
import org.springframework.util.MBeanTestUtils;
import static org.junit.Assert.*;
/**
* <strong>Note:</strong> the JMX test suite requires the presence of the
* {@code jmxremote_optional.jar} in your classpath. Thus, if you
* run into the <em>"Unsupported protocol: jmxmp"</em> error, you will
* need to download the
* <a href="http://www.oracle.com/technetwork/java/javase/tech/download-jsp-141676.html">JMX Remote API 1.0.1_04 Reference Implementation</a>
* from Oracle and extract {@code jmxremote_optional.jar} into your
* classpath, for example in the {@code lib/ext} folder of your JVM.
* <strong>Note:</strong> certain tests throughout this hierarchy require the presence of
* the {@code jmxremote_optional.jar} in your classpath. For this reason, these tests are
* run only if {@link TestGroup#JMXMP} is enabled. If you wish to run these tests, follow
* the instructions in the TestGroup class to enable JMXMP tests. If you run into the
* <em>"Unsupported protocol: jmxmp"</em> error, you will need to download the
* <a href="http://www.oracle.com/technetwork/java/javase/tech/download-jsp-141676.html">
* JMX Remote API 1.0.1_04 Reference Implementation</a> from Oracle and extract
* {@code jmxremote_optional.jar} into your classpath, for example in the {@code lib/ext}
* folder of your JVM.
* See also <a href="https://issuetracker.springsource.com/browse/EBR-349">EBR-349</a>.
*
* @author Rob Harrop
......
......@@ -36,6 +36,10 @@ import org.springframework.jmx.JmxException;
import org.springframework.jmx.JmxTestBean;
import org.springframework.jmx.export.MBeanExporter;
import org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
/**
* @author Rob Harrop
......@@ -204,6 +208,8 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
if (!runTests)
return;
Assume.group(TestGroup.JMXMP);
JMXServiceURL url = new JMXServiceURL("service:jmx:jmxmp://localhost:9876");
JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, getServer());
......
......@@ -26,6 +26,9 @@ import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
/**
* @author Rob Harrop
* @author Chris Beams
......@@ -40,6 +43,9 @@ public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTes
@Override
public void onSetUp() throws Exception {
runTests = false;
Assume.group(TestGroup.JMXMP);
runTests = true;
super.onSetUp();
this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer());
try {
......@@ -65,8 +71,12 @@ public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTes
if (this.connector != null) {
this.connector.close();
}
this.connectorServer.stop();
super.tearDown();
if (this.connectorServer != null) {
this.connectorServer.stop();
}
if (runTests) {
super.tearDown();
}
}
}
......@@ -30,6 +30,10 @@ import javax.management.remote.JMXServiceURL;
import org.junit.Test;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
/**
* @author Rob Harrop
......@@ -38,6 +42,20 @@ import org.springframework.jmx.AbstractMBeanServerTests;
public class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests {
private static final String OBJECT_NAME = "spring:type=connector,name=test";
private boolean runTests = false;
@Override
protected void onSetUp() throws Exception {
Assume.group(TestGroup.JMXMP);
runTests = true;
}
@Override
public void tearDown() throws Exception {
if (runTests) {
super.tearDown();
}
}
@Test
public void testStartupWithLocatedServer() throws Exception {
......
......@@ -26,6 +26,10 @@ import javax.management.remote.JMXServiceURL;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
/**
* @author Rob Harrop
......@@ -45,6 +49,7 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
@Test
public void testTestValidConnection() throws Exception {
Assume.group(TestGroup.JMXMP);
JMXConnectorServer connectorServer = getConnectorServer();
connectorServer.start();
......@@ -78,7 +83,9 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
}
}
@Test
public void testTestWithLazyConnection() throws Exception {
Assume.group(TestGroup.JMXMP);
MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
bean.setServiceUrl(SERVICE_URL);
bean.setConnectOnStartup(false);
......
......@@ -48,7 +48,13 @@ public enum TestGroup {
* {@code StopWatch}, etc. should be considered a candidate as their successful
* execution is likely to be based on events occurring within a given time window.
*/
PERFORMANCE;
PERFORMANCE,
/**
* Tests requiring the presence of jmxremote_optional.jar in jre/lib/ext in order to
* avoid "Unsupported protocol: jmxmp" errors.
*/
JMXMP;
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册