Merge branch '1.5.x'
This commit is contained in:
commit
fd2e3b3505
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,11 +161,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));
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ public class RabbitAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
|
public void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
|
||||||
load(new Class<?>[] { MessageConvertersConfiguration.class,
|
load(new Class<?>[] { MessageConvertersConfiguration.class,
|
||||||
MessageRecoverersConfiguration.class },
|
MessageRecoverersConfiguration.class },
|
||||||
"spring.rabbitmq.listener.simple.retry.enabled:true",
|
"spring.rabbitmq.listener.simple.retry.enabled:true",
|
||||||
"spring.rabbitmq.listener.simple.retry.maxAttempts:4",
|
"spring.rabbitmq.listener.simple.retry.maxAttempts:4",
|
||||||
"spring.rabbitmq.listener.simple.retry.initialInterval:2000",
|
"spring.rabbitmq.listener.simple.retry.initialInterval:2000",
|
||||||
|
|
@ -346,29 +346,31 @@ public class RabbitAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRabbitListenerContainerFactoryConfigurersAreAvailable() {
|
public void testRabbitListenerContainerFactoryConfigurersAreAvailable() {
|
||||||
load(TestConfiguration.class,
|
load(TestConfiguration.class, "spring.rabbitmq.listener.simple.concurrency:5",
|
||||||
"spring.rabbitmq.listener.simple.concurrency:5",
|
|
||||||
"spring.rabbitmq.listener.simple.maxConcurrency:10",
|
"spring.rabbitmq.listener.simple.maxConcurrency:10",
|
||||||
"spring.rabbitmq.listener.simple.prefetch:40",
|
"spring.rabbitmq.listener.simple.prefetch:40",
|
||||||
"spring.rabbitmq.listener.direct.consumers-per-queue:5",
|
"spring.rabbitmq.listener.direct.consumers-per-queue:5",
|
||||||
"spring.rabbitmq.listener.direct.prefetch:40");
|
"spring.rabbitmq.listener.direct.prefetch:40");
|
||||||
assertThat(this.context.getBeansOfType(
|
assertThat(this.context
|
||||||
SimpleRabbitListenerContainerFactoryConfigurer.class)).hasSize(1);
|
.getBeansOfType(SimpleRabbitListenerContainerFactoryConfigurer.class))
|
||||||
assertThat(this.context.getBeansOfType(
|
.hasSize(1);
|
||||||
DirectRabbitListenerContainerFactoryConfigurer.class)).hasSize(1);
|
assertThat(this.context
|
||||||
|
.getBeansOfType(DirectRabbitListenerContainerFactoryConfigurer.class))
|
||||||
|
.hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleRabbitListenerContainerFactoryConfigurerUsesConfig() {
|
public void testSimpleRabbitListenerContainerFactoryConfigurerUsesConfig() {
|
||||||
load(TestConfiguration.class,
|
load(TestConfiguration.class, "spring.rabbitmq.listener.type:direct", // listener
|
||||||
"spring.rabbitmq.listener.type:direct", // listener type is irrelevant
|
// type is
|
||||||
|
// irrelevant
|
||||||
"spring.rabbitmq.listener.simple.concurrency:5",
|
"spring.rabbitmq.listener.simple.concurrency:5",
|
||||||
"spring.rabbitmq.listener.simple.maxConcurrency:10",
|
"spring.rabbitmq.listener.simple.maxConcurrency:10",
|
||||||
"spring.rabbitmq.listener.simple.prefetch:40");
|
"spring.rabbitmq.listener.simple.prefetch:40");
|
||||||
SimpleRabbitListenerContainerFactoryConfigurer configurer = this.context
|
SimpleRabbitListenerContainerFactoryConfigurer configurer = this.context
|
||||||
.getBean(SimpleRabbitListenerContainerFactoryConfigurer.class);
|
.getBean(SimpleRabbitListenerContainerFactoryConfigurer.class);
|
||||||
SimpleRabbitListenerContainerFactory factory =
|
SimpleRabbitListenerContainerFactory factory = mock(
|
||||||
mock(SimpleRabbitListenerContainerFactory.class);
|
SimpleRabbitListenerContainerFactory.class);
|
||||||
configurer.configure(factory, mock(ConnectionFactory.class));
|
configurer.configure(factory, mock(ConnectionFactory.class));
|
||||||
verify(factory).setConcurrentConsumers(5);
|
verify(factory).setConcurrentConsumers(5);
|
||||||
verify(factory).setMaxConcurrentConsumers(10);
|
verify(factory).setMaxConcurrentConsumers(10);
|
||||||
|
|
@ -377,14 +379,15 @@ public class RabbitAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDirectRabbitListenerContainerFactoryConfigurerUsesConfig() {
|
public void testDirectRabbitListenerContainerFactoryConfigurerUsesConfig() {
|
||||||
load(TestConfiguration.class,
|
load(TestConfiguration.class, "spring.rabbitmq.listener.type:simple", // listener
|
||||||
"spring.rabbitmq.listener.type:simple", // listener type is irrelevant
|
// type is
|
||||||
|
// irrelevant
|
||||||
"spring.rabbitmq.listener.direct.consumers-per-queue:5",
|
"spring.rabbitmq.listener.direct.consumers-per-queue:5",
|
||||||
"spring.rabbitmq.listener.direct.prefetch:40");
|
"spring.rabbitmq.listener.direct.prefetch:40");
|
||||||
DirectRabbitListenerContainerFactoryConfigurer configurer = this.context
|
DirectRabbitListenerContainerFactoryConfigurer configurer = this.context
|
||||||
.getBean(DirectRabbitListenerContainerFactoryConfigurer.class);
|
.getBean(DirectRabbitListenerContainerFactoryConfigurer.class);
|
||||||
DirectRabbitListenerContainerFactory factory =
|
DirectRabbitListenerContainerFactory factory = mock(
|
||||||
mock(DirectRabbitListenerContainerFactory.class);
|
DirectRabbitListenerContainerFactory.class);
|
||||||
configurer.configure(factory, mock(ConnectionFactory.class));
|
configurer.configure(factory, mock(ConnectionFactory.class));
|
||||||
verify(factory).setConsumersPerQueue(5);
|
verify(factory).setConsumersPerQueue(5);
|
||||||
verify(factory).setPrefetchCount(40);
|
verify(factory).setPrefetchCount(40);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue