use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method testSkipRegistrationOfDisabledEndpoint.
@Test
public void testSkipRegistrationOfDisabledEndpoint() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
MutablePropertyValues mpv = new MutablePropertyValues();
mpv.add("enabled", Boolean.FALSE);
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class, null, mpv));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().isRegistered(getObjectName("endpoint1", this.context))).isFalse();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method testRegistrationTwoEndpoints.
@Test
public void testRegistrationTwoEndpoints() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class));
this.context.registerBeanDefinition("endpoint2", new RootBeanDefinition(TestEndpoint2.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(getObjectName("endpoint1", this.context))).isNotNull();
assertThat(mbeanExporter.getServer().getMBeanInfo(getObjectName("endpoint2", this.context))).isNotNull();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method testRegistrationWithDifferentDomainAndIdentity.
@Test
public void testRegistrationWithDifferentDomainAndIdentity() throws Exception {
Map<String, Object> properties = new HashMap<>();
properties.put("domain", "test-domain");
properties.put("ensureUniqueRuntimeObjectNames", true);
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class, null, new MutablePropertyValues(properties)));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(getObjectName("test-domain", "endpoint1", true, this.context))).isNotNull();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class JndiDataSourceAutoConfigurationTests method standardDataSourceIsNotExcludedFromExport.
@SuppressWarnings("unchecked")
@Test
public void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException, NamingException {
DataSource dataSource = mock(DataSource.class);
configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.jndi-name:foo");
this.context.register(JndiDataSourceAutoConfiguration.class, MBeanExporterConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter).getPropertyValue("excludedBeans");
assertThat(excludedBeans).isEmpty();
}
use of org.springframework.jmx.export.MBeanExporter in project av-service by dvoraka.
the class CoreConfig method mbeanExporter.
/**
* Special MBeanExporter bean for integration tests.
*
* @return MBeanExporter with a different registration strategy
*/
@Bean
@Profile("itest")
public MBeanExporter mbeanExporter() {
MBeanExporter exporter = new MBeanExporter();
exporter.setRegistrationPolicy(RegistrationPolicy.REPLACE_EXISTING);
return exporter;
}
Aggregations