use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExportAutoConfigurationTests method testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource.
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class, NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExportAutoConfigurationTests method testEndpointMBeanExporterWithProperties.
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException, InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class, EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(getObjectName("test-domain", "healthEndpoint", this.context).toString() + ",key1=value1,key2=value2"))).isNotNull();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExportAutoConfigurationTests method testEndpointMBeanExporterIsInstalled.
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class, EndpointAutoConfiguration.class, EndpointMBeanExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().queryNames(getObjectName("*", "*,*", this.context), null)).isNotEmpty();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method testRegistrationWithDifferentDomain.
@Test
public void testRegistrationWithDifferentDomain() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class, null, new MutablePropertyValues(Collections.singletonMap("domain", "test-domain"))));
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", false, this.context))).isNotNull();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method loggerEndpointLowerCaseLogLevel.
@Test
public void loggerEndpointLowerCaseLogLevel() throws Exception {
MBeanExporter mbeanExporter = registerLoggersEndpoint();
Object response = mbeanExporter.getServer().invoke(getObjectName("loggersEndpoint", this.context), "setLogLevel", new Object[] { "com.example", "trace" }, new String[] { String.class.getName(), String.class.getName() });
assertThat(response).isNull();
}
Aggregations