pull/6251/head
Phillip Webb 9 years ago
parent d41127d3da
commit 266445aaf0

@ -46,8 +46,8 @@ public class TraceProperties {
} }
/** /**
* Items to be included in the trace. Defaults to request/response headers (including cookies) * Items to be included in the trace. Defaults to request/response headers (including
* and errors. * cookies) and errors.
*/ */
private Set<Include> include = new HashSet<Include>(DEFAULT_INCLUDES); private Set<Include> include = new HashSet<Include>(DEFAULT_INCLUDES);

@ -73,7 +73,8 @@ public class CassandraDataAutoConfiguration {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
this.properties = properties; this.properties = properties;
this.cluster = cluster; this.cluster = cluster;
this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.data.cassandra."); this.propertyResolver = new RelaxedPropertyResolver(environment,
"spring.data.cassandra.");
} }
@Bean @Bean
@ -105,8 +106,8 @@ public class CassandraDataAutoConfiguration {
session.setCluster(this.cluster); session.setCluster(this.cluster);
session.setConverter(converter); session.setConverter(converter);
session.setKeyspaceName(this.properties.getKeyspaceName()); session.setKeyspaceName(this.properties.getKeyspaceName());
SchemaAction schemaAction = this.propertyResolver SchemaAction schemaAction = this.propertyResolver.getProperty("schemaAction",
.getProperty("schemaAction", SchemaAction.class, SchemaAction.NONE); SchemaAction.class, SchemaAction.NONE);
session.setSchemaAction(schemaAction); session.setSchemaAction(schemaAction);
return session; return session;
} }

