Search in sources :

Example 1 with MetadataNamingStrategy

use of org.springframework.jmx.export.naming.MetadataNamingStrategy in project spring-boot by spring-projects.

the class JmxAutoConfigurationTests method testDefaultDomainConfiguredOnMBeanExport.

@Test
public void testDefaultDomainConfiguredOnMBeanExport() {
    MockEnvironment env = new MockEnvironment();
    env.setProperty("spring.jmx.enabled", "true");
    env.setProperty("spring.jmx.default-domain", "my-test-domain");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(env);
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class);
    this.context.refresh();
    MBeanExporter mBeanExporter = this.context.getBean(MBeanExporter.class);
    assertThat(mBeanExporter).isNotNull();
    MetadataNamingStrategy naming = (MetadataNamingStrategy) ReflectionTestUtils.getField(mBeanExporter, "namingStrategy");
    assertThat(ReflectionTestUtils.getField(naming, "defaultDomain")).isEqualTo("my-test-domain");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MockEnvironment(org.springframework.mock.env.MockEnvironment) IntegrationMBeanExporter(org.springframework.integration.monitor.IntegrationMBeanExporter) MBeanExporter(org.springframework.jmx.export.MBeanExporter) MetadataNamingStrategy(org.springframework.jmx.export.naming.MetadataNamingStrategy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 IntegrationMBeanExporter (org.springframework.integration.monitor.IntegrationMBeanExporter)1 MBeanExporter (org.springframework.jmx.export.MBeanExporter)1 MetadataNamingStrategy (org.springframework.jmx.export.naming.MetadataNamingStrategy)1 MockEnvironment (org.springframework.mock.env.MockEnvironment)1