Merge branch '2.1.x'

Closes gh-17335
Closes gh-17292
This commit is contained in:
Andy Wilkinson
2019-06-27 11:46:52 +01:00
11 changed files with 74 additions and 60 deletions

View File

@@ -63,44 +63,53 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
@Test
void severalRepositoriesNoConflict() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar).build();
validateFoo(repo);
validateBar(repo);
assertThat(repo.getAllGroups()).hasSize(2);
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.bar.name", "spring.bar.description", "spring.bar.counter");
assertThat(repo.getAllProperties()).hasSize(6);
try (InputStream foo = getInputStreamFor("foo")) {
try (InputStream bar = getInputStreamFor("bar")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar)
.build();
validateFoo(repo);
validateBar(repo);
assertThat(repo.getAllGroups()).hasSize(2);
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.bar.name", "spring.bar.description", "spring.bar.counter");
assertThat(repo.getAllProperties()).hasSize(6);
}
}
}
@Test
void repositoryWithRoot() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream root = getInputStreamFor("root")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root).build();
validateFoo(repo);
assertThat(repo.getAllGroups()).hasSize(2);
try (InputStream foo = getInputStreamFor("foo")) {
try (InputStream root = getInputStreamFor("root")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root)
.build();
validateFoo(repo);
assertThat(repo.getAllGroups()).hasSize(2);
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.root.name", "spring.root2.name");
assertThat(repo.getAllProperties()).hasSize(5);
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.root.name", "spring.root2.name");
assertThat(repo.getAllProperties()).hasSize(5);
}
}
}
@Test
void severalRepositoriesIdenticalGroups() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream foo2 = getInputStreamFor("foo2")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2).build();
assertThat(repo.getAllGroups()).hasSize(1);
ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo");
contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties");
assertThat(group.getSources()).hasSize(3);
contains(group.getProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.foo.enabled", "spring.foo.type");
assertThat(group.getProperties()).hasSize(5);
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.foo.enabled", "spring.foo.type");
assertThat(repo.getAllProperties()).hasSize(5);
try (InputStream foo = getInputStreamFor("foo")) {
try (InputStream foo2 = getInputStreamFor("foo2")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2)
.build();
assertThat(repo.getAllGroups()).hasSize(1);
ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo");
contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties");
assertThat(group.getSources()).hasSize(3);
contains(group.getProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.foo.enabled", "spring.foo.type");
assertThat(group.getProperties()).hasSize(5);
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
"spring.foo.enabled", "spring.foo.type");
assertThat(repo.getAllProperties()).hasSize(5);
}
}
}
@@ -135,19 +144,22 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
@Test
void builderInstancesAreIsolated() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) {
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create();
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build();
validateFoo(firstRepo);
ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build();
validateFoo(secondRepo);
validateBar(secondRepo);
// first repo not impacted by second build
assertThat(secondRepo).isNotEqualTo(firstRepo);
assertThat(firstRepo.getAllGroups()).hasSize(1);
assertThat(firstRepo.getAllProperties()).hasSize(3);
assertThat(secondRepo.getAllGroups()).hasSize(2);
assertThat(secondRepo.getAllProperties()).hasSize(6);
try (InputStream foo = getInputStreamFor("foo")) {
try (InputStream bar = getInputStreamFor("bar")) {
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder
.create();
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build();
validateFoo(firstRepo);
ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build();
validateFoo(secondRepo);
validateBar(secondRepo);
// first repo not impacted by second build
assertThat(secondRepo).isNotEqualTo(firstRepo);
assertThat(firstRepo.getAllGroups()).hasSize(1);
assertThat(firstRepo.getAllProperties()).hasSize(3);
assertThat(secondRepo.getAllGroups()).hasSize(2);
assertThat(secondRepo.getAllProperties()).hasSize(6);
}
}
}

View File

@@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.11")
classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.14")
}
}