diff --git a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java
index 8010dca2e7..ab05a3ea6e 100644
--- a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java
@@ -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.*;
/**
- * Note: the JMX test suite requires the presence of the
- * {@code jmxremote_optional.jar} in your classpath. Thus, if you
- * run into the "Unsupported protocol: jmxmp" error, you will
- * need to download the
- * JMX Remote API 1.0.1_04 Reference Implementation
- * from Oracle and extract {@code jmxremote_optional.jar} into your
- * classpath, for example in the {@code lib/ext} folder of your JVM.
+ * Note: 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
+ * "Unsupported protocol: jmxmp" error, you will need to download the
+ *
+ * JMX Remote API 1.0.1_04 Reference Implementation from Oracle and extract
+ * {@code jmxremote_optional.jar} into your classpath, for example in the {@code lib/ext}
+ * folder of your JVM.
* See also EBR-349.
*
* @author Rob Harrop
diff --git a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java
index c8d7b1c6b0..e1bd521a1d 100644
--- a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java
@@ -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());
diff --git a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java
index c36e788f1e..74a29b0be0 100644
--- a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java
@@ -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();
+ }
}
}
diff --git a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java
index 6bf72b5dbf..6d66caa79c 100644
--- a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java
@@ -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 {
diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java
index 0a346b6fc1..c9c83cffae 100644
--- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java
@@ -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);
diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/test/java/org/springframework/tests/TestGroup.java
index 7bd0ccdfd5..662f0dab53 100644
--- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java
+++ b/spring-core/src/test/java/org/springframework/tests/TestGroup.java
@@ -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;
/**