Make TestPropertyValues immutable

Update `TestPropertyValues` so that it is totally immutable. Methods
now return a new instance rather than changing existing state.

See gh-9875
This commit is contained in:
Phillip Webb
2017-07-26 15:38:58 -07:00
parent 07556cda51
commit ad9f28110c
8 changed files with 103 additions and 107 deletions

View File

@@ -93,7 +93,7 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertyValues.of(environment).and("spring.datasource.initialize", "false")
TestPropertyValues.of(environment).and("spring.datasource.initialize=false")
.applyTo(context);
context.register(config);
context.register(DataSourceAutoConfiguration.class,

View File

@@ -130,7 +130,7 @@ public class DataSourceJmxConfigurationTests {
private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
String jdbcUrl = "jdbc:hsqldb:mem:test-" + UUID.randomUUID().toString();
TestPropertyValues.of(environment).and("spring.datasource.url", jdbcUrl)
TestPropertyValues.of(environment).and("spring.datasource.url=" + jdbcUrl)
.applyTo(context);
if (config != null) {
context.register(config);

View File

@@ -104,8 +104,8 @@ public class HikariDataSourceConfigurationTests {
private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
TestPropertyValues.of(environment).and("spring.datasource.initialize", "false")
.and("spring.datasource.type", HikariDataSource.class.getName())
TestPropertyValues.of(environment).and("spring.datasource.initialize=false")
.and("spring.datasource.type=" + HikariDataSource.class.getName())
.applyTo(ctx);
ctx.register(DataSourceAutoConfiguration.class);
ctx.refresh();

View File

@@ -213,7 +213,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
ctx.setClassLoader(classLoader);
}
TestPropertyValues.of(environment)
.and("spring.datasource.generate-unique-name", "true").applyTo(ctx);
.and("spring.datasource.generate-unique-name=true").applyTo(ctx);
ctx.register(TestConfiguration.class);
if (!ObjectUtils.isEmpty(configs)) {
ctx.register(configs);