BAEL-2878 Guide to Spring's ApplicationContextRunner
This commit is contained in:
parent
e16ed51835
commit
066cf2d6f2
@ -15,7 +15,7 @@ public class ConditionalOnBeanIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenDependentBeanIsPresent_thenConditionalBeanCreated() {
|
public void whenDependentBeanIsPresent_thenConditionalBeanCreated() {
|
||||||
this.contextRunner.withUserConfiguration(basicConfiguration.class, ConditionalOnBeanConfiguration.class)
|
this.contextRunner.withUserConfiguration(BasicConfiguration.class, ConditionalOnBeanConfiguration.class)
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasBean("created");
|
assertThat(context).hasBean("created");
|
||||||
assertThat(context).getBean("created")
|
assertThat(context).getBean("created")
|
||||||
@ -28,7 +28,7 @@ public class ConditionalOnBeanIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenDependentBeanIsPresent_thenConditionalMissingBeanIgnored() {
|
public void whenDependentBeanIsPresent_thenConditionalMissingBeanIgnored() {
|
||||||
this.contextRunner.withUserConfiguration(basicConfiguration.class, ConditionalOnMissingBeanConfiguration.class)
|
this.contextRunner.withUserConfiguration(BasicConfiguration.class, ConditionalOnMissingBeanConfiguration.class)
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasBean("created");
|
assertThat(context).hasBean("created");
|
||||||
assertThat(context).getBean("created")
|
assertThat(context).getBean("created")
|
||||||
@ -49,7 +49,7 @@ public class ConditionalOnBeanIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
protected static class basicConfiguration {
|
protected static class BasicConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
public String created() {
|
public String created() {
|
||||||
return "This is always created";
|
return "This is always created";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user