mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
This commit is contained in:
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)
|
||||
* and errors.
|
||||
* Items to be included in the trace. Defaults to request/response headers (including
|
||||
* cookies) and errors.
|
||||
*/
|
||||
private Set<Include> include = new HashSet<Include>(DEFAULT_INCLUDES);
|
||||
|
||||
|
@ -73,7 +73,8 @@ public class CassandraDataAutoConfiguration {
|
||||
this.beanFactory = beanFactory;
|
||||
this.properties = properties;
|
||||
this.cluster = cluster;
|
||||
this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.data.cassandra.");
|
||||
this.propertyResolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.data.cassandra.");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ -105,8 +106,8 @@ public class CassandraDataAutoConfiguration {
|
||||
session.setCluster(this.cluster);
|
||||
session.setConverter(converter);
|
||||
session.setKeyspaceName(this.properties.getKeyspaceName());
|
||||
SchemaAction schemaAction = this.propertyResolver
|
||||
.getProperty("schemaAction", SchemaAction.class, SchemaAction.NONE);
|
||||
SchemaAction schemaAction = this.propertyResolver.getProperty("schemaAction",
|
||||
SchemaAction.class, SchemaAction.NONE);
|
||||
session.setSchemaAction(schemaAction);
|
||||
return session;
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;
|
||||
@ConditionalOnClass(LiteDeviceDelegatingViewResolver.class)
|
||||
@ConditionalOnProperty(prefix = "spring.mobile.devicedelegatingviewresolver", name = "enabled", havingValue = "true")
|
||||
@EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class)
|
||||
@AutoConfigureAfter({WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class,
|
||||
@AutoConfigureAfter({ WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class,
|
||||
GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class,
|
||||
ThymeleafAutoConfiguration.class})
|
||||
ThymeleafAutoConfiguration.class })
|
||||
public class DeviceDelegatingViewResolverAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
|
@ -21,8 +21,8 @@ import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
|
||||
/**
|
||||
* A factory for {@link LiteDeviceDelegatingViewResolver} that applies customizations
|
||||
* of {@link DeviceDelegatingViewResolverProperties}.
|
||||
* A factory for {@link LiteDeviceDelegatingViewResolver} that applies customizations of
|
||||
* {@link DeviceDelegatingViewResolverProperties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
@ -31,7 +31,8 @@ public class DeviceDelegatingViewResolverFactory {
|
||||
|
||||
private final DeviceDelegatingViewResolverProperties properties;
|
||||
|
||||
public DeviceDelegatingViewResolverFactory(DeviceDelegatingViewResolverProperties properties) {
|
||||
public DeviceDelegatingViewResolverFactory(
|
||||
DeviceDelegatingViewResolverProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@ -42,8 +43,8 @@ public class DeviceDelegatingViewResolverFactory {
|
||||
* @param delegatingOrder the order of the {@link LiteDeviceDelegatingViewResolver}
|
||||
* @return a {@link LiteDeviceDelegatingViewResolver} handling the specified resolver
|
||||
*/
|
||||
public LiteDeviceDelegatingViewResolver createViewResolver(
|
||||
ViewResolver delegate, int delegatingOrder) {
|
||||
public LiteDeviceDelegatingViewResolver createViewResolver(ViewResolver delegate,
|
||||
int delegatingOrder) {
|
||||
LiteDeviceDelegatingViewResolver resolver = new LiteDeviceDelegatingViewResolver(
|
||||
delegate);
|
||||
resolver.setEnableFallback(this.properties.isEnableFallback());
|
||||
@ -67,7 +68,8 @@ public class DeviceDelegatingViewResolverFactory {
|
||||
*/
|
||||
public LiteDeviceDelegatingViewResolver createViewResolver(ViewResolver delegate) {
|
||||
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();
|
||||
return createViewResolver(delegate, adjustOrder(delegateOrder));
|
||||
|
@ -28,22 +28,22 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
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()"
|
||||
* (no access).
|
||||
*/
|
||||
private String checkTokenAccess;
|
||||
|
||||
/**
|
||||
* A Spring Security access rule for the token key endpoint (e.g. a SpEL expression
|
||||
* like "isAuthenticated()"). Default is empty, which is interpreted as "denyAll()"
|
||||
* (no access).
|
||||
* Spring Security access rule for the token key endpoint (e.g. a SpEL expression like
|
||||
* "isAuthenticated()"). Default is empty, which is interpreted as "denyAll()" (no
|
||||
* access).
|
||||
*/
|
||||
private String tokenKeyAccess;
|
||||
|
||||
/**
|
||||
* The realm name for client authentication. If an unauthenticated request comes in to
|
||||
* the token endpoint, it will respond with a challenge including this name.
|
||||
* Realm name for client authentication. If an unauthenticated request comes in to the
|
||||
* token endpoint, it will respond with a challenge including this name.
|
||||
*/
|
||||
private String realm;
|
||||
|
||||
|
@ -429,8 +429,7 @@ public class WebMvcAutoConfiguration {
|
||||
for (HandlerExceptionResolver resolver : exceptionResolvers) {
|
||||
if (resolver instanceof AbstractHandlerExceptionResolver) {
|
||||
((AbstractHandlerExceptionResolver) resolver)
|
||||
.setWarnLogCategory(resolver.getClass()
|
||||
.getName());
|
||||
.setWarnLogCategory(resolver.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,14 +71,12 @@ public class CassandraDataAutoConfigurationIntegrationTests {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
String cityPackage = City.class.getPackage().getName();
|
||||
AutoConfigurationPackages.register(this.context, cityPackage);
|
||||
|
||||
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,
|
||||
CassandraDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
CassandraSessionFactoryBean bean = this.context
|
||||
.getBean(CassandraSessionFactoryBean.class);
|
||||
assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.RECREATE_DROP_UNUSED);
|
||||
|
@ -91,7 +91,8 @@ public class CassandraTestServer implements TestRule {
|
||||
|
||||
@Override
|
||||
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
|
||||
public void deviceDelegatingJspResourceViewResolver() throws Exception {
|
||||
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
|
||||
.getBean(InternalResourceViewResolver.class);
|
||||
assertLiteDeviceDelegatingViewResolver(internalResourceViewResolver,
|
||||
@ -90,8 +91,10 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
|
||||
public void deviceDelegatingFreemarkerViewResolver() throws Exception {
|
||||
load(Collections.<Class<?>>singletonList(FreeMarkerAutoConfiguration.class),
|
||||
"spring.mobile.devicedelegatingviewresolver.enabled:true");
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(this.context.getBean(FreeMarkerViewResolver.class),
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
|
||||
.hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(
|
||||
this.context.getBean(FreeMarkerViewResolver.class),
|
||||
"deviceDelegatingFreemarkerViewResolver");
|
||||
}
|
||||
|
||||
@ -99,8 +102,10 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
|
||||
public void deviceDelegatingGroovyMarkupViewResolver() throws Exception {
|
||||
load(Collections.<Class<?>>singletonList(GroovyTemplateAutoConfiguration.class),
|
||||
"spring.mobile.devicedelegatingviewresolver.enabled:true");
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(this.context.getBean(GroovyMarkupViewResolver.class),
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
|
||||
.hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(
|
||||
this.context.getBean(GroovyMarkupViewResolver.class),
|
||||
"deviceDelegatingGroovyMarkupViewResolver");
|
||||
}
|
||||
|
||||
@ -108,8 +113,10 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
|
||||
public void deviceDelegatingMustacheViewResolver() throws Exception {
|
||||
load(Collections.<Class<?>>singletonList(MustacheAutoConfiguration.class),
|
||||
"spring.mobile.devicedelegatingviewresolver.enabled:true");
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(this.context.getBean(MustacheViewResolver.class),
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
|
||||
.hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(
|
||||
this.context.getBean(MustacheViewResolver.class),
|
||||
"deviceDelegatingMustacheViewResolver");
|
||||
}
|
||||
|
||||
@ -117,26 +124,30 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests {
|
||||
public void deviceDelegatingThymeleafViewResolver() throws Exception {
|
||||
load(Collections.<Class<?>>singletonList(ThymeleafAutoConfiguration.class),
|
||||
"spring.mobile.devicedelegatingviewresolver.enabled:true");
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(this.context.getBean(ThymeleafViewResolver.class),
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
|
||||
.hasSize(2);
|
||||
assertLiteDeviceDelegatingViewResolver(
|
||||
this.context.getBean(ThymeleafViewResolver.class),
|
||||
"deviceDelegatingThymeleafViewResolver");
|
||||
}
|
||||
|
||||
public void assertLiteDeviceDelegatingViewResolver(ViewResolver delegate, String delegatingBeanName) {
|
||||
public void assertLiteDeviceDelegatingViewResolver(ViewResolver delegate,
|
||||
String delegatingBeanName) {
|
||||
LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
|
||||
.getBean(delegatingBeanName, LiteDeviceDelegatingViewResolver.class);
|
||||
assertThat(deviceDelegatingViewResolver.getViewResolver())
|
||||
.isSameAs(delegate);
|
||||
assertThat(deviceDelegatingViewResolver.getViewResolver()).isSameAs(delegate);
|
||||
assertThat(deviceDelegatingViewResolver.getOrder())
|
||||
.isEqualTo(((Ordered) delegate).getOrder() - 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceDelegatingViewResolverDisabled() throws Exception {
|
||||
load(Arrays.asList(FreeMarkerAutoConfiguration.class, GroovyTemplateAutoConfiguration.class,
|
||||
MustacheAutoConfiguration.class, ThymeleafAutoConfiguration.class),
|
||||
load(Arrays.asList(FreeMarkerAutoConfiguration.class,
|
||||
GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class,
|
||||
ThymeleafAutoConfiguration.class),
|
||||
"spring.mobile.devicedelegatingviewresolver.enabled:false");
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)).hasSize(0);
|
||||
assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class))
|
||||
.hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,7 +48,7 @@ public class MongoPropertiesTests {
|
||||
// gh-1572
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(context, "spring.data.mongodb.password:word");
|
||||
context.register(Conf.class);
|
||||
context.register(Config.class);
|
||||
context.refresh();
|
||||
MongoProperties properties = context.getBean(MongoProperties.class);
|
||||
assertThat(properties.getPassword()).isEqualTo("word".toCharArray());
|
||||
@ -123,50 +123,58 @@ public class MongoPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void allMongoClientOptionsCanBeSet() throws UnknownHostException {
|
||||
MongoClientOptions mco = MongoClientOptions.builder()
|
||||
.alwaysUseMBeans(true)
|
||||
.connectionsPerHost(101)
|
||||
.connectTimeout(10001)
|
||||
.cursorFinalizerEnabled(false)
|
||||
.description("test")
|
||||
.maxWaitTime(120001)
|
||||
.socketKeepAlive(true)
|
||||
.socketTimeout(1000)
|
||||
.threadsAllowedToBlockForConnectionMultiplier(6)
|
||||
.minConnectionsPerHost(0)
|
||||
.maxConnectionIdleTime(60000)
|
||||
.maxConnectionLifeTime(60000)
|
||||
.heartbeatFrequency(10001)
|
||||
.minHeartbeatFrequency(501)
|
||||
.heartbeatConnectTimeout(20001)
|
||||
.heartbeatSocketTimeout(20001)
|
||||
.localThreshold(20)
|
||||
.requiredReplicaSetName("testReplicaSetName")
|
||||
.build();
|
||||
|
||||
MongoClientOptions.Builder builder = MongoClientOptions.builder();
|
||||
builder.alwaysUseMBeans(true);
|
||||
builder.connectionsPerHost(101);
|
||||
builder.connectTimeout(10001);
|
||||
builder.cursorFinalizerEnabled(false);
|
||||
builder.description("test");
|
||||
builder.maxWaitTime(120001);
|
||||
builder.socketKeepAlive(true);
|
||||
builder.socketTimeout(1000);
|
||||
builder.threadsAllowedToBlockForConnectionMultiplier(6);
|
||||
builder.minConnectionsPerHost(0);
|
||||
builder.maxConnectionIdleTime(60000);
|
||||
builder.maxConnectionLifeTime(60000);
|
||||
builder.heartbeatFrequency(10001);
|
||||
builder.minHeartbeatFrequency(501);
|
||||
builder.heartbeatConnectTimeout(20001);
|
||||
builder.heartbeatSocketTimeout(20001);
|
||||
builder.localThreshold(20);
|
||||
builder.requiredReplicaSetName("testReplicaSetName");
|
||||
MongoClientOptions options = builder.build();
|
||||
MongoProperties properties = new MongoProperties();
|
||||
MongoClient client = properties.createMongoClient(mco, null);
|
||||
MongoClientOptions wrappedMco = client.getMongoClientOptions();
|
||||
|
||||
assertThat(wrappedMco.isAlwaysUseMBeans()).isEqualTo(mco.isAlwaysUseMBeans());
|
||||
assertThat(wrappedMco.getConnectionsPerHost()).isEqualTo(mco.getConnectionsPerHost());
|
||||
assertThat(wrappedMco.getConnectTimeout()).isEqualTo(mco.getConnectTimeout());
|
||||
assertThat(wrappedMco.isCursorFinalizerEnabled()).isEqualTo(mco.isCursorFinalizerEnabled());
|
||||
assertThat(wrappedMco.getDescription()).isEqualTo(mco.getDescription());
|
||||
assertThat(wrappedMco.getMaxWaitTime()).isEqualTo(mco.getMaxWaitTime());
|
||||
assertThat(wrappedMco.getSocketTimeout()).isEqualTo(mco.getSocketTimeout());
|
||||
assertThat(wrappedMco.isSocketKeepAlive()).isEqualTo(mco.isSocketKeepAlive());
|
||||
assertThat(wrappedMco.getThreadsAllowedToBlockForConnectionMultiplier()).isEqualTo(
|
||||
mco.getThreadsAllowedToBlockForConnectionMultiplier());
|
||||
assertThat(wrappedMco.getMinConnectionsPerHost()).isEqualTo(mco.getMinConnectionsPerHost());
|
||||
assertThat(wrappedMco.getMaxConnectionIdleTime()).isEqualTo(mco.getMaxConnectionIdleTime());
|
||||
assertThat(wrappedMco.getMaxConnectionLifeTime()).isEqualTo(mco.getMaxConnectionLifeTime());
|
||||
assertThat(wrappedMco.getHeartbeatFrequency()).isEqualTo(mco.getHeartbeatFrequency());
|
||||
assertThat(wrappedMco.getMinHeartbeatFrequency()).isEqualTo(mco.getMinHeartbeatFrequency());
|
||||
assertThat(wrappedMco.getHeartbeatConnectTimeout()).isEqualTo(mco.getHeartbeatConnectTimeout());
|
||||
assertThat(wrappedMco.getHeartbeatSocketTimeout()).isEqualTo(mco.getHeartbeatSocketTimeout());
|
||||
assertThat(wrappedMco.getLocalThreshold()).isEqualTo(mco.getLocalThreshold());
|
||||
assertThat(wrappedMco.getRequiredReplicaSetName()).isEqualTo(mco.getRequiredReplicaSetName());
|
||||
MongoClient client = properties.createMongoClient(options, null);
|
||||
MongoClientOptions wrapped = client.getMongoClientOptions();
|
||||
assertThat(wrapped.isAlwaysUseMBeans()).isEqualTo(options.isAlwaysUseMBeans());
|
||||
assertThat(wrapped.getConnectionsPerHost())
|
||||
.isEqualTo(options.getConnectionsPerHost());
|
||||
assertThat(wrapped.getConnectTimeout()).isEqualTo(options.getConnectTimeout());
|
||||
assertThat(wrapped.isCursorFinalizerEnabled())
|
||||
.isEqualTo(options.isCursorFinalizerEnabled());
|
||||
assertThat(wrapped.getDescription()).isEqualTo(options.getDescription());
|
||||
assertThat(wrapped.getMaxWaitTime()).isEqualTo(options.getMaxWaitTime());
|
||||
assertThat(wrapped.getSocketTimeout()).isEqualTo(options.getSocketTimeout());
|
||||
assertThat(wrapped.isSocketKeepAlive()).isEqualTo(options.isSocketKeepAlive());
|
||||
assertThat(wrapped.getThreadsAllowedToBlockForConnectionMultiplier())
|
||||
.isEqualTo(options.getThreadsAllowedToBlockForConnectionMultiplier());
|
||||
assertThat(wrapped.getMinConnectionsPerHost())
|
||||
.isEqualTo(options.getMinConnectionsPerHost());
|
||||
assertThat(wrapped.getMaxConnectionIdleTime())
|
||||
.isEqualTo(options.getMaxConnectionIdleTime());
|
||||
assertThat(wrapped.getMaxConnectionLifeTime())
|
||||
.isEqualTo(options.getMaxConnectionLifeTime());
|
||||
assertThat(wrapped.getHeartbeatFrequency())
|
||||
.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) {
|
||||
@ -192,7 +200,7 @@ public class MongoPropertiesTests {
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(MongoProperties.class)
|
||||
static class Conf {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
@ -541,20 +541,22 @@ public class WebMvcAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private void testLogResolvedExceptionCustomization(final boolean expected) {
|
||||
HandlerExceptionResolver exceptionResolver = this.context.getBean(
|
||||
HandlerExceptionResolver.class);
|
||||
assertThat(exceptionResolver).isInstanceOf(HandlerExceptionResolverComposite.class);
|
||||
List<HandlerExceptionResolver> delegates =
|
||||
((HandlerExceptionResolverComposite) exceptionResolver).getExceptionResolvers();
|
||||
HandlerExceptionResolver exceptionResolver = this.context
|
||||
.getBean(HandlerExceptionResolver.class);
|
||||
assertThat(exceptionResolver)
|
||||
.isInstanceOf(HandlerExceptionResolverComposite.class);
|
||||
List<HandlerExceptionResolver> delegates = ((HandlerExceptionResolverComposite) exceptionResolver)
|
||||
.getExceptionResolvers();
|
||||
for (HandlerExceptionResolver delegate : delegates) {
|
||||
if (delegate instanceof AbstractHandlerMethodAdapter) {
|
||||
assertThat(new DirectFieldAccessor(delegate).getPropertyValue("warnLogger"))
|
||||
.is(new Condition<Object>() {
|
||||
@Override
|
||||
public boolean matches(Object value) {
|
||||
return (expected ? value != null : value == null);
|
||||
}
|
||||
});
|
||||
assertThat(
|
||||
new DirectFieldAccessor(delegate).getPropertyValue("warnLogger"))
|
||||
.is(new Condition<Object>() {
|
||||
@Override
|
||||
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.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@ -37,7 +39,12 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -159,23 +166,23 @@ public class ConfigurationMetadata {
|
||||
}
|
||||
|
||||
static String toDashedCase(String name) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder dashed = new StringBuilder();
|
||||
Character previous = null;
|
||||
for (char current : name.toCharArray()) {
|
||||
if (SEPARATORS.contains(current)) {
|
||||
sb.append("-");
|
||||
dashed.append("-");
|
||||
}
|
||||
else if (Character.isUpperCase(current) && previous != null
|
||||
&& !SEPARATORS.contains(previous)) {
|
||||
sb.append("-").append(current);
|
||||
dashed.append("-").append(current);
|
||||
}
|
||||
else {
|
||||
sb.append(current);
|
||||
dashed.append(current);
|
||||
}
|
||||
previous = current;
|
||||
|
||||
}
|
||||
return sb.toString().toLowerCase();
|
||||
return dashed.toString().toLowerCase();
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> List<T> flattenValues(
|
||||
|
@ -259,6 +259,7 @@ public class PropertiesConfigurationFactoryTests {
|
||||
public void setFooDLQBar(String fooDLQBar) {
|
||||
this.fooDLQBar = fooDLQBar;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user