This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch camel-2.21.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit bd38d92b4a62530ba72a4f8f665b42662408099c Author: lburgazzoli <[email protected]> AuthorDate: Fri Jun 8 23:53:24 2018 +0200 CAMEL-12560: fix cherry-pick --- ...netesServiceDiscoveryAutoConfigurationTest.java | 46 ++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/test/cloud/KubernetesServiceDiscoveryAutoConfigurationTest.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/test/cloud/KubernetesServiceDiscoveryAutoConfigurationTest.java index 5c9bd3f..ac09349 100644 --- a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/test/cloud/KubernetesServiceDiscoveryAutoConfigurationTest.java +++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/test/java/org/apache/camel/component/kubernetes/springboot/test/cloud/KubernetesServiceDiscoveryAutoConfigurationTest.java @@ -20,7 +20,8 @@ import org.apache.camel.cloud.ServiceDiscovery; import org.apache.camel.model.cloud.springboot.KubernetesServiceCallServiceDiscoveryConfigurationProperties; import org.junit.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; @@ -29,35 +30,40 @@ public class KubernetesServiceDiscoveryAutoConfigurationTest { @Test public void testServiceDiscoveryDisabled() { - new ApplicationContextRunner() - .withUserConfiguration(TestConfiguration.class) - .withPropertyValues( - "spring.main.banner-mode=off", - "camel.cloud.kubernetes.service-discovery.enabled=false") + ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfiguration.class) + .web(false) .run( - context -> { - assertThat(context).doesNotHaveBean(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class); - assertThat(context).getBeans(ServiceDiscovery.class).doesNotContainKeys("kubernetes-service-discovery"); - } + "--debug=false", + "--spring.main.banner-mode=OFF", + "--camel.cloud.kubernetes.service-discovery.enabled=false" ); + + try { + assertThat(context.getBeansOfType(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class)).isEmpty(); + assertThat(context.getBeansOfType(ServiceDiscovery.class)).doesNotContainKeys("kubernetes-service-discovery"); + } finally { + context.close(); + } } @Test public void testServiceDiscoveryEnabled() { - new ApplicationContextRunner() - .withUserConfiguration(TestConfiguration.class) - .withPropertyValues( - "spring.main.banner-mode=off", - "camel.cloud.kubernetes.service-discovery.enabled=true") + ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfiguration.class) + .web(false) .run( - context -> { - assertThat(context).hasSingleBean(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class); - assertThat(context).getBeans(ServiceDiscovery.class).containsKeys("kubernetes-service-discovery"); - } + "--debug=false", + "--spring.main.banner-mode=OFF", + "--camel.cloud.kubernetes.service-discovery.enabled=true" ); - } + try { + assertThat(context.getBeansOfType(KubernetesServiceCallServiceDiscoveryConfigurationProperties.class)).hasSize(1); + assertThat(context.getBeansOfType(ServiceDiscovery.class)).containsKeys("kubernetes-service-discovery"); + } finally { + context.close(); + } + } @EnableAutoConfiguration @Configuration -- To stop receiving notification emails like this one, please contact [email protected].
