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 12dbf05a50..ab05a3ea6e 100644
--- a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,32 +20,38 @@ import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
-import junit.framework.TestCase;
-
+import org.junit.After;
+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
* @author Juergen Hoeller
* @author Sam Brannen
+ * @author Chris Beams
*/
-public abstract class AbstractMBeanServerTests extends TestCase {
+public abstract class AbstractMBeanServerTests {
protected MBeanServer server;
- @Override
+ @Before
public final void setUp() throws Exception {
this.server = MBeanServerFactory.createMBeanServer();
try {
@@ -64,8 +70,8 @@ public abstract class AbstractMBeanServerTests extends TestCase {
return ctx;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
releaseServer();
onTearDown();
}
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 7842ee328c..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
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -29,18 +29,23 @@ import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
-import org.junit.Ignore;
+import org.junit.Test;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.jmx.IJmxTestBean;
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
* @author Juergen Hoeller
* @author Sam Brannen
+ * @author Chris Beams
*/
public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
@@ -78,6 +83,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
return (IJmxTestBean) factory.getObject();
}
+ @Test
public void testProxyClassIsDifferent() throws Exception {
if (!runTests)
return;
@@ -85,6 +91,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertTrue("The proxy class should be different than the base class", (proxy.getClass() != IJmxTestBean.class));
}
+ @Test
public void testDifferentProxiesSameClass() throws Exception {
if (!runTests)
return;
@@ -95,6 +102,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertSame("The proxy classes should be the same", proxy1.getClass(), proxy2.getClass());
}
+ @Test
public void testGetAttributeValue() throws Exception {
if (!runTests)
return;
@@ -103,6 +111,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertEquals("The age should be 100", 100, age);
}
+ @Test
public void testSetAttributeValue() throws Exception {
if (!runTests)
return;
@@ -111,6 +120,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertEquals("The name of the bean should have been updated", "Rob Harrop", target.getName());
}
+ @Test
public void testSetAttributeValueWithRuntimeException() throws Exception {
if (!runTests)
return;
@@ -123,6 +133,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAttributeValueWithCheckedException() throws Exception {
if (!runTests)
return;
@@ -135,6 +146,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAttributeValueWithIOException() throws Exception {
if (!runTests)
return;
@@ -147,6 +159,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetReadOnlyAttribute() throws Exception {
if (!runTests)
return;
@@ -159,6 +172,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testInvokeNoArgs() throws Exception {
if (!runTests)
return;
@@ -167,6 +181,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertEquals("The operation should return 1", 1, result);
}
+ @Test
public void testInvokeArgs() throws Exception {
if (!runTests)
return;
@@ -175,6 +190,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertEquals("The operation should return 3", 3, result);
}
+ @Test
public void testInvokeUnexposedMethodWithException() throws Exception {
if (!runTests)
return;
@@ -187,19 +203,13 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
}
- // TODO [SPR-8089] Clean up ignored JMX tests.
- //
- // @Ignore should have no effect for JUnit 3.8 tests; however, it appears
- // that tests on the CI server -- as well as those in Eclipse -- do in
- // fact get ignored. So we leave @Ignore here so that developers can
- // easily search for ignored tests.
- //
- // Once fixed, renamed to test* instead of ignore*.
- @Ignore("Requires jmxremote_optional.jar; see comments in AbstractMBeanServerTests for details.")
- public void ignoreTestLazyConnectionToRemote() throws Exception {
+ @Test
+ public void testTestLazyConnectionToRemote() throws Exception {
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/RemoteMBeanClientInterceptorTestsIgnore.java b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java
similarity index 75%
rename from spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTestsIgnore.java
rename to spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java
index 7082efec13..74a29b0be0 100644
--- a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTestsIgnore.java
+++ b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -26,19 +26,14 @@ import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
-import org.junit.Ignore;
+import org.springframework.tests.Assume;
+import org.springframework.tests.TestGroup;
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
-// TODO [SPR-8089] Clean up ignored JMX tests.
-//
-// @Ignore should have no effect for JUnit 3.8 tests; however, it appears
-// that tests on the CI server -- as well as those in Eclipse -- do in
-// fact get ignored. So we leave @Ignore here so that developers can
-// easily search for ignored tests.
-@Ignore("Requires jmxremote_optional.jar; see comments in AbstractMBeanServerTests for details.")
-public class RemoteMBeanClientInterceptorTestsIgnore extends MBeanClientInterceptorTests {
+public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTests {
private static final String SERVICE_URL = "service:jmx:jmxmp://localhost:9876";
@@ -48,6 +43,9 @@ public class RemoteMBeanClientInterceptorTestsIgnore extends MBeanClientIntercep
@Override
public void onSetUp() throws Exception {
+ runTests = false;
+ Assume.group(TestGroup.JMXMP);
+ runTests = true;
super.onSetUp();
this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer());
try {
@@ -73,8 +71,12 @@ public class RemoteMBeanClientInterceptorTestsIgnore extends MBeanClientIntercep
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/export/CustomEditorConfigurerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java
index 2c71236d78..1901901114 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java
@@ -22,8 +22,11 @@ import java.util.Date;
import javax.management.ObjectName;
+import org.junit.Test;
import org.springframework.jmx.AbstractJmxTests;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
*/
@@ -36,6 +39,7 @@ public class CustomEditorConfigurerTests extends AbstractJmxTests {
return "org/springframework/jmx/export/customConfigurer.xml";
}
+ @Test
public void testDatesInJmx() throws Exception {
// System.out.println(getServer().getClass().getName());
ObjectName oname = new ObjectName("bean:name=dateRange");
@@ -47,6 +51,7 @@ public class CustomEditorConfigurerTests extends AbstractJmxTests {
assertEquals("endDate ", getEndDate(), endJmx);
}
+ @Test
public void testGetDates() throws Exception {
DateRange dr = (DateRange) getContext().getBean("dateRange");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java
index 59740fa0db..f2bee32668 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java
@@ -28,6 +28,8 @@ import org.springframework.jmx.JmxTestBean;
import org.springframework.jmx.export.naming.ObjectNamingStrategy;
import org.springframework.jmx.support.ObjectNameManager;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
* @author Juergen Hoeller
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java
index 2d7d9e2639..c08a9f73b2 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java
@@ -33,6 +33,7 @@ import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -50,6 +51,8 @@ import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.TestBean;
+import static org.junit.Assert.*;
+
/**
* Integration tests for the {@link MBeanExporter} class.
*
@@ -66,6 +69,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
private static final String OBJECT_NAME = "spring:test=jmxMBeanAdaptor";
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNonNotificationListenerType() throws Exception {
Map listeners = new HashMap();
// put a non-NotificationListener instance in as a value...
@@ -80,6 +84,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNullNotificationListenerType() throws Exception {
Map listeners = new HashMap();
// put null in as a value...
@@ -94,6 +99,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerForNonExistentMBean() throws Exception {
Map listeners = new HashMap();
NotificationListener dummyListener = new NotificationListener() {
@@ -117,6 +123,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testWithSuppliedMBeanServer() throws Exception {
MBeanExporter exporter = new MBeanExporter();
exporter.setBeans(getBeanMap());
@@ -127,6 +134,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
/** Fails if JVM platform MBean server has been started already
+ @Test
public void testWithLocatedMBeanServer() throws Exception {
MBeanExporter adaptor = new MBeanExporter();
adaptor.setBeans(getBeanMap());
@@ -136,6 +144,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
*/
+ @Test
public void testUserCreatedMBeanRegWithDynamicMBean() throws Exception {
Map map = new HashMap();
map.put("spring:name=dynBean", new TestDynamicMBean());
@@ -153,6 +162,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertFalse("Assembler should not have been invoked", asm.invoked);
}
+ @Test
public void testAutodetectMBeans() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectMBeans.xml", getClass()));
@@ -170,6 +180,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testAutodetectWithExclude() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectMBeans.xml", getClass()));
@@ -189,6 +200,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testAutodetectLazyMBeans() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectLazyMBeans.xml", getClass()));
@@ -210,6 +222,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testAutodetectNoMBeans() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("autodetectNoMBeans.xml", getClass()));
@@ -220,6 +233,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testWithMBeanExporterListeners() throws Exception {
MockMBeanExporterListener listener1 = new MockMBeanExporterListener();
MockMBeanExporterListener listener2 = new MockMBeanExporterListener();
@@ -235,6 +249,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertListener(listener2);
}
+ @Test
public void testExportJdkProxy() throws Exception {
JmxTestBean bean = new JmxTestBean();
bean.setName("Rob Harrop");
@@ -260,6 +275,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertEquals("Rob Harrop", nameValue);
}
+ @Test
public void testSelfNaming() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(OBJECT_NAME);
SelfNamingTestBean testBean = new SelfNamingTestBean();
@@ -278,6 +294,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertNotNull(instance);
}
+ @Test
public void testRegisterIgnoreExisting() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(OBJECT_NAME);
@@ -311,6 +328,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertEquals("Rob Harrop", server.getAttribute(objectName, "Name"));
}
+ @Test
public void testRegisterReplaceExisting() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(OBJECT_NAME);
@@ -339,6 +357,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertEquals("Sally Greenwood", server.getAttribute(objectName, "Name"));
}
+ @Test
public void testWithExposeClassLoader() throws Exception {
String name = "Rob Harrop";
String otherName = "Juergen Hoeller";
@@ -368,6 +387,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
assertEquals("Incorrect updated name.", otherName, bean.getName());
}
+ @Test
public void testBonaFideMBeanIsNotExportedWhenAutodetectIsTotallyTurnedOff() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@@ -386,6 +406,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
exporter.afterPropertiesSet();
}
+ @Test
public void testOnlyBonaFideMBeanIsExportedWhenAutodetectIsMBeanOnly() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@@ -405,6 +426,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
ObjectNameManager.getInstance(exportedBeanName));
}
+ @Test
public void testBonaFideMBeanAndRegularBeanExporterWithAutodetectAll() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@@ -428,6 +450,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
ObjectNameManager.getInstance(notToBeExportedBeanName));
}
+ @Test
public void testBonaFideMBeanIsNotExportedWithAutodetectAssembler() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@@ -450,6 +473,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
/**
* Want to ensure that said MBean is not exported twice.
*/
+ @Test
public void testBonaFideMBeanExplicitlyExportedAndAutodetectionIsOn() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@@ -468,6 +492,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
ObjectNameManager.getInstance(OBJECT_NAME));
}
+ @Test
public void testSetAutodetectModeToOutOfRangeNegativeValue() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -478,6 +503,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAutodetectModeToOutOfRangePositiveValue() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -488,6 +514,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAutodetectModeNameToNull() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -498,6 +525,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAutodetectModeNameToAnEmptyString() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -508,6 +536,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAutodetectModeNameToAWhitespacedString() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -518,6 +547,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testSetAutodetectModeNameToARubbishValue() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -528,6 +558,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testNotRunningInBeanFactoryAndPassedBeanNameToExport() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -541,6 +572,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
}
}
+ @Test
public void testNotRunningInBeanFactoryAndAutodetectionIsOn() throws Exception {
try {
MBeanExporter exporter = new MBeanExporter();
@@ -555,6 +587,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
/**
* SPR-2158
*/
+ @Test
public void testMBeanIsNotUnregisteredSpuriouslyIfSomeExternalProcessHasUnregisteredMBean() throws Exception {
MBeanExporter exporter = new MBeanExporter();
exporter.setBeans(getBeanMap());
@@ -574,6 +607,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
/**
* SPR-3302
*/
+ @Test
public void testBeanNameCanBeUsedInNotificationListenersMap() throws Exception {
String beanName = "charlesDexterWard";
BeanDefinitionBuilder testBean = BeanDefinitionBuilder.rootBeanDefinition(JmxTestBean.class);
@@ -595,6 +629,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
exporter.afterPropertiesSet();
}
+ @Test
public void testWildcardCanBeUsedInNotificationListenersMap() throws Exception {
String beanName = "charlesDexterWard";
BeanDefinitionBuilder testBean = BeanDefinitionBuilder.rootBeanDefinition(JmxTestBean.class);
@@ -619,6 +654,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
/*
* SPR-3625
*/
+ @Test
public void testMBeanIsUnregisteredForRuntimeExceptionDuringInitialization() throws Exception {
BeanDefinitionBuilder builder1 = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
BeanDefinitionBuilder builder2 = BeanDefinitionBuilder
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java
index 4524412307..a6423dcee8 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java
@@ -26,6 +26,7 @@ import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectName;
+import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.jmx.JmxTestBean;
@@ -33,6 +34,8 @@ import org.springframework.jmx.access.NotificationListenerRegistrar;
import org.springframework.jmx.export.naming.SelfNaming;
import org.springframework.jmx.support.ObjectNameManager;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
* @author Mark Fisher
@@ -41,6 +44,7 @@ import org.springframework.jmx.support.ObjectNameManager;
public class NotificationListenerTests extends AbstractMBeanServerTests {
@SuppressWarnings({"rawtypes", "unchecked"})
+ @Test
public void testRegisterNotificationListenerForMBean() throws Exception {
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
JmxTestBean bean = new JmxTestBean();
@@ -66,6 +70,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerWithWildcard() throws Exception {
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
JmxTestBean bean = new JmxTestBean();
@@ -90,6 +95,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
assertEquals("Listener not notified", 1, listener.getCount(attributeName));
}
+ @Test
public void testRegisterNotificationListenerWithHandback() throws Exception {
String objectName = "spring:name=Test";
JmxTestBean bean = new JmxTestBean();
@@ -120,6 +126,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
assertEquals("Handback object not transmitted correctly", handback, listener.getLastHandback(attributeName));
}
+ @Test
public void testRegisterNotificationListenerForAllMBeans() throws Exception {
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
JmxTestBean bean = new JmxTestBean();
@@ -146,6 +153,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings("serial")
+ @Test
public void testRegisterNotificationListenerWithFilter() throws Exception {
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
JmxTestBean bean = new JmxTestBean();
@@ -186,6 +194,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
assertEquals("Listener incorrectly notified for Age", 0, listener.getCount(ageAttribute));
}
+ @Test
public void testCreationWithNoNotificationListenerSet() {
try {
new NotificationListenerBean().afterPropertiesSet();
@@ -195,6 +204,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerWithBeanNameAndBeanNameInBeansMap() throws Exception {
String beanName = "testBean";
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
@@ -225,6 +235,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerWithBeanNameAndBeanInstanceInBeansMap() throws Exception {
String beanName = "testBean";
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
@@ -255,6 +266,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerWithBeanNameBeforeObjectNameMappedToSameBeanInstance() throws Exception {
String beanName = "testBean";
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
@@ -286,6 +298,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerWithObjectNameBeforeBeanNameMappedToSameBeanInstance() throws Exception {
String beanName = "testBean";
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
@@ -317,6 +330,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
public void testRegisterNotificationListenerWithTwoBeanNamesMappedToDifferentBeanInstances() throws Exception {
String beanName1 = "testBean1";
String beanName2 = "testBean2";
@@ -359,6 +373,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
assertEquals("Listener not notified for testBean2", 2, listener.getCount("Age"));
}
+ @Test
public void testNotificationListenerRegistrar() throws Exception {
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
JmxTestBean bean = new JmxTestBean();
@@ -391,6 +406,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
assertEquals("Listener notified after destruction", 1, listener.getCount(attributeName));
}
+ @Test
public void testNotificationListenerRegistrarWithMultipleNames() throws Exception {
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
ObjectName objectName2 = ObjectName.getInstance("spring:name=Test2");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java
index a6abda7ed2..2237fcc155 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java
@@ -32,12 +32,15 @@ import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationListener;
import javax.management.ReflectionException;
+import org.junit.Test;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.jmx.export.notification.NotificationPublisher;
import org.springframework.jmx.export.notification.NotificationPublisherAware;
import org.springframework.jmx.support.ObjectNameManager;
+import static org.junit.Assert.*;
+
/**
* Integration tests for the Spring JMX {@link NotificationPublisher} functionality.
*
@@ -48,6 +51,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests {
private CountingNotificationListener listener = new CountingNotificationListener();
+ @Test
public void testSimpleBean() throws Exception {
// start the MBeanExporter
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml");
@@ -60,6 +64,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests {
assertEquals("Notification not sent", 1, listener.count);
}
+ @Test
public void testSimpleBeanRegisteredManually() throws Exception {
// start the MBeanExporter
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml");
@@ -74,6 +79,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests {
assertEquals("Notification not sent", 1, listener.count);
}
+ @Test
public void testMBean() throws Exception {
// start the MBeanExporter
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml");
@@ -86,6 +92,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests {
}
/*
+ @Test
public void testStandardMBean() throws Exception {
// start the MBeanExporter
ApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/jmx/export/notificationPublisherTests.xml");
@@ -97,6 +104,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests {
}
*/
+ @Test
public void testLazyInit() throws Exception {
// start the MBeanExporter
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherLazyTests.xml");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java
index c95000c59d..256372eb1b 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -18,11 +18,15 @@ package org.springframework.jmx.export;
import javax.management.ObjectName;
+import org.junit.Test;
import org.springframework.jmx.AbstractJmxTests;
import org.springframework.jmx.IJmxTestBean;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
public class PropertyPlaceholderConfigurerTests extends AbstractJmxTests {
@@ -31,6 +35,7 @@ public class PropertyPlaceholderConfigurerTests extends AbstractJmxTests {
return "org/springframework/jmx/export/propertyPlaceholderConfigurer.xml";
}
+ @Test
public void testPropertiesReplaced() {
IJmxTestBean bean = (IJmxTestBean) getContext().getBean("testBean");
@@ -38,6 +43,7 @@ public class PropertyPlaceholderConfigurerTests extends AbstractJmxTests {
assertEquals("Age is incorrect", 100, bean.getAge());
}
+ @Test
public void testPropertiesCorrectInJmx() throws Exception {
ObjectName oname = new ObjectName("bean:name=proxyTestBean1");
Object name = getServer().getAttribute(oname, "Name");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java
index d74787b7f8..11c68dcb99 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -20,15 +20,22 @@ import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
+import org.junit.Test;
import org.springframework.jmx.IJmxTestBean;
import org.springframework.jmx.export.assembler.AbstractMetadataAssemblerTests;
import org.springframework.jmx.export.metadata.JmxAttributeSource;
-/** @author Rob Harrop */
+import static org.junit.Assert.*;
+
+/**
+ * @author Rob Harrop
+ * @author Chris Beams
+ */
public class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerTests {
private static final String OBJECT_NAME = "bean:name=testBean4";
+ @Test
public void testAttributeFromInterface() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute("Colour");
@@ -36,12 +43,14 @@ public class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerT
assertTrue("The name attribute should be readable", attr.isReadable());
}
+ @Test
public void testOperationFromInterface() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanOperationInfo op = inf.getOperation("fromInterface");
assertNotNull(op);
}
+ @Test
public void testOperationOnGetter() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java
index 2c4a06e0be..42962c5f64 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java
@@ -28,12 +28,16 @@ import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
+import org.junit.Test;
import org.springframework.jmx.AbstractJmxTests;
import org.springframework.jmx.IJmxTestBean;
import org.springframework.jmx.support.ObjectNameManager;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
@@ -43,12 +47,14 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
protected abstract String getObjectName();
+ @Test
public void testMBeanRegistration() throws Exception {
// beans are registered at this point - just grab them from the server
ObjectInstance instance = getObjectInstance();
assertNotNull("Bean should not be null", instance);
}
+ @Test
public void testRegisterOperations() throws Exception {
IJmxTestBean bean = getBean();
assertNotNull(bean);
@@ -57,6 +63,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
getExpectedOperationCount(), inf.getOperations().length);
}
+ @Test
public void testRegisterAttributes() throws Exception {
IJmxTestBean bean = getBean();
assertNotNull(bean);
@@ -65,11 +72,13 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
getExpectedAttributeCount(), inf.getAttributes().length);
}
+ @Test
public void testGetMBeanInfo() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
assertNotNull("MBeanInfo should not be null", info);
}
+ @Test
public void testGetMBeanAttributeInfo() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
MBeanAttributeInfo[] inf = info.getAttributes();
@@ -84,6 +93,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
}
}
+ @Test
public void testGetMBeanOperationInfo() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
MBeanOperationInfo[] inf = info.getOperations();
@@ -98,6 +108,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
}
}
+ @Test
public void testDescriptionNotNull() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
@@ -105,6 +116,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
info.getDescription());
}
+ @Test
public void testSetAttribute() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
getServer().setAttribute(objectName, new Attribute(NAME_ATTRIBUTE, "Rob Harrop"));
@@ -112,6 +124,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
assertEquals("Rob Harrop", bean.getName());
}
+ @Test
public void testGetAttribute() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
getBean().setName("John Smith");
@@ -119,6 +132,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
assertEquals("Incorrect result", "John Smith", val);
}
+ @Test
public void testOperationInvocation() throws Exception{
ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
Object result = getServer().invoke(objectName, "add",
@@ -126,6 +140,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
assertEquals("Incorrect result", new Integer(50), result);
}
+ @Test
public void testAttributeInfoHasDescriptors() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
@@ -141,6 +156,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
desc.getFieldValue("setMethod"));
}
+ @Test
public void testAttributeHasCorrespondingOperations() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
@@ -159,6 +175,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
assertEquals("set operation should have role \"setter\"", "setter", set.getDescriptor().getFieldValue("role"));
}
+ @Test
public void testNotificationMetadata() throws Exception {
ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo();
MBeanNotificationInfo[] notifications = info.getNotifications();
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java
index 99cefe7158..0c3ece7839 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java
@@ -26,6 +26,7 @@ import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;
+import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.jmx.IJmxTestBean;
import org.springframework.jmx.JmxTestBean;
@@ -34,6 +35,8 @@ import org.springframework.jmx.export.metadata.JmxAttributeSource;
import org.springframework.jmx.support.ObjectNameManager;
import org.springframework.tests.aop.interceptor.NopInterceptor;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
* @author Chris Beams
@@ -44,12 +47,14 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
protected static final String CACHE_ENTRIES_METRIC = "CacheEntries";
+ @Test
public void testDescription() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
assertEquals("The descriptions are not the same", "My Managed Bean",
info.getDescription());
}
+ @Test
public void testAttributeDescriptionOnSetter() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute(AGE_ATTRIBUTE);
@@ -57,6 +62,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
"The Age Attribute", attr.getDescription());
}
+ @Test
public void testAttributeDescriptionOnGetter() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE);
@@ -67,12 +73,14 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
/**
* Tests the situation where the attribute is only defined on the getter.
*/
+ @Test
public void testReadOnlyAttribute() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute(AGE_ATTRIBUTE);
assertFalse("The age attribute should not be writable", attr.isWritable());
}
+ @Test
public void testReadWriteAttribute() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE);
@@ -83,6 +91,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
/**
* Tests the situation where the property only has a getter.
*/
+ @Test
public void testWithOnlySetter() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = inf.getAttribute("NickName");
@@ -92,12 +101,14 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
/**
* Tests the situation where the property only has a setter.
*/
+ @Test
public void testWithOnlyGetter() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute("Superman");
assertNotNull("Attribute should not be null", attr);
}
+ @Test
public void testManagedResourceDescriptor() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getMBeanDescriptor();
@@ -111,6 +122,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
assertEquals("Persist Name should be bar", "bar.jmx", desc.getFieldValue("persistName"));
}
+ @Test
public void testAttributeDescriptor() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getAttribute(NAME_ATTRIBUTE).getDescriptor();
@@ -121,6 +133,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
assertEquals("Persist Period should be 300", "300", desc.getFieldValue("persistPeriod"));
}
+ @Test
public void testOperationDescriptor() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getOperation("myOperation").getDescriptor();
@@ -129,6 +142,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
assertEquals("Role should be \"operation\"", "operation", desc.getFieldValue("role"));
}
+ @Test
public void testOperationParameterMetadata() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanOperationInfo oper = info.getOperation("add");
@@ -142,6 +156,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
assertEquals("Incorrect type for y param", int.class.getName(), params[1].getType());
}
+ @Test
public void testWithCglibProxy() throws Exception {
IJmxTestBean tb = createJmxTestBean();
ProxyFactory pf = new ProxyFactory();
@@ -169,6 +184,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
assertTrue("Not included in autodetection", assembler.includeBean(proxy.getClass(), "some bean name"));
}
+ @Test
public void testMetricDescription() throws Exception {
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo metric = inf.getAttribute(QUEUE_SIZE_METRIC);
@@ -179,6 +195,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
"The QueueSize metric", operation.getDescription());
}
+ @Test
public void testMetricDescriptor() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getAttribute(QUEUE_SIZE_METRIC).getDescriptor();
@@ -191,6 +208,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
assertEquals("Metric Category should be utilization", "utilization",desc.getFieldValue("metricCategory"));
}
+ @Test
public void testMetricDescriptorDefaults() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getAttribute(CACHE_ENTRIES_METRIC).getDescriptor();
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java
index d4034ed449..e7bb1d68c9 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -19,8 +19,13 @@ package org.springframework.jmx.export.assembler;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
public class InterfaceBasedMBeanInfoAssemblerCustomTests extends AbstractJmxAssemblerTests {
@@ -48,6 +53,7 @@ public class InterfaceBasedMBeanInfoAssemblerCustomTests extends AbstractJmxAsse
return assembler;
}
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java
index 5cd8488eb7..1a485f377e 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java
@@ -22,13 +22,19 @@ import javax.management.MBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests {
protected static final String OBJECT_NAME = "bean:name=testBean4";
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
@@ -37,6 +43,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
assertFalse("Age is not writable", attr.isWritable());
}
+ @Test
public void testWithUnknownClass() throws Exception {
try {
getWithMapping("com.foo.bar.Unknown");
@@ -47,6 +54,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
}
}
+ @Test
public void testWithNonInterface() throws Exception {
try {
getWithMapping("JmxTestBean");
@@ -57,7 +65,8 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
}
}
- public void ignoreTestWithFallThrough() throws Exception {
+ @Test
+ public void testWithFallThrough() throws Exception {
InterfaceBasedMBeanInfoAssembler assembler =
getWithMapping("foobar", "org.springframework.jmx.export.assembler.ICustomJmxBean");
assembler.setManagedInterfaces(new Class>[] {IAdditionalTestMethods.class});
@@ -68,6 +77,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
assertNickName(attr);
}
+ @Test
public void testNickNameIsExposed() throws Exception {
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
MBeanAttributeInfo attr = inf.getAttribute("NickName");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java
index 2c2a8618eb..ea234b09e8 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,14 +22,20 @@ import javax.management.MBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
/**
* @author Juergen Hoeller
* @author Rob Harrop
+ * @author Chris Beams
*/
public class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAssemblerTests {
protected static final String OBJECT_NAME = "bean:name=testBean4";
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
@@ -37,6 +43,7 @@ public class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAsse
assertFalse("Age is not writable", attr.isWritable());
}
+ @Test
public void testNickNameIsExposed() throws Exception {
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
MBeanAttributeInfo attr = inf.getAttribute("NickName");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java
index 35fe108270..aa1e2d57c2 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,19 @@ import javax.management.MBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
public class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests {
protected static final String OBJECT_NAME = "bean:name=testBean4";
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
@@ -36,6 +42,7 @@ public class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAss
assertFalse("Age is not writable", attr.isWritable());
}
+ @Test
public void testNickNameIsExposed() throws Exception {
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
MBeanAttributeInfo attr = inf.getAttribute("NickName");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java
index f037d87bcb..6b12c74d97 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,14 +22,20 @@ import javax.management.MBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
/**
* @author Juergen Hoeller
* @author Rob Harrop
+ * @author Chris Beams
*/
public class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmxAssemblerTests {
protected static final String OBJECT_NAME = "bean:name=testBean4";
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
@@ -37,6 +43,7 @@ public class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmx
assertTrue("Age is not writable", attr.isWritable());
}
+ @Test
public void testNickNameIsExposed() throws Exception {
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
MBeanAttributeInfo attr = inf.getAttribute("NickName");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java
index 8a49293006..53335e50d7 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,15 @@ import java.util.Properties;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
import org.springframework.jmx.JmxTestBean;
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
* @author Rick Evans
+ * @author Chris Beams
*/
public class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests {
@@ -60,6 +64,7 @@ public class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssembler
return assembler;
}
+ @Test
public void testSupermanIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute("Superman");
@@ -71,6 +76,7 @@ public class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssembler
/*
* http://opensource.atlassian.com/projects/spring/browse/SPR-2754
*/
+ @Test
public void testIsNotIgnoredDoesntIgnoreUnspecifiedBeanMethods() throws Exception {
final String beanKey = "myTestBean";
MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler();
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java
index 062a45febd..10b1985515 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -16,18 +16,25 @@
package org.springframework.jmx.export.assembler;
+import java.util.Properties;
+
import javax.management.MBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
-import java.util.Properties;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* @author Rob Harrop
+ * @author Chris Beams
*/
public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests {
protected static final String OBJECT_NAME = "bean:name=testBean4";
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
@@ -36,6 +43,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss
assertFalse("Age is not writable", attr.isWritable());
}
+ @Test
public void testWithFallThrough() throws Exception {
MethodNameBasedMBeanInfoAssembler assembler =
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
@@ -47,6 +55,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss
assertNickName(attr);
}
+ @Test
public void testNickNameIsExposed() throws Exception {
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
MBeanAttributeInfo attr = inf.getAttribute("NickName");
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java
index 72da54f6f3..d85f42b508 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java
@@ -20,9 +20,14 @@ import javax.management.MBeanOperationInfo;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
/**
* @author Rob Harrop
* @author David Boden
+ * @author Chris Beams
*/
public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests {
@@ -50,6 +55,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler
return assembler;
}
+ @Test
public void testGetAgeIsReadOnly() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
@@ -58,6 +64,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler
assertFalse(attr.isWritable());
}
+ @Test
public void testSetNameParameterIsNamed() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
diff --git a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTestsIgnore.java b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java
similarity index 86%
rename from spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTestsIgnore.java
rename to spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java
index ef244b085e..6d66caa79c 100644
--- a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTestsIgnore.java
+++ b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2011 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -28,23 +28,36 @@ import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-import org.junit.Ignore;
+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
+ * @author Chris Beams
*/
-// TODO [SPR-8089] Clean up ignored JMX tests.
-//
-// @Ignore should have no effect for JUnit 3.8 tests; however, it appears
-// that tests on the CI server -- as well as those in Eclipse -- do in
-// fact get ignored. So we leave @Ignore here so that developers can
-// easily search for ignored tests.
-@Ignore("Requires jmxremote_optional.jar; see comments in AbstractMBeanServerTests for details.")
-public class ConnectorServerFactoryBeanTestsIgnore extends 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 {
ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean();
bean.afterPropertiesSet();
@@ -56,6 +69,7 @@ public class ConnectorServerFactoryBeanTestsIgnore extends AbstractMBeanServerTe
}
}
+ @Test
public void testStartupWithSuppliedServer() throws Exception {
//Added a brief snooze here - seems to fix occasional
//java.net.BindException: Address already in use errors
@@ -72,6 +86,7 @@ public class ConnectorServerFactoryBeanTestsIgnore extends AbstractMBeanServerTe
}
}
+ @Test
public void testRegisterWithMBeanServer() throws Exception {
//Added a brief snooze here - seems to fix occasional
//java.net.BindException: Address already in use errors
@@ -89,6 +104,7 @@ public class ConnectorServerFactoryBeanTestsIgnore extends AbstractMBeanServerTe
}
}
+ @Test
public void testNoRegisterWithMBeanServer() throws Exception {
ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean();
bean.afterPropertiesSet();
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 598bc73e8c..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
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,13 @@ import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
-import org.junit.Ignore;
+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
@@ -43,16 +47,9 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
return JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer());
}
- // TODO [SPR-8089] Clean up ignored JMX tests.
- //
- // @Ignore should have no effect for JUnit 3.8 tests; however, it appears
- // that tests on the CI server -- as well as those in Eclipse -- do in
- // fact get ignored. So we leave @Ignore here so that developers can
- // easily search for ignored tests.
- //
- // Once fixed, renamed to test* instead of ignore*.
- @Ignore("Requires jmxremote_optional.jar; see comments in AbstractMBeanServerTests for details.")
- public void ignoreTestValidConnection() throws Exception {
+ @Test
+ public void testTestValidConnection() throws Exception {
+ Assume.group(TestGroup.JMXMP);
JMXConnectorServer connectorServer = getConnectorServer();
connectorServer.start();
@@ -75,6 +72,7 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
}
}
+ @Test
public void testWithNoServiceUrl() throws Exception {
MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
try {
@@ -85,16 +83,9 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
}
}
- // TODO [SPR-8089] Clean up ignored JMX tests.
- //
- // @Ignore should have no effect for JUnit 3.8 tests; however, it appears
- // that tests on the CI server -- as well as those in Eclipse -- do in
- // fact get ignored. So we leave @Ignore here so that developers can
- // easily search for ignored tests.
- //
- // Once fixed, renamed to test* instead of ignore*.
- @Ignore("Requires jmxremote_optional.jar; see comments in AbstractMBeanServerTests for details.")
- public void ignoreTestWithLazyConnection() throws Exception {
+ @Test
+ public void testTestWithLazyConnection() throws Exception {
+ Assume.group(TestGroup.JMXMP);
MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
bean.setServiceUrl(SERVICE_URL);
bean.setConnectOnStartup(false);
@@ -116,6 +107,7 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe
}
}
+ @Test
public void testWithLazyConnectionAndNoAccess() throws Exception {
MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
bean.setServiceUrl(SERVICE_URL);
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;
/**