Disable bean overriding by default in ApplicationContextRunner

For consistency with SpringApplication, this commit disables bean
overriding by default in ApplicationContextRunner. Bean overriding can
be enabled again using withAllowBeanDefinitionOverriding.

Closes gh-18019
This commit is contained in:
Stephane Nicoll
2019-12-30 11:52:09 +01:00
parent e92e818b7c
commit eb852f1ad6
7 changed files with 110 additions and 63 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -136,8 +136,8 @@ class ConditionalOnBeanTests {
@Test
void conditionEvaluationConsidersChangeInTypeWhenBeanIsOverridden() {
this.contextRunner.withUserConfiguration(OriginalDefinition.class, OverridingDefinition.class,
ConsumingConfiguration.class).run((context) -> {
this.contextRunner.withAllowBeanDefinitionOverriding(true).withUserConfiguration(OriginalDefinition.class,
OverridingDefinition.class, ConsumingConfiguration.class).run((context) -> {
assertThat(context).hasBean("testBean");
assertThat(context).hasSingleBean(Integer.class);
assertThat(context).doesNotHaveBean(ConsumingConfiguration.class);