|
|
|
|
@@ -112,8 +112,9 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|
|
|
|
assertThat(systemProperties.get("my.services.cleardb-free.credentials"))
|
|
|
|
|
.isEqualTo("******");
|
|
|
|
|
assertThat(systemProperties.get("foo.mycredentials.uri")).isEqualTo("******");
|
|
|
|
|
clearSystemProperties("my.services.amqp-free.credentials.uri", "credentials.http_api_uri",
|
|
|
|
|
"my.services.cleardb-free.credentials", "foo.mycredentials.uri");
|
|
|
|
|
clearSystemProperties("my.services.amqp-free.credentials.uri",
|
|
|
|
|
"credentials.http_api_uri", "my.services.cleardb-free.credentials",
|
|
|
|
|
"foo.mycredentials.uri");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@@ -208,14 +209,13 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|
|
|
|
@Test
|
|
|
|
|
public void propertyWithPlaceholderResolved() throws Exception {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context,
|
|
|
|
|
"my.foo: ${bar.blah}", "bar.blah: hello");
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context, "my.foo: ${bar.blah}",
|
|
|
|
|
"bar.blah: hello");
|
|
|
|
|
this.context.register(Config.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
EnvironmentEndpoint report = getEndpointBean();
|
|
|
|
|
Map<String, Object> env = report.invoke();
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env
|
|
|
|
|
.get("test");
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
|
|
|
|
assertThat(testProperties.get("my.foo")).isEqualTo("hello");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -223,14 +223,12 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|
|
|
|
@Test
|
|
|
|
|
public void propertyWithPlaceholderNotResolved() throws Exception {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context,
|
|
|
|
|
"my.foo: ${bar.blah}");
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(this.context, "my.foo: ${bar.blah}");
|
|
|
|
|
this.context.register(Config.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
EnvironmentEndpoint report = getEndpointBean();
|
|
|
|
|
Map<String, Object> env = report.invoke();
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env
|
|
|
|
|
.get("test");
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
|
|
|
|
assertThat(testProperties.get("my.foo")).isEqualTo("${bar.blah}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -244,8 +242,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
EnvironmentEndpoint report = getEndpointBean();
|
|
|
|
|
Map<String, Object> env = report.invoke();
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env
|
|
|
|
|
.get("test");
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
|
|
|
|
assertThat(testProperties.get("my.foo")).isEqualTo("http://******://hello");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -259,16 +256,17 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
EnvironmentEndpoint report = getEndpointBean();
|
|
|
|
|
Map<String, Object> env = report.invoke();
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env
|
|
|
|
|
.get("test");
|
|
|
|
|
assertThat(testProperties.get("my.foo")).isEqualTo("http://${bar.password}://hello");
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
|
|
|
|
assertThat(testProperties.get("my.foo"))
|
|
|
|
|
.isEqualTo("http://${bar.password}://hello");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
|
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
|
MutablePropertySources propertySources = this.context.getEnvironment().getPropertySources();
|
|
|
|
|
MutablePropertySources propertySources = this.context.getEnvironment()
|
|
|
|
|
.getPropertySources();
|
|
|
|
|
Map<String, Object> source = new HashMap<String, Object>();
|
|
|
|
|
source.put("foo", Collections.singletonMap("bar", "baz"));
|
|
|
|
|
propertySources.addFirst(new MapPropertySource("test", source));
|
|
|
|
|
@@ -276,8 +274,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
EnvironmentEndpoint report = getEndpointBean();
|
|
|
|
|
Map<String, Object> env = report.invoke();
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env
|
|
|
|
|
.get("test");
|
|
|
|
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
|
|
|
|
Map<String, String> foo = (Map<String, String>) testProperties.get("foo");
|
|
|
|
|
assertThat(foo.get("bar")).isEqualTo("baz");
|
|
|
|
|
}
|
|
|
|
|
|