Verify that @EnableIntegrationMBeanExport can set custom JMX domain

Add a test to JmxAutoConfigurationTests which verifies that
@EnableIntegrationMBeanExport can be used on a @Configuration class
to customize the default domain used for MBeans created by Spring
Integration. See https://jira.spring.io/browse/SPR-12128.

Closes gh-1451
pull/1510/head
Andy Wilkinson 10 years ago
parent 2d8ec0faab
commit 8399fc990c

@ -20,11 +20,15 @@ import org.junit.After;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
import org.springframework.integration.monitor.IntegrationMBeanExporter;
import org.springframework.jmx.export.MBeanExporter; import org.springframework.jmx.export.MBeanExporter;
import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation; import org.springframework.jmx.export.annotation.ManagedOperation;
@ -120,6 +124,24 @@ public class JmxAutoConfigurationTests {
this.context.refresh(); this.context.refresh();
} }
@Test
public void customJmxDomain() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(CustomJmxDomainConfiguration.class,
JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
this.context.refresh();
IntegrationMBeanExporter mbeanExporter = this.context
.getBean(IntegrationMBeanExporter.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(mbeanExporter);
assertEquals("foo.my", dfa.getPropertyValue("domain"));
}
@Configuration
@EnableIntegrationMBeanExport(defaultDomain = "foo.my")
public static class CustomJmxDomainConfiguration {
}
@Configuration @Configuration
public static class TestConfiguration { public static class TestConfiguration {

Loading…
Cancel
Save