|
|
@ -354,7 +354,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { |
|
|
|
exporter.setBeans(beansToExport); |
|
|
|
exporter.setBeans(beansToExport); |
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_NONE); |
|
|
|
exporter.setAutodetect(false); |
|
|
|
// MBean has a bad ObjectName, so if said MBean is autodetected, an exception will be thrown...
|
|
|
|
// MBean has a bad ObjectName, so if said MBean is autodetected, an exception will be thrown...
|
|
|
|
start(exporter); |
|
|
|
start(exporter); |
|
|
|
} |
|
|
|
} |
|
|
@ -524,18 +524,16 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void notRunningInBeanFactoryAndPassedBeanNameToExport() throws Exception { |
|
|
|
void notRunningInBeanFactoryAndPassedBeanNameToExport() { |
|
|
|
Map<String, Object> beans = Map.of(OBJECT_NAME, "beanName"); |
|
|
|
Map<String, Object> beans = Map.of(OBJECT_NAME, "beanName"); |
|
|
|
exporter.setBeans(beans); |
|
|
|
exporter.setBeans(beans); |
|
|
|
assertThatExceptionOfType(MBeanExportException.class) |
|
|
|
assertThatExceptionOfType(MBeanExportException.class).isThrownBy(() -> start(exporter)); |
|
|
|
.isThrownBy(() -> start(exporter)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void notRunningInBeanFactoryAndAutodetectionIsOn() throws Exception { |
|
|
|
void notRunningInBeanFactoryAndAutodetectionIsOn() { |
|
|
|
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ALL); |
|
|
|
exporter.setAutodetect(true); |
|
|
|
assertThatExceptionOfType(MBeanExportException.class) |
|
|
|
assertThatExceptionOfType(MBeanExportException.class).isThrownBy(() -> start(exporter)); |
|
|
|
.isThrownBy(() -> start(exporter)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-2158
|
|
|
|
@Test // SPR-2158
|
|
|
@ -556,7 +554,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-3302
|
|
|
|
@Test // SPR-3302
|
|
|
|
void beanNameCanBeUsedInNotificationListenersMap() throws Exception { |
|
|
|
void beanNameCanBeUsedInNotificationListenersMap() { |
|
|
|
String beanName = "charlesDexterWard"; |
|
|
|
String beanName = "charlesDexterWard"; |
|
|
|
BeanDefinitionBuilder testBean = BeanDefinitionBuilder.rootBeanDefinition(JmxTestBean.class); |
|
|
|
BeanDefinitionBuilder testBean = BeanDefinitionBuilder.rootBeanDefinition(JmxTestBean.class); |
|
|
|
|
|
|
|
|
|
|
@ -576,7 +574,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void wildcardCanBeUsedInNotificationListenersMap() throws Exception { |
|
|
|
void wildcardCanBeUsedInNotificationListenersMap() { |
|
|
|
String beanName = "charlesDexterWard"; |
|
|
|
String beanName = "charlesDexterWard"; |
|
|
|
BeanDefinitionBuilder testBean = BeanDefinitionBuilder.rootBeanDefinition(JmxTestBean.class); |
|
|
|
BeanDefinitionBuilder testBean = BeanDefinitionBuilder.rootBeanDefinition(JmxTestBean.class); |
|
|
|
|
|
|
|
|
|
|
@ -636,24 +634,23 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { |
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setAssembler(new NamedBeanAutodetectCapableMBeanInfoAssemblerStub(firstBeanName, secondBeanName)); |
|
|
|
exporter.setAssembler(new NamedBeanAutodetectCapableMBeanInfoAssemblerStub(firstBeanName, secondBeanName)); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ALL); |
|
|
|
exporter.setAutodetect(true); |
|
|
|
exporter.addExcludedBean(secondBeanName); |
|
|
|
exporter.addExcludedBean(secondBeanName); |
|
|
|
|
|
|
|
|
|
|
|
start(exporter); |
|
|
|
start(exporter); |
|
|
|
assertIsRegistered("Bean not autodetected in (AUTODETECT_ALL) mode", |
|
|
|
assertIsRegistered("Bean not autodetected", ObjectNameManager.getInstance(firstBeanName)); |
|
|
|
ObjectNameManager.getInstance(firstBeanName)); |
|
|
|
assertIsNotRegistered("Bean should have been excluded", ObjectNameManager.getInstance(secondBeanName)); |
|
|
|
assertIsNotRegistered("Bean should have been excluded", |
|
|
|
|
|
|
|
ObjectNameManager.getInstance(secondBeanName)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void registerFactoryBean() throws MalformedObjectNameException { |
|
|
|
void registerFactoryBean() throws MalformedObjectNameException { |
|
|
|
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); |
|
|
|
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); |
|
|
|
factory.registerBeanDefinition("spring:type=FactoryBean", new RootBeanDefinition(ProperSomethingFactoryBean.class)); |
|
|
|
factory.registerBeanDefinition("spring:type=FactoryBean", |
|
|
|
|
|
|
|
new RootBeanDefinition(ProperSomethingFactoryBean.class)); |
|
|
|
|
|
|
|
|
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ALL); |
|
|
|
exporter.setAutodetect(true); |
|
|
|
|
|
|
|
|
|
|
|
start(exporter); |
|
|
|
start(exporter); |
|
|
|
assertIsRegistered("Non-null FactoryBean object registered", |
|
|
|
assertIsRegistered("Non-null FactoryBean object registered", |
|
|
@ -663,11 +660,12 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void ignoreNullObjectFromFactoryBean() throws MalformedObjectNameException { |
|
|
|
void ignoreNullObjectFromFactoryBean() throws MalformedObjectNameException { |
|
|
|
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); |
|
|
|
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); |
|
|
|
factory.registerBeanDefinition("spring:type=FactoryBean", new RootBeanDefinition(NullSomethingFactoryBean.class)); |
|
|
|
factory.registerBeanDefinition("spring:type=FactoryBean", |
|
|
|
|
|
|
|
new RootBeanDefinition(NullSomethingFactoryBean.class)); |
|
|
|
|
|
|
|
|
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setServer(getServer()); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setBeanFactory(factory); |
|
|
|
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ALL); |
|
|
|
exporter.setAutodetect(true); |
|
|
|
|
|
|
|
|
|
|
|
start(exporter); |
|
|
|
start(exporter); |
|
|
|
assertIsNotRegistered("Null FactoryBean object not registered", |
|
|
|
assertIsNotRegistered("Null FactoryBean object not registered", |
|
|
|