@ -53,9 +53,9 @@ import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;
@ConditionalOnClass(LiteDeviceDelegatingViewResolver.class) @ConditionalOnClass(LiteDeviceDelegatingViewResolver.class)
@ConditionalOnProperty(prefix = "spring.mobile.devicedelegatingviewresolver", name = "enabled", havingValue = "true") @ConditionalOnProperty(prefix = "spring.mobile.devicedelegatingviewresolver", name = "enabled", havingValue = "true")
@EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class) @EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class)
@AutoConfigureAfter({WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class, @AutoConfigureAfter({ WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class,
GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class, GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class,
ThymeleafAutoConfiguration.class}) ThymeleafAutoConfiguration.class })
public class DeviceDelegatingViewResolverAutoConfiguration { public class DeviceDelegatingViewResolverAutoConfiguration {
@Configuration @Configuration

@ -21,8 +21,8 @@ import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver;
import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.ViewResolver;
/** /**
* A factory for {@link LiteDeviceDelegatingViewResolver} that applies customizations * A factory for {@link LiteDeviceDelegatingViewResolver} that applies customizations of
* of {@link DeviceDelegatingViewResolverProperties}. * {@link DeviceDelegatingViewResolverProperties}.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 1.4.0 * @since 1.4.0
@ -31,7 +31,8 @@ public class DeviceDelegatingViewResolverFactory {
private final DeviceDelegatingViewResolverProperties properties; private final DeviceDelegatingViewResolverProperties properties;
public DeviceDelegatingViewResolverFactory(DeviceDelegatingViewResolverProperties properties) { public DeviceDelegatingViewResolverFactory(
DeviceDelegatingViewResolverProperties properties) {
this.properties = properties; this.properties = properties;
} }
@ -42,8 +43,8 @@ public class DeviceDelegatingViewResolverFactory {
* @param delegatingOrder the order of the {@link LiteDeviceDelegatingViewResolver} * @param delegatingOrder the order of the {@link LiteDeviceDelegatingViewResolver}
* @return a {@link LiteDeviceDelegatingViewResolver} handling the specified resolver * @return a {@link LiteDeviceDelegatingViewResolver} handling the specified resolver
*/ */
public LiteDeviceDelegatingViewResolver createViewResolver( public LiteDeviceDelegatingViewResolver createViewResolver(ViewResolver delegate,
ViewResolver delegate, int delegatingOrder) { int delegatingOrder) {
LiteDeviceDelegatingViewResolver resolver = new LiteDeviceDelegatingViewResolver( LiteDeviceDelegatingViewResolver resolver = new LiteDeviceDelegatingViewResolver(
delegate); delegate);
resolver.setEnableFallback(this.properties.isEnableFallback()); resolver.setEnableFallback(this.properties.isEnableFallback());
@ -67,7 +68,8 @@ public class DeviceDelegatingViewResolverFactory {
*/ */
public LiteDeviceDelegatingViewResolver createViewResolver(ViewResolver delegate) { public LiteDeviceDelegatingViewResolver createViewResolver(ViewResolver delegate) {
if (!(delegate instanceof Ordered)) { if (!(delegate instanceof Ordered)) {
throw new IllegalStateException("ViewResolver " + delegate + "should implement " + Ordered.class.getName()); throw new IllegalStateException("ViewResolver " + delegate
+ "should implement " + Ordered.class.getName());
} }
int delegateOrder = ((Ordered) delegate).getOrder(); int delegateOrder = ((Ordered) delegate).getOrder();
return createViewResolver(delegate, adjustOrder(delegateOrder)); return createViewResolver(delegate, adjustOrder(delegateOrder));

@ -28,22 +28,22 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public class AuthorizationServerProperties { public class AuthorizationServerProperties {
/** /**
* A Spring Security access rule for the check token endpoint (e.g. a SpEL expression * Spring Security access rule for the check token endpoint (e.g. a SpEL expression
* like "isAuthenticated()") . Default is empty, which is interpreted as "denyAll()" * like "isAuthenticated()") . Default is empty, which is interpreted as "denyAll()"
* (no access). * (no access).
*/ */
private String checkTokenAccess; private String checkTokenAccess;
/** /**
* A Spring Security access rule for the token key endpoint (e.g. a SpEL expression * Spring Security access rule for the token key endpoint (e.g. a SpEL expression like
* like "isAuthenticated()"). Default is empty, which is interpreted as "denyAll()" * "isAuthenticated()"). Default is empty, which is interpreted as "denyAll()" (no
* (no access). * access).
*/ */
private String tokenKeyAccess; private String tokenKeyAccess;
/** /**
* The realm name for client authentication. If an unauthenticated request comes in to * Realm name for client authentication. If an unauthenticated request comes in to the
* the token endpoint, it will respond with a challenge including this name. * token endpoint, it will respond with a challenge including this name.
*/ */
private String realm; private String realm;

@ -429,8 +429,7 @@ public class WebMvcAutoConfiguration {
for (HandlerExceptionResolver resolver : exceptionResolvers) { for (HandlerExceptionResolver resolver : exceptionResolvers) {
if (resolver instanceof AbstractHandlerExceptionResolver) { if (resolver instanceof AbstractHandlerExceptionResolver) {
((AbstractHandlerExceptionResolver) resolver) ((AbstractHandlerExceptionResolver) resolver)
.setWarnLogCategory(resolver.getClass() .setWarnLogCategory(resolver.getClass().getName());
.getName());
} }
} }
} }

@ -71,14 +71,12 @@ public class CassandraDataAutoConfigurationIntegrationTests {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
String cityPackage = City.class.getPackage().getName(); String cityPackage = City.class.getPackage().getName();
AutoConfigurationPackages.register(this.context, cityPackage); AutoConfigurationPackages.register(this.context, cityPackage);
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.cassandra.schemaAction:RECREATE_DROP_UNUSED", "spring.data.cassandra.keyspaceName:boot_test"); "spring.data.cassandra.schemaAction:RECREATE_DROP_UNUSED",
"spring.data.cassandra.keyspaceName:boot_test");
this.context.register(CassandraAutoConfiguration.class, this.context.register(CassandraAutoConfiguration.class,
CassandraDataAutoConfiguration.class); CassandraDataAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
CassandraSessionFactoryBean bean = this.context CassandraSessionFactoryBean bean = this.context
.getBean(CassandraSessionFactoryBean.class); .getBean(CassandraSessionFactoryBean.class);
assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.RECREATE_DROP_UNUSED); assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.RECREATE_DROP_UNUSED);

@ -91,7 +91,8 @@ public class CassandraTestServer implements TestRule {
@Override @Override
public void evaluate() throws Throwable { public void evaluate() throws Throwable {
Assume.assumeTrue("Skipping test due to Cassandra not being available", false); Assume.assumeTrue("Skipping test due to Cassandra not being available",
false);
} }
} }

@ -79,7 +79,8 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
@Test @Test
public void deviceDelegatingJspResourceViewResolver() throws Exception { public void deviceDelegatingJspResourceViewResolver() throws Exception {
load("spring.mobile.devicedelegatingviewresolver.enabled:true"); load("spring.mobile.devicedelegatingviewresolver.enabled:true");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(1); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
.hasSize(1);
InternalResourceViewResolver internalResourceViewResolver = this.context InternalResourceViewResolver internalResourceViewResolver = this.context
.getBean(InternalResourceViewResolver.class); .getBean(InternalResourceViewResolver.class);
assertLiteDeviceDelegatingViewResolver(internalResourceViewResolver, assertLiteDeviceDelegatingViewResolver(internalResourceViewResolver,
@ -90,8 +91,10 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
public void deviceDelegatingFreemarkerViewResolver() throws Exception { public void deviceDelegatingFreemarkerViewResolver() throws Exception {
load(Collections.<Class<?>>singletonList(FreeMarkerAutoConfiguration.class), load(Collections.<Class<?>>singletonList(FreeMarkerAutoConfiguration.class),
"spring.mobile.devicedelegatingviewresolver.enabled:true"); "spring.mobile.devicedelegatingviewresolver.enabled:true");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
assertLiteDeviceDelegatingViewResolver(this.context.getBean(FreeMarkerViewResolver.class), .hasSize(2);
assertLiteDeviceDelegatingViewResolver(
this.context.getBean(FreeMarkerViewResolver.class),
"deviceDelegatingFreemarkerViewResolver"); "deviceDelegatingFreemarkerViewResolver");
} }
@ -99,8 +102,10 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
public void deviceDelegatingGroovyMarkupViewResolver() throws Exception { public void deviceDelegatingGroovyMarkupViewResolver() throws Exception {
load(Collections.<Class<?>>singletonList(GroovyTemplateAutoConfiguration.class), load(Collections.<Class<?>>singletonList(GroovyTemplateAutoConfiguration.class),
"spring.mobile.devicedelegatingviewresolver.enabled:true"); "spring.mobile.devicedelegatingviewresolver.enabled:true");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
assertLiteDeviceDelegatingViewResolver(this.context.getBean(GroovyMarkupViewResolver.class), .hasSize(2);
assertLiteDeviceDelegatingViewResolver(
this.context.getBean(GroovyMarkupViewResolver.class),
"deviceDelegatingGroovyMarkupViewResolver"); "deviceDelegatingGroovyMarkupViewResolver");
} }
@ -108,8 +113,10 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
public void deviceDelegatingMustacheViewResolver() throws Exception { public void deviceDelegatingMustacheViewResolver() throws Exception {
load(Collections.<Class<?>>singletonList(MustacheAutoConfiguration.class), load(Collections.<Class<?>>singletonList(MustacheAutoConfiguration.class),
"spring.mobile.devicedelegatingviewresolver.enabled:true"); "spring.mobile.devicedelegatingviewresolver.enabled:true");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
assertLiteDeviceDelegatingViewResolver(this.context.getBean(MustacheViewResolver.class), .hasSize(2);
assertLiteDeviceDelegatingViewResolver(
this.context.getBean(MustacheViewResolver.class),
"deviceDelegatingMustacheViewResolver"); "deviceDelegatingMustacheViewResolver");
} }
@ -117,26 +124,30 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
public void deviceDelegatingThymeleafViewResolver() throws Exception { public void deviceDelegatingThymeleafViewResolver() throws Exception {
load(Collections.<Class<?>>singletonList(ThymeleafAutoConfiguration.class), load(Collections.<Class<?>>singletonList(ThymeleafAutoConfiguration.class),
"spring.mobile.devicedelegatingviewresolver.enabled:true"); "spring.mobile.devicedelegatingviewresolver.enabled:true");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
assertLiteDeviceDelegatingViewResolver(this.context.getBean(ThymeleafViewResolver.class), .hasSize(2);
assertLiteDeviceDelegatingViewResolver(
this.context.getBean(ThymeleafViewResolver.class),
"deviceDelegatingThymeleafViewResolver"); "deviceDelegatingThymeleafViewResolver");
} }
public void assertLiteDeviceDelegatingViewResolver(ViewResolver delegate, String delegatingBeanName) { public void assertLiteDeviceDelegatingViewResolver(ViewResolver delegate,
String delegatingBeanName) {
LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
.getBean(delegatingBeanName, LiteDeviceDelegatingViewResolver.class); .getBean(delegatingBeanName, LiteDeviceDelegatingViewResolver.class);
assertThat(deviceDelegatingViewResolver.getViewResolver()) assertThat(deviceDelegatingViewResolver.getViewResolver()).isSameAs(delegate);
.isSameAs(delegate);
assertThat(deviceDelegatingViewResolver.getOrder()) assertThat(deviceDelegatingViewResolver.getOrder())
.isEqualTo(((Ordered) delegate).getOrder() - 1); .isEqualTo(((Ordered) delegate).getOrder() - 1);
} }
@Test @Test
public void deviceDelegatingViewResolverDisabled() throws Exception { public void deviceDelegatingViewResolverDisabled() throws Exception {
load(Arrays.asList(FreeMarkerAutoConfiguration.class, GroovyTemplateAutoConfiguration.class, load(Arrays.asList(FreeMarkerAutoConfiguration.class,
MustacheAutoConfiguration.class, ThymeleafAutoConfiguration.class), GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class,
ThymeleafAutoConfiguration.class),
"spring.mobile.devicedelegatingviewresolver.enabled:false"); "spring.mobile.devicedelegatingviewresolver.enabled:false");
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(0); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
.hasSize(0);
} }
@Test @Test

@ -48,7 +48,7 @@ public class MongoPropertiesTests {
// gh-1572 // gh-1572
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, "spring.data.mongodb.password:word"); EnvironmentTestUtils.addEnvironment(context, "spring.data.mongodb.password:word");
context.register(Conf.class); context.register(Config.class);
context.refresh(); context.refresh();
MongoProperties properties = context.getBean(MongoProperties.class); MongoProperties properties = context.getBean(MongoProperties.class);
assertThat(properties.getPassword()).isEqualTo("word".toCharArray()); assertThat(properties.getPassword()).isEqualTo("word".toCharArray());
@ -123,50 +123,58 @@ public class MongoPropertiesTests {
@Test @Test
public void allMongoClientOptionsCanBeSet() throws UnknownHostException { public void allMongoClientOptionsCanBeSet() throws UnknownHostException {
MongoClientOptions mco = MongoClientOptions.builder() MongoClientOptions.Builder builder = MongoClientOptions.builder();
.alwaysUseMBeans(true) builder.alwaysUseMBeans(true);
.connectionsPerHost(101) builder.connectionsPerHost(101);
.connectTimeout(10001) builder.connectTimeout(10001);
.cursorFinalizerEnabled(false) builder.cursorFinalizerEnabled(false);
.description("test") builder.description("test");
.maxWaitTime(120001) builder.maxWaitTime(120001);
.socketKeepAlive(true) builder.socketKeepAlive(true);
.socketTimeout(1000) builder.socketTimeout(1000);
.threadsAllowedToBlockForConnectionMultiplier(6) builder.threadsAllowedToBlockForConnectionMultiplier(6);
.minConnectionsPerHost(0) builder.minConnectionsPerHost(0);
.maxConnectionIdleTime(60000) builder.maxConnectionIdleTime(60000);
.maxConnectionLifeTime(60000) builder.maxConnectionLifeTime(60000);
.heartbeatFrequency(10001) builder.heartbeatFrequency(10001);
.minHeartbeatFrequency(501) builder.minHeartbeatFrequency(501);
.heartbeatConnectTimeout(20001) builder.heartbeatConnectTimeout(20001);
.heartbeatSocketTimeout(20001) builder.heartbeatSocketTimeout(20001);
.localThreshold(20) builder.localThreshold(20);
.requiredReplicaSetName("testReplicaSetName") builder.requiredReplicaSetName("testReplicaSetName");
.build(); MongoClientOptions options = builder.build();
MongoProperties properties = new MongoProperties(); MongoProperties properties = new MongoProperties();
MongoClient client = properties.createMongoClient(mco, null); MongoClient client = properties.createMongoClient(options, null);
MongoClientOptions wrappedMco = client.getMongoClientOptions(); MongoClientOptions wrapped = client.getMongoClientOptions();
assertThat(wrapped.isAlwaysUseMBeans()).isEqualTo(options.isAlwaysUseMBeans());
assertThat(wrappedMco.isAlwaysUseMBeans()).isEqualTo(mco.isAlwaysUseMBeans()); assertThat(wrapped.getConnectionsPerHost())
assertThat(wrappedMco.getConnectionsPerHost()).isEqualTo(mco.getConnectionsPerHost()); .isEqualTo(options.getConnectionsPerHost());
assertThat(wrappedMco.getConnectTimeout()).isEqualTo(mco.getConnectTimeout()); assertThat(wrapped.getConnectTimeout()).isEqualTo(options.getConnectTimeout());
assertThat(wrappedMco.isCursorFinalizerEnabled()).isEqualTo(mco.isCursorFinalizerEnabled()); assertThat(wrapped.isCursorFinalizerEnabled())
assertThat(wrappedMco.getDescription()).isEqualTo(mco.getDescription()); .isEqualTo(options.isCursorFinalizerEnabled());
assertThat(wrappedMco.getMaxWaitTime()).isEqualTo(mco.getMaxWaitTime()); assertThat(wrapped.getDescription()).isEqualTo(options.getDescription());
assertThat(wrappedMco.getSocketTimeout()).isEqualTo(mco.getSocketTimeout()); assertThat(wrapped.getMaxWaitTime()).isEqualTo(options.getMaxWaitTime());
assertThat(wrappedMco.isSocketKeepAlive()).isEqualTo(mco.isSocketKeepAlive()); assertThat(wrapped.getSocketTimeout()).isEqualTo(options.getSocketTimeout());
assertThat(wrappedMco.getThreadsAllowedToBlockForConnectionMultiplier()).isEqualTo( assertThat(wrapped.isSocketKeepAlive()).isEqualTo(options.isSocketKeepAlive());
mco.getThreadsAllowedToBlockForConnectionMultiplier()); assertThat(wrapped.getThreadsAllowedToBlockForConnectionMultiplier())
assertThat(wrappedMco.getMinConnectionsPerHost()).isEqualTo(mco.getMinConnectionsPerHost()); .isEqualTo(options.getThreadsAllowedToBlockForConnectionMultiplier());
assertThat(wrappedMco.getMaxConnectionIdleTime()).isEqualTo(mco.getMaxConnectionIdleTime()); assertThat(wrapped.getMinConnectionsPerHost())
assertThat(wrappedMco.getMaxConnectionLifeTime()).isEqualTo(mco.getMaxConnectionLifeTime()); .isEqualTo(options.getMinConnectionsPerHost());
assertThat(wrappedMco.getHeartbeatFrequency()).isEqualTo(mco.getHeartbeatFrequency()); assertThat(wrapped.getMaxConnectionIdleTime())
assertThat(wrappedMco.getMinHeartbeatFrequency()).isEqualTo(mco.getMinHeartbeatFrequency()); .isEqualTo(options.getMaxConnectionIdleTime());
assertThat(wrappedMco.getHeartbeatConnectTimeout()).isEqualTo(mco.getHeartbeatConnectTimeout()); assertThat(wrapped.getMaxConnectionLifeTime())
assertThat(wrappedMco.getHeartbeatSocketTimeout()).isEqualTo(mco.getHeartbeatSocketTimeout()); .isEqualTo(options.getMaxConnectionLifeTime());
assertThat(wrappedMco.getLocalThreshold()).isEqualTo(mco.getLocalThreshold()); assertThat(wrapped.getHeartbeatFrequency())
assertThat(wrappedMco.getRequiredReplicaSetName()).isEqualTo(mco.getRequiredReplicaSetName()); .isEqualTo(options.getHeartbeatFrequency());
assertThat(wrapped.getMinHeartbeatFrequency())
.isEqualTo(options.getMinHeartbeatFrequency());
assertThat(wrapped.getHeartbeatConnectTimeout())
.isEqualTo(options.getHeartbeatConnectTimeout());
assertThat(wrapped.getHeartbeatSocketTimeout())
.isEqualTo(options.getHeartbeatSocketTimeout());
assertThat(wrapped.getLocalThreshold()).isEqualTo(options.getLocalThreshold());
assertThat(wrapped.getRequiredReplicaSetName())
.isEqualTo(options.getRequiredReplicaSetName());
} }
private List<ServerAddress> extractServerAddresses(MongoClient client) { private List<ServerAddress> extractServerAddresses(MongoClient client) {
@ -192,7 +200,7 @@ public class MongoPropertiesTests {
@Configuration @Configuration
@EnableConfigurationProperties(MongoProperties.class) @EnableConfigurationProperties(MongoProperties.class)
static class Conf { static class Config {
} }

@ -541,20 +541,22 @@ public class WebMvcAutoConfigurationTests {
} }
private void testLogResolvedExceptionCustomization(final boolean expected) { private void testLogResolvedExceptionCustomization(final boolean expected) {
HandlerExceptionResolver exceptionResolver = this.context.getBean( HandlerExceptionResolver exceptionResolver = this.context
HandlerExceptionResolver.class); .getBean(HandlerExceptionResolver.class);
assertThat(exceptionResolver).isInstanceOf(HandlerExceptionResolverComposite.class); assertThat(exceptionResolver)
List<HandlerExceptionResolver> delegates = .isInstanceOf(HandlerExceptionResolverComposite.class);
((HandlerExceptionResolverComposite) exceptionResolver).getExceptionResolvers(); List<HandlerExceptionResolver> delegates = ((HandlerExceptionResolverComposite) exceptionResolver)
.getExceptionResolvers();
for (HandlerExceptionResolver delegate : delegates) { for (HandlerExceptionResolver delegate : delegates) {
if (delegate instanceof AbstractHandlerMethodAdapter) { if (delegate instanceof AbstractHandlerMethodAdapter) {
assertThat(new DirectFieldAccessor(delegate).getPropertyValue("warnLogger")) assertThat(
.is(new Condition<Object>() { new DirectFieldAccessor(delegate).getPropertyValue("warnLogger"))
@Override .is(new Condition<Object>() {
public boolean matches(Object value) { @Override
return (expected ? value != null : value == null); public boolean matches(Object value) {
} return (expected ? value != null : value == null);
}); }
});
} }
} }
} }

@ -19,8 +19,10 @@ package org.springframework.boot.configurationprocessor.metadata;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Set;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
@ -37,7 +39,12 @@ import org.springframework.util.ObjectUtils;
*/ */
public class ConfigurationMetadata { public class ConfigurationMetadata {
private static final List<Character> SEPARATORS = Arrays.asList('-', '_'); private static final Set<Character> SEPARATORS;
static {
List<Character> chars = Arrays.asList('-', '_');
SEPARATORS = Collections.unmodifiableSet(new HashSet<Character>(chars));
}
private final MultiValueMap<String, ItemMetadata> items; private final MultiValueMap<String, ItemMetadata> items;
@ -159,23 +166,23 @@ public class ConfigurationMetadata {
} }
static String toDashedCase(String name) { static String toDashedCase(String name) {
StringBuilder sb = new StringBuilder(); StringBuilder dashed = new StringBuilder();
Character previous = null; Character previous = null;
for (char current : name.toCharArray()) { for (char current : name.toCharArray()) {
if (SEPARATORS.contains(current)) { if (SEPARATORS.contains(current)) {
sb.append("-"); dashed.append("-");
} }
else if (Character.isUpperCase(current) && previous != null else if (Character.isUpperCase(current) && previous != null
&& !SEPARATORS.contains(previous)) { && !SEPARATORS.contains(previous)) {
sb.append("-").append(current); dashed.append("-").append(current);
} }
else { else {
sb.append(current); dashed.append(current);
} }
previous = current; previous = current;
} }
return sb.toString().toLowerCase(); return dashed.toString().toLowerCase();
} }
private static <T extends Comparable<T>> List<T> flattenValues( private static <T extends Comparable<T>> List<T> flattenValues(

@ -259,6 +259,7 @@ public class PropertiesConfigurationFactoryTests {
public void setFooDLQBar(String fooDLQBar) { public void setFooDLQBar(String fooDLQBar) {
this.fooDLQBar = fooDLQBar; this.fooDLQBar = fooDLQBar;
} }
} }
} }

Loading…
Cancel
Save