Make ApplicationContextRunner immutable

Update `ApplicationContextRunner` so that it is totally immutable.
Methods now return new instances rather than changing existing state.

See gh-9875
This commit is contained in:
Phillip Webb
2017-07-26 16:37:42 -07:00
parent ad9f28110c
commit 89ad0660d1
6 changed files with 145 additions and 37 deletions

View File

@@ -55,7 +55,9 @@ public class TestDatabaseAutoConfigurationTests {
DataSource datasource = context.getBean(DataSource.class);
JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
jdbcTemplate.execute("create table example (id int, name varchar);");
this.contextRunner.run((secondContext) -> {
this.contextRunner
.withUserConfiguration(ExistingDataSourceConfiguration.class)
.run((secondContext) -> {
DataSource anotherDatasource = secondContext
.getBean(DataSource.class);
JdbcTemplate anotherJdbcTemplate = new JdbcTemplate(