|
|
@ -40,8 +40,7 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void simpleRepository() throws IOException {
|
|
|
|
public void simpleRepository() throws IOException {
|
|
|
|
InputStream foo = getInputStreamFor("foo");
|
|
|
|
try (InputStream foo = getInputStreamFor("foo")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create(foo).build();
|
|
|
|
.create(foo).build();
|
|
|
|
validateFoo(repo);
|
|
|
|
validateFoo(repo);
|
|
|
@ -50,15 +49,11 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
"spring.foo.counter");
|
|
|
|
"spring.foo.counter");
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(3);
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
foo.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void hintsOnMaps() throws IOException {
|
|
|
|
public void hintsOnMaps() throws IOException {
|
|
|
|
InputStream map = getInputStreamFor("map");
|
|
|
|
try (InputStream map = getInputStreamFor("map")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create(map).build();
|
|
|
|
.create(map).build();
|
|
|
|
validateMap(repo);
|
|
|
|
validateMap(repo);
|
|
|
@ -67,16 +62,12 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
"spring.map.keys", "spring.map.values");
|
|
|
|
"spring.map.keys", "spring.map.values");
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(4);
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
map.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void severalRepositoriesNoConflict() throws IOException {
|
|
|
|
public void severalRepositoriesNoConflict() throws IOException {
|
|
|
|
InputStream foo = getInputStreamFor("foo");
|
|
|
|
try (InputStream foo = getInputStreamFor("foo");
|
|
|
|
InputStream bar = getInputStreamFor("bar");
|
|
|
|
InputStream bar = getInputStreamFor("bar")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create(foo, bar).build();
|
|
|
|
.create(foo, bar).build();
|
|
|
|
validateFoo(repo);
|
|
|
|
validateFoo(repo);
|
|
|
@ -87,17 +78,12 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
"spring.bar.counter");
|
|
|
|
"spring.bar.counter");
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(6);
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
foo.close();
|
|
|
|
|
|
|
|
bar.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void repositoryWithRoot() throws IOException {
|
|
|
|
public void repositoryWithRoot() throws IOException {
|
|
|
|
InputStream foo = getInputStreamFor("foo");
|
|
|
|
try (InputStream foo = getInputStreamFor("foo");
|
|
|
|
InputStream root = getInputStreamFor("root");
|
|
|
|
InputStream root = getInputStreamFor("root")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create(foo, root).build();
|
|
|
|
.create(foo, root).build();
|
|
|
|
validateFoo(repo);
|
|
|
|
validateFoo(repo);
|
|
|
@ -107,17 +93,12 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
"spring.foo.counter", "spring.root.name", "spring.root2.name");
|
|
|
|
"spring.foo.counter", "spring.root.name", "spring.root2.name");
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(5);
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
foo.close();
|
|
|
|
|
|
|
|
root.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void severalRepositoriesIdenticalGroups() throws IOException {
|
|
|
|
public void severalRepositoriesIdenticalGroups() throws IOException {
|
|
|
|
InputStream foo = getInputStreamFor("foo");
|
|
|
|
try (InputStream foo = getInputStreamFor("foo");
|
|
|
|
InputStream foo2 = getInputStreamFor("foo2");
|
|
|
|
InputStream foo2 = getInputStreamFor("foo2")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create(foo, foo2).build();
|
|
|
|
.create(foo, foo2).build();
|
|
|
|
assertThat(repo.getAllGroups()).hasSize(1);
|
|
|
|
assertThat(repo.getAllGroups()).hasSize(1);
|
|
|
@ -132,16 +113,11 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
"spring.foo.counter", "spring.foo.enabled", "spring.foo.type");
|
|
|
|
"spring.foo.counter", "spring.foo.enabled", "spring.foo.type");
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(5);
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
foo.close();
|
|
|
|
|
|
|
|
foo2.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void emptyGroups() throws IOException {
|
|
|
|
public void emptyGroups() throws IOException {
|
|
|
|
InputStream in = getInputStreamFor("empty-groups");
|
|
|
|
try (InputStream in = getInputStreamFor("empty-groups")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create(in).build();
|
|
|
|
.create(in).build();
|
|
|
|
validateEmptyGroup(repo);
|
|
|
|
validateEmptyGroup(repo);
|
|
|
@ -149,16 +125,12 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
contains(repo.getAllProperties(), "name", "title");
|
|
|
|
contains(repo.getAllProperties(), "name", "title");
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(2);
|
|
|
|
assertThat(repo.getAllProperties()).hasSize(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void builderInstancesAreIsolated() throws IOException {
|
|
|
|
public void builderInstancesAreIsolated() throws IOException {
|
|
|
|
InputStream foo = getInputStreamFor("foo");
|
|
|
|
try (InputStream foo = getInputStreamFor("foo");
|
|
|
|
InputStream bar = getInputStreamFor("bar");
|
|
|
|
InputStream bar = getInputStreamFor("bar")) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder
|
|
|
|
.create();
|
|
|
|
.create();
|
|
|
|
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo)
|
|
|
|
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo)
|
|
|
@ -175,10 +147,6 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
|
|
|
|
assertThat(secondRepo.getAllGroups()).hasSize(2);
|
|
|
|
assertThat(secondRepo.getAllGroups()).hasSize(2);
|
|
|
|
assertThat(secondRepo.getAllProperties()).hasSize(6);
|
|
|
|
assertThat(secondRepo.getAllProperties()).hasSize(6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
|
|
|
|
foo.close();
|
|
|
|
|
|
|
|
bar.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void validateFoo(ConfigurationMetadataRepository repo) {
|
|
|
|
private void validateFoo(ConfigurationMetadataRepository repo) {
|
|
|
|