From c489c6c5f68172060fc4e829330d0e6208d072c2 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 11 Jul 2018 17:13:45 +0100 Subject: [PATCH] Polish test following forward merge --- .../condition/ConditionalOnBeanTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java index 5d6cfcc1ab..85e9ddfec5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java @@ -139,12 +139,14 @@ public class ConditionalOnBeanTests { @Test public void conditionEvaluationConsidersChangeInTypeWhenBeanIsOverridden() { - this.context.register(OriginalDefinition.class, OverridingDefinition.class, - ConsumingConfiguration.class); - this.context.refresh(); - assertThat(this.context.containsBean("testBean")).isTrue(); - assertThat(this.context.getBean(Integer.class)).isEqualTo(1); - assertThat(this.context.getBeansOfType(ConsumingConfiguration.class)).isEmpty(); + this.contextRunner + .withUserConfiguration(OriginalDefinition.class, + OverridingDefinition.class, ConsumingConfiguration.class) + .run((context) -> { + assertThat(context).hasBean("testBean"); + assertThat(context).hasSingleBean(Integer.class); + assertThat(context).doesNotHaveBean(ConsumingConfiguration.class); + }); } @Configuration