@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 201 8 the original author or authors .
* Copyright 2012 - 201 9 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -101,31 +101,30 @@ public class IntegrationAutoConfigurationTests {
}
@Test
public void jmxIntegrationEnabledByDefault ( ) {
this . contextRunner . run ( ( context ) - > {
MBeanServer mBeanServer = context . getBean ( MBeanServer . class ) ;
assertThat ( mBeanServer . getDomains ( ) ) . contains (
"org.springframework.integration" ,
"org.springframework.integration.monitor" ) ;
assertThat ( context )
. hasBean ( IntegrationManagementConfigurer . MANAGEMENT_CONFIGURER_NAME ) ;
} ) ;
public void enableJmxIntegration ( ) {
this . contextRunner . withPropertyValues ( "spring.jmx.enabled=true" )
. run ( ( context ) - > {
MBeanServer mBeanServer = context . getBean ( MBeanServer . class ) ;
assertThat ( mBeanServer . getDomains ( ) ) . contains (
"org.springframework.integration" ,
"org.springframework.integration.monitor" ) ;
assertThat ( context ) . hasBean (
IntegrationManagementConfigurer . MANAGEMENT_CONFIGURER_NAME ) ;
} ) ;
}
@Test
public void disableJmxIntegration ( ) {
this . contextRunner . withPropertyValues ( "spring.jmx.enabled=false" )
. run ( ( context ) - > {
assertThat ( context ) . doesNotHaveBean ( MBeanServer . class ) ;
assertThat ( context )
. hasSingleBean ( IntegrationManagementConfigurer . class ) ;
} ) ;
public void jmxIntegrationIsDisabledByDefault ( ) {
this . contextRunner . run ( ( context ) - > {
assertThat ( context ) . doesNotHaveBean ( MBeanServer . class ) ;
assertThat ( context ) . hasSingleBean ( IntegrationManagementConfigurer . class ) ;
} ) ;
}
@Test
public void customizeJmxDomain ( ) {
this . contextRunner . withPropertyValues ( "spring.jmx. default_domain=org.foo")
. run ( ( context ) - > {
this . contextRunner . withPropertyValues ( "spring.jmx. enabled=true",
"spring.jmx.default_domain=org.foo" ) . run ( ( context ) - > {
MBeanServer mBeanServer = context . getBean ( MBeanServer . class ) ;
assertThat ( mBeanServer . getDomains ( ) ) . contains ( "org.foo" )
. doesNotContain ( "org.springframework.integration" ,
@ -135,8 +134,8 @@ public class IntegrationAutoConfigurationTests {
@Test
public void primaryExporterIsAllowed ( ) {
this . contextRunner . with UserConfiguration( CustomMBeanExporter . class )
. run( ( context ) - > {
this . contextRunner . with PropertyValues( "spring.jmx.enabled=true" )
. withUserConfiguration( CustomMBeanExporter . class ) . run( ( context ) - > {
assertThat ( context ) . getBeans ( MBeanExporter . class ) . hasSize ( 2 ) ;
assertThat ( context . getBean ( MBeanExporter . class ) )
. isSameAs ( context . getBean ( "myMBeanExporter" ) ) ;