Formatting
This commit is contained in:
parent
ea4e6fea35
commit
4a7dcc8786
|
@ -93,7 +93,8 @@ public class EnvironmentMvcEndpoint extends EndpointMvcAdapter
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object getOptionalValue(Environment source, String name) {
|
protected Object getOptionalValue(Environment source, String name) {
|
||||||
Object result = ((EnvironmentEndpoint) getDelegate()).getResolver().getProperty(name, Object.class);
|
Object result = ((EnvironmentEndpoint) getDelegate()).getResolver()
|
||||||
|
.getProperty(name, Object.class);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result = ((EnvironmentEndpoint) getDelegate()).sanitize(name, result);
|
result = ((EnvironmentEndpoint) getDelegate()).sanitize(name, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,9 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||||
assertThat(systemProperties.get("my.services.cleardb-free.credentials"))
|
assertThat(systemProperties.get("my.services.cleardb-free.credentials"))
|
||||||
.isEqualTo("******");
|
.isEqualTo("******");
|
||||||
assertThat(systemProperties.get("foo.mycredentials.uri")).isEqualTo("******");
|
assertThat(systemProperties.get("foo.mycredentials.uri")).isEqualTo("******");
|
||||||
clearSystemProperties("my.services.amqp-free.credentials.uri", "credentials.http_api_uri",
|
clearSystemProperties("my.services.amqp-free.credentials.uri",
|
||||||
"my.services.cleardb-free.credentials", "foo.mycredentials.uri");
|
"credentials.http_api_uri", "my.services.cleardb-free.credentials",
|
||||||
|
"foo.mycredentials.uri");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -208,14 +209,13 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||||
@Test
|
@Test
|
||||||
public void propertyWithPlaceholderResolved() throws Exception {
|
public void propertyWithPlaceholderResolved() throws Exception {
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context, "my.foo: ${bar.blah}",
|
||||||
"my.foo: ${bar.blah}", "bar.blah: hello");
|
"bar.blah: hello");
|
||||||
this.context.register(Config.class);
|
this.context.register(Config.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
EnvironmentEndpoint report = getEndpointBean();
|
EnvironmentEndpoint report = getEndpointBean();
|
||||||
Map<String, Object> env = report.invoke();
|
Map<String, Object> env = report.invoke();
|
||||||
Map<String, Object> testProperties = (Map<String, Object>) env
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
||||||
.get("test");
|
|
||||||
assertThat(testProperties.get("my.foo")).isEqualTo("hello");
|
assertThat(testProperties.get("my.foo")).isEqualTo("hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,14 +223,12 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||||
@Test
|
@Test
|
||||||
public void propertyWithPlaceholderNotResolved() throws Exception {
|
public void propertyWithPlaceholderNotResolved() throws Exception {
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context, "my.foo: ${bar.blah}");
|
||||||
"my.foo: ${bar.blah}");
|
|
||||||
this.context.register(Config.class);
|
this.context.register(Config.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
EnvironmentEndpoint report = getEndpointBean();
|
EnvironmentEndpoint report = getEndpointBean();
|
||||||
Map<String, Object> env = report.invoke();
|
Map<String, Object> env = report.invoke();
|
||||||
Map<String, Object> testProperties = (Map<String, Object>) env
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
||||||
.get("test");
|
|
||||||
assertThat(testProperties.get("my.foo")).isEqualTo("${bar.blah}");
|
assertThat(testProperties.get("my.foo")).isEqualTo("${bar.blah}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,8 +242,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
EnvironmentEndpoint report = getEndpointBean();
|
EnvironmentEndpoint report = getEndpointBean();
|
||||||
Map<String, Object> env = report.invoke();
|
Map<String, Object> env = report.invoke();
|
||||||
Map<String, Object> testProperties = (Map<String, Object>) env
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
||||||
.get("test");
|
|
||||||
assertThat(testProperties.get("my.foo")).isEqualTo("http://******://hello");
|
assertThat(testProperties.get("my.foo")).isEqualTo("http://******://hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,16 +256,17 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
EnvironmentEndpoint report = getEndpointBean();
|
EnvironmentEndpoint report = getEndpointBean();
|
||||||
Map<String, Object> env = report.invoke();
|
Map<String, Object> env = report.invoke();
|
||||||
Map<String, Object> testProperties = (Map<String, Object>) env
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
||||||
.get("test");
|
assertThat(testProperties.get("my.foo"))
|
||||||
assertThat(testProperties.get("my.foo")).isEqualTo("http://${bar.password}://hello");
|
.isEqualTo("http://${bar.password}://hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
|
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
MutablePropertySources propertySources = this.context.getEnvironment().getPropertySources();
|
MutablePropertySources propertySources = this.context.getEnvironment()
|
||||||
|
.getPropertySources();
|
||||||
Map<String, Object> source = new HashMap<String, Object>();
|
Map<String, Object> source = new HashMap<String, Object>();
|
||||||
source.put("foo", Collections.singletonMap("bar", "baz"));
|
source.put("foo", Collections.singletonMap("bar", "baz"));
|
||||||
propertySources.addFirst(new MapPropertySource("test", source));
|
propertySources.addFirst(new MapPropertySource("test", source));
|
||||||
|
@ -276,8 +274,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
EnvironmentEndpoint report = getEndpointBean();
|
EnvironmentEndpoint report = getEndpointBean();
|
||||||
Map<String, Object> env = report.invoke();
|
Map<String, Object> env = report.invoke();
|
||||||
Map<String, Object> testProperties = (Map<String, Object>) env
|
Map<String, Object> testProperties = (Map<String, Object>) env.get("test");
|
||||||
.get("test");
|
|
||||||
Map<String, String> foo = (Map<String, String>) testProperties.get("foo");
|
Map<String, String> foo = (Map<String, String>) testProperties.get("foo");
|
||||||
assertThat(foo.get("bar")).isEqualTo("baz");
|
assertThat(foo.get("bar")).isEqualTo("baz");
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,11 +162,10 @@ public class EnvironmentMvcEndpointTests {
|
||||||
.andExpect(content().string(containsString("\"my.foo\":\"******\"")));
|
.andExpect(content().string(containsString("\"my.foo\":\"******\"")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Test
|
@Test
|
||||||
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
|
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
|
||||||
ConfigurableEnvironment environment = (ConfigurableEnvironment) this.context.getEnvironment();
|
MutablePropertySources propertySources = ((ConfigurableEnvironment) this.context
|
||||||
MutablePropertySources propertySources = environment.getPropertySources();
|
.getEnvironment()).getPropertySources();
|
||||||
Map<String, Object> source = new HashMap<String, Object>();
|
Map<String, Object> source = new HashMap<String, Object>();
|
||||||
source.put("foo", Collections.singletonMap("bar", "baz"));
|
source.put("foo", Collections.singletonMap("bar", "baz"));
|
||||||
propertySources.addFirst(new MapPropertySource("test", source));
|
propertySources.addFirst(new MapPropertySource("test", source));
|
||||||
|
|
|
@ -329,7 +329,8 @@ public class RabbitAutoConfigurationTests {
|
||||||
"spring.rabbitmq.listener.simple.transactionSize:20");
|
"spring.rabbitmq.listener.simple.transactionSize:20");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSimpleRabbitListenerContainerFactoryWithCustomSettings(String... environment) {
|
private void testSimpleRabbitListenerContainerFactoryWithCustomSettings(
|
||||||
|
String... environment) {
|
||||||
load(new Class<?>[] { MessageConvertersConfiguration.class,
|
load(new Class<?>[] { MessageConvertersConfiguration.class,
|
||||||
MessageRecoverersConfiguration.class }, environment);
|
MessageRecoverersConfiguration.class }, environment);
|
||||||
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context
|
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context
|
||||||
|
|
Loading…
Reference in New Issue