From 266445aaf0c69441f5ea7fee83c8f9e9357c2ff1 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 29 Jun 2016 10:44:33 -0700 Subject: [PATCH] Polish --- .../boot/actuate/trace/TraceProperties.java | 4 +- .../CassandraDataAutoConfiguration.java | 7 +- ...legatingViewResolverAutoConfiguration.java | 4 +- .../DeviceDelegatingViewResolverFactory.java | 14 +-- .../AuthorizationServerProperties.java | 12 +-- .../web/WebMvcAutoConfiguration.java | 3 +- ...DataAutoConfigurationIntegrationTests.java | 6 +- .../data/cassandra/CassandraTestServer.java | 3 +- ...ingViewResolverAutoConfigurationTests.java | 41 +++++--- .../mongo/MongoPropertiesTests.java | 98 ++++++++++--------- .../web/WebMvcAutoConfigurationTests.java | 26 ++--- .../metadata/ConfigurationMetadata.java | 19 ++-- .../PropertiesConfigurationFactoryTests.java | 1 + 13 files changed, 134 insertions(+), 104 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceProperties.java index 3233ead562d..4bc9a24c1f7 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceProperties.java @@ -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 = new HashSet(DEFAULT_INCLUDES); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java index 72772348ccf..26fb0d66748 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java @@ -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; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java index e70f5fd8b6c..e27b5557103 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java @@ -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 diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverFactory.java index b0ba4255925..6ab4234766f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverFactory.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverFactory.java @@ -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)); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java index 1f70da5e172..3dd52b4b3fb 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/AuthorizationServerProperties.java @@ -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; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index 5b1766728a1..69c1f4c4f94 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -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()); } } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java index 2c98e6f6f1e..074f9d0eab1 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java @@ -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); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraTestServer.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraTestServer.java index 5fcb6a0b331..300b3f20bde 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraTestServer.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraTestServer.java @@ -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); } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfigurationTests.java index 157dd9a001b..0bbe42e7a8b 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfigurationTests.java @@ -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.>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.>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.>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.>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 diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java index 77ff362769f..51001affb07 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java @@ -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 extractServerAddresses(MongoClient client) { @@ -192,7 +200,7 @@ public class MongoPropertiesTests { @Configuration @EnableConfigurationProperties(MongoProperties.class) - static class Conf { + static class Config { } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java index c1abfaba1e5..4835c995cea 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java @@ -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 delegates = - ((HandlerExceptionResolverComposite) exceptionResolver).getExceptionResolvers(); + HandlerExceptionResolver exceptionResolver = this.context + .getBean(HandlerExceptionResolver.class); + assertThat(exceptionResolver) + .isInstanceOf(HandlerExceptionResolverComposite.class); + List delegates = ((HandlerExceptionResolverComposite) exceptionResolver) + .getExceptionResolvers(); for (HandlerExceptionResolver delegate : delegates) { if (delegate instanceof AbstractHandlerMethodAdapter) { - assertThat(new DirectFieldAccessor(delegate).getPropertyValue("warnLogger")) - .is(new Condition() { - @Override - public boolean matches(Object value) { - return (expected ? value != null : value == null); - } - }); + assertThat( + new DirectFieldAccessor(delegate).getPropertyValue("warnLogger")) + .is(new Condition() { + @Override + public boolean matches(Object value) { + return (expected ? value != null : value == null); + } + }); } } } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java index c963cd16121..be735020dc2 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java @@ -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 SEPARATORS = Arrays.asList('-', '_'); + private static final Set SEPARATORS; + + static { + List chars = Arrays.asList('-', '_'); + SEPARATORS = Collections.unmodifiableSet(new HashSet(chars)); + } private final MultiValueMap 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 > List flattenValues( diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java index d827da30d88..ac999c4acae 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java @@ -259,6 +259,7 @@ public class PropertiesConfigurationFactoryTests { public void setFooDLQBar(String fooDLQBar) { this.fooDLQBar = fooDLQBar; } + } }