From 6dd84159f5273ff14b1697f51ab12d03f0027b94 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 29 Mar 2016 15:26:38 +0200 Subject: [PATCH] Restore JMX property to IntegrationJmxConfiguration Closes gh-5309 --- .../IntegrationAutoConfiguration.java | 2 +- .../IntegrationAutoConfigurationTests.java | 42 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java index 00fc69b0a3..ef0f682fb2 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java @@ -39,7 +39,6 @@ import org.springframework.integration.monitor.IntegrationMBeanExporter; @Configuration @ConditionalOnClass(EnableIntegration.class) @AutoConfigureAfter(JmxAutoConfiguration.class) -@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true) public class IntegrationAutoConfiguration { @Configuration @@ -50,6 +49,7 @@ public class IntegrationAutoConfiguration { @Configuration @ConditionalOnClass(EnableIntegrationMBeanExport.class) @ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT) + @ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true) @EnableIntegrationMBeanExport(defaultDomain = "${spring.jmx.default-domain:}", server = "${spring.jmx.server:mbeanServer}") protected static class IntegrationJmxConfiguration { } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java index d2b5153b34..de22e83d5f 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java @@ -55,28 +55,9 @@ public class IntegrationAutoConfigurationTests { @Test public void integrationIsAvailable() { load(); - MBeanServer mBeanServer = this.context.getBean(MBeanServer.class); - assertDomains(mBeanServer, true, "org.springframework.integration", - "org.springframework.integration.monitor"); assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull(); } - @Test - public void disableIntegration() { - load("spring.jmx.enabled=false"); - assertThat(this.context.getBeansOfType(MBeanServer.class)).hasSize(0); - } - - @Test - public void customizeDomain() { - load("spring.jmx.default-domain=org.foo"); - MBeanServer mBeanServer = this.context.getBean(MBeanServer.class); - assertDomains(mBeanServer, true, "org.foo"); - assertDomains(mBeanServer, false, "org.springframework.integration", - "org.springframework.integration.monitor"); - } - - @Test public void parentContext() { this.context = new AnnotationConfigApplicationContext(); @@ -92,6 +73,29 @@ public class IntegrationAutoConfigurationTests { this.context.close(); } + @Test + public void jmxIntegrationEnabledByDefault() { + load(); + MBeanServer mBeanServer = this.context.getBean(MBeanServer.class); + assertDomains(mBeanServer, true, "org.springframework.integration", + "org.springframework.integration.monitor"); + } + + @Test + public void disableJmxIntegration() { + load("spring.jmx.enabled=false"); + assertThat(this.context.getBeansOfType(MBeanServer.class)).hasSize(0); + } + + @Test + public void customizeJmxDomain() { + load("spring.jmx.default-domain=org.foo"); + MBeanServer mBeanServer = this.context.getBean(MBeanServer.class); + assertDomains(mBeanServer, true, "org.foo"); + assertDomains(mBeanServer, false, "org.springframework.integration", + "org.springframework.integration.monitor"); + } + private static void assertDomains(MBeanServer mBeanServer, boolean expected, String... domains) { List actual = Arrays.asList(mBeanServer.getDomains()); for (String domain : domains) {