diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MvcEndpointCorsProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointCorsProperties.java similarity index 72% rename from spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MvcEndpointCorsProperties.java rename to spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointCorsProperties.java index aaddb94663b..8f2ba01ae3d 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MvcEndpointCorsProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointCorsProperties.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.util.CollectionUtils; -import org.springframework.web.cors.CorsConfiguration; /** * Configuration properties for MVC endpoints' CORS support. @@ -30,23 +28,22 @@ import org.springframework.web.cors.CorsConfiguration; * @since 1.3.0 */ @ConfigurationProperties(prefix = "endpoints.cors") -public class MvcEndpointCorsProperties { +public class EndpointCorsProperties { /** - * Comma-separated list of origins to allow. '*' allows all origins. When - * not set, CORS support is disabled. + * Comma-separated list of origins to allow. '*' allows all origins. When not set, + * CORS support is disabled. */ private List allowedOrigins = new ArrayList(); /** - * Comma-separated list of methods to allow. '*' allows all methods. When - * not set, defaults to GET. + * Comma-separated list of methods to allow. '*' allows all methods. When not set, + * defaults to GET. */ private List allowedMethods = new ArrayList(); /** - * Comma-separated list of headers to allow in a request. '*' allows all - * headers. + * Comma-separated list of headers to allow in a request. '*' allows all headers. */ private List allowedHeaders = new ArrayList(); @@ -114,28 +111,4 @@ public class MvcEndpointCorsProperties { this.maxAge = maxAge; } - CorsConfiguration toCorsConfiguration() { - if (CollectionUtils.isEmpty(this.allowedOrigins)) { - return null; - } - CorsConfiguration corsConfiguration = new CorsConfiguration(); - corsConfiguration.setAllowedOrigins(this.allowedOrigins); - if (!CollectionUtils.isEmpty(this.allowedHeaders)) { - corsConfiguration.setAllowedHeaders(this.allowedHeaders); - } - if (!CollectionUtils.isEmpty(this.allowedMethods)) { - corsConfiguration.setAllowedMethods(this.allowedMethods); - } - if (!CollectionUtils.isEmpty(this.exposedHeaders)) { - corsConfiguration.setExposedHeaders(this.exposedHeaders); - } - if (this.maxAge != null) { - corsConfiguration.setMaxAge(this.maxAge); - } - if (this.allowCredentials != null) { - corsConfiguration.setAllowCredentials(this.allowCredentials); - } - return corsConfiguration; - } - } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java index acc8d789703..af83416297e 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java @@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure; import java.io.IOException; import java.util.List; +import java.util.Set; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -45,6 +46,7 @@ import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMappingCusto import org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint; import org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint; import org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint; +import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints; import org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint; import org.springframework.boot.autoconfigure.AutoConfigureAfter; @@ -71,7 +73,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.event.ContextClosedEvent; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.PropertySource; +import org.springframework.util.CollectionUtils; import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.servlet.DispatcherServlet; @@ -94,7 +98,7 @@ import org.springframework.web.servlet.DispatcherServlet; EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class }) @EnableConfigurationProperties({ HealthMvcEndpointProperties.class, - MvcEndpointCorsProperties.class }) + EndpointCorsProperties.class }) public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, SmartInitializingSingleton { @@ -109,7 +113,7 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, private ManagementServerProperties managementServerProperties; @Autowired - private MvcEndpointCorsProperties corsMvcEndpointProperties; + private EndpointCorsProperties corsProperties; @Autowired(required = false) private List mappingCustomizers; @@ -123,8 +127,10 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, @Bean @ConditionalOnMissingBean public EndpointHandlerMapping endpointHandlerMapping() { - EndpointHandlerMapping mapping = new EndpointHandlerMapping(mvcEndpoints() - .getEndpoints(), this.corsMvcEndpointProperties.toCorsConfiguration()); + Set endpoints = mvcEndpoints().getEndpoints(); + CorsConfiguration corsConfiguration = getCorsConfiguration(this.corsProperties); + EndpointHandlerMapping mapping = new EndpointHandlerMapping(endpoints, + corsConfiguration); boolean disabled = ManagementServerPort.get(this.applicationContext) != ManagementServerPort.SAME; mapping.setDisabled(disabled); if (!disabled) { @@ -138,6 +144,30 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, return mapping; } + private CorsConfiguration getCorsConfiguration(EndpointCorsProperties properties) { + if (CollectionUtils.isEmpty(properties.getAllowedOrigins())) { + return null; + } + CorsConfiguration configuration = new CorsConfiguration(); + configuration.setAllowedOrigins(properties.getAllowedOrigins()); + if (!CollectionUtils.isEmpty(properties.getAllowedHeaders())) { + configuration.setAllowedHeaders(properties.getAllowedHeaders()); + } + if (!CollectionUtils.isEmpty(properties.getAllowedMethods())) { + configuration.setAllowedMethods(properties.getAllowedMethods()); + } + if (!CollectionUtils.isEmpty(properties.getExposedHeaders())) { + configuration.setExposedHeaders(properties.getExposedHeaders()); + } + if (properties.getMaxAge() != null) { + configuration.setMaxAge(properties.getMaxAge()); + } + if (properties.getAllowCredentials() != null) { + configuration.setAllowCredentials(properties.getAllowCredentials()); + } + return configuration; + } + @Override public void afterSingletonsInstantiated() { ManagementServerPort managementPort = ManagementServerPort diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java index bc0a606a6d2..8b4fbca6958 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,8 @@ package org.springframework.boot.actuate; import org.springframework.boot.test.AbstractConfigurationClassTests; /** - * Tests for the actuator module's @Configuration classes + * Tests for the actuator module's {@code @Configuration} classes. + * * @author Andy Wilkinson */ public class ActuatorConfigurationClassTests extends AbstractConfigurationClassTests { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java index 85c895c552a..ad43b604a47 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java @@ -52,18 +52,15 @@ public class SpringApplicationHierarchyTests { "--server.port=0"); } - @EnableAutoConfiguration(exclude = { - ElasticsearchDataAutoConfiguration.class, - ElasticsearchRepositoriesAutoConfiguration.class}, - excludeName = {"org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration"}) + @EnableAutoConfiguration(exclude = { ElasticsearchDataAutoConfiguration.class, + ElasticsearchRepositoriesAutoConfiguration.class }, excludeName = { "org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration" }) public static class Child { } - @EnableAutoConfiguration(exclude = {JolokiaAutoConfiguration.class, + @EnableAutoConfiguration(exclude = { JolokiaAutoConfiguration.class, EndpointMBeanExportAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class, - ElasticsearchRepositoriesAutoConfiguration.class}, - excludeName = {"org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration"}) + ElasticsearchRepositoriesAutoConfiguration.class }, excludeName = { "org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration" }) public static class Parent { } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfiguration.java index e1a5b07a6fb..d7837380f42 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfiguration.java @@ -84,6 +84,7 @@ public @interface EnableAutoConfiguration { * Exclude specific auto-configuration class names such that they will never be * applied. * @return the class names to exclude + * @since 1.3.0 */ String[] excludeName() default {}; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java index eddff6c0aeb..3011156a4ce 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; @@ -73,8 +74,8 @@ class EnableAutoConfigurationImportSelector implements DeferredImportSelector, SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, this.beanClassLoader))); - // Remove those specifically disabled - List excluded = new ArrayList(); + // Remove those specifically excluded + Set excluded = new LinkedHashSet(); excluded.addAll(Arrays.asList(attributes.getStringArray("exclude"))); excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName"))); factories.removeAll(excluded); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java index 250bb493437..d283147b868 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java @@ -57,6 +57,7 @@ public @interface SpringBootApplication { * Exclude specific auto-configuration class names such that they will never be * applied. * @return the class names to exclude + * @since 1.3.0 */ String[] excludeName() default {}; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index 53ae47e1cc3..0f517e6194e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -106,7 +106,8 @@ public class RabbitAutoConfiguration { protected static class RabbitConnectionFactoryCreator { @Bean - public ConnectionFactory rabbitConnectionFactory(RabbitProperties config) throws Exception { + public ConnectionFactory rabbitConnectionFactory(RabbitProperties config) + throws Exception { RabbitConnectionFactoryBean factory = new RabbitConnectionFactoryBean(); if (config.getHost() != null) { factory.setHost(config.getHost()); @@ -131,12 +132,13 @@ public class RabbitAutoConfiguration { Properties properties = ssl.createSslProperties(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); properties.store(outputStream, "SSL config"); - factory.setSslPropertiesLocation( - new ByteArrayResource(outputStream.toByteArray())); + factory.setSslPropertiesLocation(new ByteArrayResource(outputStream + .toByteArray())); } } factory.afterPropertiesSet(); - CachingConnectionFactory connectionFactory = new CachingConnectionFactory(factory.getObject()); + CachingConnectionFactory connectionFactory = new CachingConnectionFactory( + factory.getObject()); connectionFactory.setAddresses(config.getAddresses()); return connectionFactory; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 2c29915b6ca..4cdd3d239c1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -73,7 +73,6 @@ public class RabbitProperties { */ private Integer requestedHeartbeat; - public String getHost() { if (this.addresses == null) { return this.host; @@ -161,7 +160,7 @@ public class RabbitProperties { } public Ssl getSsl() { - return ssl; + return this.ssl; } public String getVirtualHost() { @@ -173,7 +172,7 @@ public class RabbitProperties { } public Integer getRequestedHeartbeat() { - return requestedHeartbeat; + return this.requestedHeartbeat; } public void setRequestedHeartbeat(Integer requestedHeartbeat) { @@ -208,7 +207,7 @@ public class RabbitProperties { private String trustStorePassword; public boolean isEnabled() { - return enabled; + return this.enabled; } public void setEnabled(boolean enabled) { @@ -216,7 +215,7 @@ public class RabbitProperties { } public String getKeyStore() { - return keyStore; + return this.keyStore; } public void setKeyStore(String keyStore) { @@ -224,7 +223,7 @@ public class RabbitProperties { } public String getKeyStorePassword() { - return keyStorePassword; + return this.keyStorePassword; } public void setKeyStorePassword(String keyStorePassword) { @@ -232,7 +231,7 @@ public class RabbitProperties { } public String getTrustStore() { - return trustStore; + return this.trustStore; } public void setTrustStore(String trustStore) { @@ -240,7 +239,7 @@ public class RabbitProperties { } public String getTrustStorePassword() { - return trustStorePassword; + return this.trustStorePassword; } public void setTrustStorePassword(String trustStorePassword) { @@ -249,7 +248,8 @@ public class RabbitProperties { /** * Create the ssl configuration as expected by the - * {@link org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean RabbitConnectionFactoryBean}. + * {@link org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean + * RabbitConnectionFactoryBean}. * @return the ssl configuration */ public Properties createSslProperties() { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java index 54863621f04..28e93449be0 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java @@ -62,6 +62,7 @@ class BasicBatchConfigurer implements BatchConfigurer { /** * Create a new {@link BasicBatchConfigurer} instance. + * @param properties the batch properties * @param dataSource the underlying data source */ public BasicBatchConfigurer(BatchProperties properties, DataSource dataSource) { @@ -70,6 +71,7 @@ class BasicBatchConfigurer implements BatchConfigurer { /** * Create a new {@link BasicBatchConfigurer} instance. + * @param properties the batch properties * @param dataSource the underlying data source * @param entityManagerFactory the entity manager factory (or {@code null}) */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index 6760a5185fc..562c07a066a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -141,7 +141,8 @@ public class BatchAutoConfiguration { @ConditionalOnBean(name = "entityManagerFactory") public BatchConfigurer jpaBatchConfigurer(DataSource dataSource, EntityManagerFactory entityManagerFactory) { - return new BasicBatchConfigurer(this.properties, dataSource, entityManagerFactory); + return new BasicBatchConfigurer(this.properties, dataSource, + entityManagerFactory); } @Bean diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java index bb470e1869d..f128ece2230 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java @@ -17,6 +17,7 @@ package org.springframework.boot.autoconfigure.condition; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; @@ -86,7 +87,7 @@ public class ConditionEvaluationReport { * Records the name of the classes that have been excluded from condition evaluation * @param exclusions the names of the excluded classes */ - public void recordExclusions(List exclusions) { + public void recordExclusions(Collection exclusions) { Assert.notNull(exclusions, "exclusions must not be null"); this.exclusions = new ArrayList(exclusions); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/JndiSessionConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/JndiSessionConfiguration.java index fda10ceb8eb..cf851058e9c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/JndiSessionConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/JndiSessionConfiguration.java @@ -47,13 +47,13 @@ class JndiSessionConfiguration { @Bean @ConditionalOnMissingBean public Session session() { + String jndiName = this.properties.getJndiName(); try { - return new JndiLocatorDelegate() - .lookup(this.properties.getJndiName(), Session.class); + return new JndiLocatorDelegate().lookup(jndiName, Session.class); } - catch (NamingException e) { + catch (NamingException ex) { throw new IllegalStateException(String.format( - "Unable to find Session in JNDI location %s", this.properties.getJndiName())); + "Unable to find Session in JNDI location %s", jndiName), ex); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java index 7245af925d3..5349a52a514 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java @@ -118,4 +118,5 @@ public class MailProperties { public String getJndiName() { return this.jndiName; } + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java index 72f39e38f0b..640a39635ff 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java @@ -16,7 +16,9 @@ package org.springframework.boot.autoconfigure.mail; +import java.util.Map; import java.util.Properties; + import javax.activation.MimeType; import javax.mail.Session; import javax.mail.internet.MimeMessage; @@ -65,25 +67,33 @@ public class MailSenderAutoConfiguration { sender.setSession(this.session); } else { - sender.setHost(this.properties.getHost()); - if (this.properties.getPort() != null) { - sender.setPort(this.properties.getPort()); - } - sender.setUsername(this.properties.getUsername()); - sender.setPassword(this.properties.getPassword()); - sender.setDefaultEncoding(this.properties.getDefaultEncoding()); - if (!this.properties.getProperties().isEmpty()) { - Properties properties = new Properties(); - properties.putAll(this.properties.getProperties()); - sender.setJavaMailProperties(properties); - } + applyProperties(sender); } return sender; } + private void applyProperties(JavaMailSenderImpl sender) { + sender.setHost(this.properties.getHost()); + if (this.properties.getPort() != null) { + sender.setPort(this.properties.getPort()); + } + sender.setUsername(this.properties.getUsername()); + sender.setPassword(this.properties.getPassword()); + sender.setDefaultEncoding(this.properties.getDefaultEncoding()); + if (!this.properties.getProperties().isEmpty()) { + sender.setJavaMailProperties(asProperties(this.properties.getProperties())); + } + } + + private Properties asProperties(Map source) { + Properties properties = new Properties(); + properties.putAll(source); + return properties; + } + /** - * Condition to trigger the creation of a {@link JavaMailSenderImpl}. This kicks in - * if either the host or jndi name property is set. + * Condition to trigger the creation of a {@link JavaMailSenderImpl}. This kicks in if + * either the host or jndi name property is set. */ static class MailSenderCondition extends AnyNestedCondition { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java index e1c534b45f4..ac62a019b0d 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java @@ -37,7 +37,6 @@ import org.springframework.social.connect.ConnectionFactory; import org.springframework.social.connect.ConnectionRepository; import org.springframework.social.connect.web.GenericConnectionStatusView; import org.springframework.social.facebook.api.Facebook; -import org.springframework.social.facebook.api.impl.FacebookTemplate; import org.springframework.social.facebook.connect.FacebookConnectionFactory; import org.springframework.web.servlet.View; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index ca1aa542900..e6749d15e8c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -463,14 +463,36 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord if (getBasedir() != null) { factory.setBaseDirectory(getBasedir()); } + customizeBackgroundProcessorDelay(factory); + customizeHeaders(factory); + if (this.maxThreads > 0) { + customizeMaxThreads(factory); + } + if (this.maxHttpHeaderSize > 0) { + customizeMaxHttpHeaderSize(factory); + } + customizeCompression(factory); + if (this.accessLogEnabled) { + customizeAccessLog(factory); + } + if (getUriEncoding() != null) { + factory.setUriEncoding(getUriEncoding()); + } + } + private void customizeBackgroundProcessorDelay( + TomcatEmbeddedServletContainerFactory factory) { factory.addContextCustomizers(new TomcatContextCustomizer() { + @Override public void customize(Context context) { context.setBackgroundProcessorDelay(Tomcat.this.backgroundProcessorDelay); } - }); + }); + } + + private void customizeHeaders(TomcatEmbeddedServletContainerFactory factory) { String remoteIpHeader = getRemoteIpHeader(); String protocolHeader = getProtocolHeader(); if (StringUtils.hasText(remoteIpHeader) @@ -482,35 +504,42 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord valve.setPortHeader(getPortHeader()); factory.addContextValves(valve); } + } - if (this.maxThreads > 0) { - factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { - @Override - public void customize(Connector connector) { - ProtocolHandler handler = connector.getProtocolHandler(); - if (handler instanceof AbstractProtocol) { - @SuppressWarnings("rawtypes") - AbstractProtocol protocol = (AbstractProtocol) handler; - protocol.setMaxThreads(Tomcat.this.maxThreads); - } + @SuppressWarnings("rawtypes") + private void customizeMaxThreads(TomcatEmbeddedServletContainerFactory factory) { + factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { + @Override + public void customize(Connector connector) { + + ProtocolHandler handler = connector.getProtocolHandler(); + if (handler instanceof AbstractProtocol) { + AbstractProtocol protocol = (AbstractProtocol) handler; + protocol.setMaxThreads(Tomcat.this.maxThreads); } - }); - } - if (this.maxHttpHeaderSize > 0) { - factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { - @Override - public void customize(Connector connector) { - ProtocolHandler handler = connector.getProtocolHandler(); - if (handler instanceof AbstractHttp11Protocol) { - @SuppressWarnings("rawtypes") - AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler; - protocol.setMaxHttpHeaderSize(Tomcat.this.maxHttpHeaderSize); - } + } + }); + } + + @SuppressWarnings("rawtypes") + private void customizeMaxHttpHeaderSize( + TomcatEmbeddedServletContainerFactory factory) { + factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { + + @Override + public void customize(Connector connector) { + ProtocolHandler handler = connector.getProtocolHandler(); + if (handler instanceof AbstractHttp11Protocol) { + AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler; + protocol.setMaxHttpHeaderSize(Tomcat.this.maxHttpHeaderSize); } - }); - } + } + }); + } + + private void customizeCompression(TomcatEmbeddedServletContainerFactory factory) { factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override @@ -535,22 +564,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } }); + } - if (this.accessLogEnabled) { - AccessLogValve valve = new AccessLogValve(); - String accessLogPattern = getAccessLogPattern(); - if (accessLogPattern != null) { - valve.setPattern(accessLogPattern); - } - else { - valve.setPattern("common"); - } - valve.setSuffix(".log"); - factory.addContextValves(valve); - } - if (getUriEncoding() != null) { - factory.setUriEncoding(getUriEncoding()); - } + private void customizeAccessLog(TomcatEmbeddedServletContainerFactory factory) { + AccessLogValve valve = new AccessLogValve(); + String accessLogPattern = getAccessLogPattern(); + valve.setPattern(accessLogPattern == null ? "common" : accessLogPattern); + valve.setSuffix(".log"); + factory.addContextValves(valve); } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java index 1c042940a51..5c2794892da 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,8 @@ package org.springframework.boot.autoconfigure; import org.springframework.boot.test.AbstractConfigurationClassTests; /** - * Tests for the autoconfigure module's @Configuration classes + * Tests for the auto-configure module's {@code @Configuration} classes. + * * @author Andy Wilkinson */ public class AutoConfigureConfigurationClassTests extends AbstractConfigurationClassTests { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java index 010a18145f7..01ce4c9c822 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java @@ -81,7 +81,8 @@ public class EnableAutoConfigurationImportSelectorTests { @Test public void classExclusionsAreApplied() { - configureExclusions(new String[]{FreeMarkerAutoConfiguration.class.getName()}, new String[0]); + configureExclusions(new String[] { FreeMarkerAutoConfiguration.class.getName() }, + new String[0]); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 1))); @@ -91,7 +92,8 @@ public class EnableAutoConfigurationImportSelectorTests { @Test public void classNamesExclusionsAreApplied() { - configureExclusions(new String[0], new String[]{VelocityAutoConfiguration.class.getName()}); + configureExclusions(new String[0], + new String[] { VelocityAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 1))); @@ -101,12 +103,13 @@ public class EnableAutoConfigurationImportSelectorTests { @Test public void bothExclusionsAreApplied() { - configureExclusions(new String[]{VelocityAutoConfiguration.class.getName()}, - new String[]{FreeMarkerAutoConfiguration.class.getName()}); + configureExclusions(new String[] { VelocityAutoConfiguration.class.getName() }, + new String[] { FreeMarkerAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports.length, is(equalTo(getAutoConfigurationClassNames().size() - 2))); - assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions(), + assertThat( + ConditionEvaluationReport.get(this.beanFactory).getExclusions(), containsInAnyOrder(FreeMarkerAutoConfiguration.class.getName(), VelocityAutoConfiguration.class.getName())); } @@ -116,8 +119,10 @@ public class EnableAutoConfigurationImportSelectorTests { this.annotationMetadata.getAnnotationAttributes( EnableAutoConfiguration.class.getName(), true)).willReturn( this.annotationAttributes); - given(this.annotationAttributes.getStringArray("exclude")).willReturn(classExclusion); - given(this.annotationAttributes.getStringArray("excludeName")).willReturn(nameExclusion); + given(this.annotationAttributes.getStringArray("exclude")).willReturn( + classExclusion); + given(this.annotationAttributes.getStringArray("excludeName")).willReturn( + nameExclusion); } private List getAutoConfigurationClassNames() { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index 6c4bc976116..532107b7152 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -212,13 +212,15 @@ public class RabbitAutoConfigurationTests { public void enableSsl() { load(TestConfiguration.class, "spring.rabbitmq.ssl.enabled:true"); com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory(); - assertTrue("SocketFactory must use SSL", rabbitConnectionFactory.getSocketFactory() instanceof SSLSocketFactory); + assertTrue("SocketFactory must use SSL", + rabbitConnectionFactory.getSocketFactory() instanceof SSLSocketFactory); } - @Test // Make sure that we at least attempt to load the store + @Test + // Make sure that we at least attempt to load the store public void enableSslWithExtraConfig() { - thrown.expectMessage("foo"); - thrown.expectMessage("does not exist"); + this.thrown.expectMessage("foo"); + this.thrown.expectMessage("does not exist"); load(TestConfiguration.class, "spring.rabbitmq.ssl.enabled:true", "spring.rabbitmq.ssl.keyStore=foo", "spring.rabbitmq.ssl.keyStorePassword=secret", @@ -229,8 +231,8 @@ public class RabbitAutoConfigurationTests { private com.rabbitmq.client.ConnectionFactory getTargetConnectionFactory() { CachingConnectionFactory connectionFactory = this.context .getBean(CachingConnectionFactory.class); - return (com.rabbitmq.client.ConnectionFactory) - new DirectFieldAccessor(connectionFactory).getPropertyValue("rabbitConnectionFactory"); + return (com.rabbitmq.client.ConnectionFactory) new DirectFieldAccessor( + connectionFactory).getPropertyValue("rabbitConnectionFactory"); } private void load(Class config, String... environment) { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJsonSerializationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJsonSerializationTests.java index 1793755fc22..be1ab369d71 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJsonSerializationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJsonSerializationTests.java @@ -69,7 +69,7 @@ public class DataSourceJsonSerializationTests { public void serializerWithMixin() throws Exception { DataSource dataSource = new DataSource(); ObjectMapper mapper = new ObjectMapper(); - mapper.addMixInAnnotations(DataSource.class, DataSourceJson.class); + mapper.addMixIn(DataSource.class, DataSourceJson.class); String value = mapper.writeValueAsString(dataSource); assertTrue(value.contains("\"url\":")); assertEquals(1, StringUtils.countOccurrencesOf(value, "\"url\"")); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfigurationTests.java index 89df6cc483f..4069c012a9f 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfigurationTests.java @@ -79,9 +79,10 @@ public class DataSourceTransactionManagerAutoConfigurationTests { EmbeddedDataSourceConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class); this.context.refresh(); - assertEquals("No transaction manager should be been created", 1, - this.context.getBeansOfType(PlatformTransactionManager.class).size()); - assertEquals("Wrong transaction manager", this.context.getBean("myTransactionManager"), + assertEquals("No transaction manager should be been created", 1, this.context + .getBeansOfType(PlatformTransactionManager.class).size()); + assertEquals("Wrong transaction manager", + this.context.getBean("myTransactionManager"), this.context.getBean(PlatformTransactionManager.class)); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java index 3ab252b8a27..1cb1eec2f21 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java @@ -16,6 +16,12 @@ package org.springframework.boot.autoconfigure.mail; +import java.util.Properties; + +import javax.mail.Session; +import javax.naming.Context; +import javax.naming.NamingException; + import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -31,12 +37,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; -import javax.mail.Session; -import javax.naming.Context; -import javax.naming.NamingException; - -import java.util.Properties; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -78,7 +78,8 @@ public class MailSenderAutoConfigurationTests { if (this.initialContextFactory != null) { System.setProperty(Context.INITIAL_CONTEXT_FACTORY, this.initialContextFactory); - } else { + } + else { System.clearProperty(Context.INITIAL_CONTEXT_FACTORY); } if (this.context != null) { @@ -138,20 +139,18 @@ public class MailSenderAutoConfigurationTests { @Test public void jndiSessionAvailable() throws NamingException { - Session session = configureJndiSession("foo"); + Session session = configureJndiSession("foo"); load(EmptyConfig.class, "spring.mail.jndi-name:foo"); - Session sessionBean = this.context.getBean(Session.class); assertEquals(session, sessionBean); - assertEquals(sessionBean, this.context.getBean(JavaMailSenderImpl.class).getSession()); + assertEquals(sessionBean, this.context.getBean(JavaMailSenderImpl.class) + .getSession()); } @Test public void jndiSessionIgnoredIfJndiNameNotSet() throws NamingException { configureJndiSession("foo"); - load(EmptyConfig.class, "spring.mail.host:smtp.acme.org"); - assertEquals(0, this.context.getBeanNamesForType(Session.class).length); assertNotNull(this.context.getBean(JavaMailSender.class)); } @@ -159,23 +158,20 @@ public class MailSenderAutoConfigurationTests { @Test public void jndiSessionNotUsedIfJndiNameNotSet() throws NamingException { configureJndiSession("foo"); - load(EmptyConfig.class); - assertEquals(0, this.context.getBeanNamesForType(Session.class).length); - assertEquals(0, this.context.getBeanNamesForType(JavaMailSender.class).length); + assertEquals(0, this.context.getBeanNamesForType(JavaMailSender.class).length); } @Test public void jndiSessionNotAvailableWithJndiName() throws NamingException { - thrown.expect(BeanCreationException.class); - thrown.expectMessage("Unable to find Session in JNDI location foo"); - + this.thrown.expect(BeanCreationException.class); + this.thrown.expectMessage("Unable to find Session in JNDI location foo"); load(EmptyConfig.class, "spring.mail.jndi-name:foo"); } - private Session configureJndiSession(String name) - throws IllegalStateException, NamingException { + private Session configureJndiSession(String name) throws IllegalStateException, + NamingException { Properties properties = new Properties(); Session session = Session.getDefaultInstance(properties); TestableInitialContextFactory.bind(name, session); 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 54589110d53..c3db3c0b853 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 @@ -18,8 +18,6 @@ package org.springframework.boot.autoconfigure.mobile; import org.junit.After; import org.junit.Test; -import org.thymeleaf.spring4.view.ThymeleafViewResolver; - import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.PropertyAccessor; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -38,6 +36,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.mobile.device.view.AbstractDeviceDelegatingViewResolver; import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver; import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.thymeleaf.spring4.view.ThymeleafViewResolver; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -93,7 +92,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests { try { this.context.getBean(ThymeleafViewResolver.class); } - catch (NoSuchBeanDefinitionException e) { + catch (NoSuchBeanDefinitionException ex) { // expected. ThymeleafViewResolver shouldn't be defined. } assertTrue(deviceDelegatingViewResolver.getOrder() == internalResourceViewResolver @@ -114,7 +113,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests { try { this.context.getBean(ThymeleafViewResolver.class); } - catch (NoSuchBeanDefinitionException e) { + catch (NoSuchBeanDefinitionException ex) { // expected. ThymeleafViewResolver shouldn't be defined. } this.context.getBean("deviceDelegatingViewResolver", @@ -177,7 +176,8 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests { .getBean("deviceDelegatingViewResolver", LiteDeviceDelegatingViewResolver.class); - DirectFieldAccessor accessor = new DirectFieldAccessor(liteDeviceDelegatingViewResolver); + DirectFieldAccessor accessor = new DirectFieldAccessor( + liteDeviceDelegatingViewResolver); assertEquals(false, accessor.getPropertyValue("enableFallback")); assertEquals("", accessor.getPropertyValue("normalPrefix")); assertEquals("mobile/", accessor.getPropertyValue("mobilePrefix")); @@ -224,7 +224,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests { PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor( "spring.mobile.devicedelegatingviewresolver.enabled:true", "spring.mobile.devicedelegatingviewresolver.normalSuffix:.nor"); - assertEquals(".nor", accessor.getPropertyValue("normalSuffix")); + assertEquals(".nor", accessor.getPropertyValue("normalSuffix")); } @Test @@ -232,7 +232,7 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests { PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor( "spring.mobile.devicedelegatingviewresolver.enabled:true", "spring.mobile.devicedelegatingviewresolver.mobileSuffix:.mob"); - assertEquals(".mob", accessor.getPropertyValue("mobileSuffix")); + assertEquals(".mob", accessor.getPropertyValue("mobileSuffix")); } @Test @@ -243,7 +243,8 @@ public class DeviceDelegatingViewResolverAutoConfigurationTests { assertEquals(".tab", accessor.getPropertyValue("tabletSuffix")); } - private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(String... configuration) { + private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor( + String... configuration) { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, configuration); this.context.register(Config.class, WebMvcAutoConfiguration.class, diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfigurationTests.java index 0fb169e6f98..7285b8c721f 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/SitePreferenceAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/SitePreferenceAutoConfigurationTests.java index 4b1717eee68..04c52e11419 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/SitePreferenceAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/SitePreferenceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitCommand.java index 9c4631fb87e..334bb5e6b07 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitCommand.java @@ -130,19 +130,15 @@ public class InitCommand extends OptionParsingCommand { private void projectGenerationOptions() { this.groupId = option(Arrays.asList("groupId", "g"), - "Project coordinates (for example 'org.test')") - .withRequiredArg(); + "Project coordinates (for example 'org.test')").withRequiredArg(); this.artifactId = option(Arrays.asList("artifactId", "a"), "Project coordinates; infer archive name (for example 'test')") .withRequiredArg(); this.version = option(Arrays.asList("version", "v"), - "Project version (for example '0.0.1-SNAPSHOT')") - .withRequiredArg(); + "Project version (for example '0.0.1-SNAPSHOT')").withRequiredArg(); this.name = option(Arrays.asList("name", "n"), - "Project name; infer application name") - .withRequiredArg(); - this.description = option("description", - "Project description") + "Project name; infer application name").withRequiredArg(); + this.description = option("description", "Project description") .withRequiredArg(); this.packaging = option(Arrays.asList("packaging", "p"), "Project packaging (for example 'jar')").withRequiredArg(); @@ -162,8 +158,7 @@ public class InitCommand extends OptionParsingCommand { this.javaVersion = option(Arrays.asList("java-version", "j"), "Language level (for example '1.8')").withRequiredArg(); this.language = option(Arrays.asList("language", "l"), - "Programming language (for example 'java')") - .withRequiredArg(); + "Programming language (for example 'java')").withRequiredArg(); this.bootVersion = option(Arrays.asList("boot-version", "b"), "Spring Boot version (for example '1.2.0.RELEASE')") .withRequiredArg(); @@ -240,22 +235,22 @@ public class InitCommand extends OptionParsingCommand { if (options.has(this.type)) { request.setType(options.valueOf(this.type)); } - if(options.has(this.language)) { + if (options.has(this.language)) { request.setLanguage(options.valueOf(this.language)); } - if(options.has(this.groupId)) { + if (options.has(this.groupId)) { request.setGroupId(options.valueOf(this.groupId)); } if (options.has(this.artifactId)) { request.setArtifactId(options.valueOf(this.artifactId)); } - if(options.has(this.name)) { + if (options.has(this.name)) { request.setName(options.valueOf(this.name)); } - if(options.has(this.version)) { + if (options.has(this.version)) { request.setVersion(options.valueOf(this.version)); } - if(options.has(this.description)) { + if (options.has(this.description)) { request.setDescription(options.valueOf(this.description)); } request.setExtract(options.has(this.extract)); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java index 5219431511d..535c974acff 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import org.apache.http.client.utils.URIBuilder; - import org.springframework.util.StringUtils; /** @@ -392,7 +391,7 @@ class ProjectGenerationRequest { private static void filter(Map projects, String tag, String tagValue) { for (Iterator> it = projects.entrySet().iterator(); it - .hasNext(); ) { + .hasNext();) { Map.Entry entry = it.next(); String value = entry.getValue().getTags().get(tag); if (!tagValue.equals(value)) { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java index 9f8812bb13d..016d3721f02 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java @@ -81,7 +81,6 @@ public abstract class CompilerAutoConfiguration { /** * Apply any additional configuration. - * * @param loader the class loader being used during compilation * @param configuration the compiler configuration * @param generatorContext the current context @@ -93,4 +92,5 @@ public abstract class CompilerAutoConfiguration { GroovyCompilerConfiguration configuration, GeneratorContext generatorContext, SourceUnit source, ClassNode classNode) throws CompilationFailedException { } + } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java index 0b93e567db5..da0f7a2ec07 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java @@ -100,11 +100,9 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans private List> createDependencyMaps(Expression valueExpression) { Map dependency = null; - List constantExpressions = getConstantExpressions(valueExpression); List> dependencies = new ArrayList>( constantExpressions.size()); - for (ConstantExpression expression : constantExpressions) { Object value = expression.getValue(); if (value instanceof String) { @@ -122,7 +120,6 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans } } } - return dependencies; } @@ -130,12 +127,10 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans if (valueExpression instanceof ListExpression) { return getConstantExpressions((ListExpression) valueExpression); } - if (valueExpression instanceof ConstantExpression && ((ConstantExpression) valueExpression).getValue() instanceof String) { return Arrays.asList((ConstantExpression) valueExpression); } - reportError("@DependencyManagementBom requires an inline constant that is a " + "string or a string array", valueExpression); return Collections.emptyList(); @@ -166,16 +161,13 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans List> bomDependencies) { URI[] uris = Grape.getInstance().resolve(null, bomDependencies.toArray(new Map[bomDependencies.size()])); - DefaultModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance(); - for (URI uri : uris) { try { DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); request.setModelResolver(new GrapeModelResolver()); request.setModelSource(new UrlModelSource(uri.toURL())); Model model = modelBuilder.build(request).getEffectiveModel(); - this.resolutionContext .addDependencyManagement(new MavenModelDependencyManagement(model)); } @@ -236,4 +228,5 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans } } + } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java index adda0bd3d81..5d1b4cc2ce8 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java @@ -28,23 +28,21 @@ public interface DependencyManagement { /** * Returns the managed dependencies. - * * @return the managed dependencies */ List getDependencies(); /** * Returns the managed version of Spring Boot. May be {@code null}. - * * @return the Spring Boot version, or {@code null} */ String getSpringBootVersion(); /** * Finds the managed dependency with the given {@code artifactId}. - * * @param artifactId The artifact ID of the dependency to find * @return the dependency, or {@code null} */ Dependency find(String artifactId); + } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java index fce32d57ea7..0517e1a99be 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java @@ -19,7 +19,8 @@ package org.springframework.boot.cli.compiler.dependencies; import org.springframework.util.StringUtils; /** - * {@link ArtifactCoordinatesResolver} backed by {@link SpringBootDependenciesDependencyManagement}. + * {@link ArtifactCoordinatesResolver} backed by + * {@link SpringBootDependenciesDependencyManagement}. * * @author Phillip Webb * @author Andy Wilkinson @@ -70,4 +71,5 @@ public class DependencyManagementArtifactCoordinatesResolver implements Dependency dependency = find(module); return dependency == null ? null : dependency.getVersion(); } + } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/MavenModelDependencyManagement.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/MavenModelDependencyManagement.java index 26feb3595c2..88ad4ca0bc5 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/MavenModelDependencyManagement.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/MavenModelDependencyManagement.java @@ -75,4 +75,5 @@ public class MavenModelDependencyManagement implements DependencyManagement { public Dependency find(String artifactId) { return this.byArtifactId.get(artifactId); } + } diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java index 8b233da6a2b..dc1f4a374d6 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java @@ -25,6 +25,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import joptsimple.OptionSet; + import org.apache.http.Header; import org.apache.http.client.methods.HttpUriRequest; import org.junit.Before; @@ -34,7 +35,6 @@ import org.junit.rules.TemporaryFolder; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.MockitoAnnotations; - import org.springframework.boot.cli.command.status.ExitStatus; import static org.hamcrest.Matchers.startsWith; diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java index 19fc80c8e15..ef8230ca34d 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import org.json.JSONObject; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.StreamUtils; @@ -118,7 +117,7 @@ public class ProjectGenerationRequestTests { public void customLanguage() { this.request.setLanguage("groovy"); assertEquals(createDefaultUrl("?type=test-type&language=groovy"), - this.request.generateUrl(createDefaultMetadata())); + this.request.generateUrl(createDefaultMetadata())); } @Test @@ -127,8 +126,9 @@ public class ProjectGenerationRequestTests { this.request.setArtifactId("sample"); this.request.setVersion("1.0.1-SNAPSHOT"); this.request.setDescription("Spring Boot Test"); - assertEquals(createDefaultUrl("?groupId=org.acme&artifactId=sample&version=1.0.1-SNAPSHOT" + - "&description=Spring+Boot+Test&type=test-type"), + assertEquals( + createDefaultUrl("?groupId=org.acme&artifactId=sample&version=1.0.1-SNAPSHOT" + + "&description=Spring+Boot+Test&type=test-type"), this.request.generateUrl(createDefaultMetadata())); } diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/CompositeDependencyManagementTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/CompositeDependencyManagementTests.java index bb578b24cb8..c7256465344 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/CompositeDependencyManagementTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/dependencies/CompositeDependencyManagementTests.java @@ -47,7 +47,6 @@ public class CompositeDependencyManagementTests { public void unknownSpringBootVersion() { given(this.dependencyManagement1.getSpringBootVersion()).willReturn(null); given(this.dependencyManagement2.getSpringBootVersion()).willReturn(null); - assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2).getSpringBootVersion(), is(nullValue())); } @@ -56,7 +55,6 @@ public class CompositeDependencyManagementTests { public void knownSpringBootVersion() { given(this.dependencyManagement1.getSpringBootVersion()).willReturn("1.2.3"); given(this.dependencyManagement2.getSpringBootVersion()).willReturn("1.2.4"); - assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2).getSpringBootVersion(), is("1.2.3")); } @@ -65,7 +63,6 @@ public class CompositeDependencyManagementTests { public void unknownDependency() { given(this.dependencyManagement1.find("artifact")).willReturn(null); given(this.dependencyManagement2.find("artifact")).willReturn(null); - assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2).find("artifact"), is(nullValue())); } @@ -76,7 +73,6 @@ public class CompositeDependencyManagementTests { new Dependency("test", "artifact", "1.2.3")); given(this.dependencyManagement2.find("artifact")).willReturn( new Dependency("test", "artifact", "1.2.4")); - assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2).find("artifact"), is(new Dependency("test", "artifact", "1.2.3"))); @@ -88,11 +84,11 @@ public class CompositeDependencyManagementTests { Arrays.asList(new Dependency("test", "artifact", "1.2.3"))); given(this.dependencyManagement2.getDependencies()).willReturn( Arrays.asList(new Dependency("test", "artifact", "1.2.4"))); - assertThat( new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2).getDependencies(), contains(new Dependency("test", "artifact", "1.2.3"), new Dependency( "test", "artifact", "1.2.4"))); } + } diff --git a/spring-boot-samples/spring-boot-sample-web-secure-github/src/main/java/sample/ui/github/SampleGithubSecureApplication.java b/spring-boot-samples/spring-boot-sample-web-secure-github/src/main/java/sample/ui/github/SampleGithubSecureApplication.java index a4c60506051..46788715919 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure-github/src/main/java/sample/ui/github/SampleGithubSecureApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure-github/src/main/java/sample/ui/github/SampleGithubSecureApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-samples/spring-boot-sample-web-secure-github/src/test/java/sample/ui/github/SampleGithubApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-secure-github/src/test/java/sample/ui/github/SampleGithubApplicationTests.java index a5c28769b27..2f2e2fe18c7 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure-github/src/test/java/sample/ui/github/SampleGithubApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-secure-github/src/test/java/sample/ui/github/SampleGithubApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,6 @@ package sample.ui.github; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,6 +30,11 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.web.context.WebApplicationContext; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; + /** * Basic integration tests for github sso application. * @@ -47,20 +47,20 @@ import org.springframework.web.context.WebApplicationContext; public class SampleGithubApplicationTests { @Autowired - WebApplicationContext context; + private WebApplicationContext context; @Autowired - FilterChainProxy filterChain; + private FilterChainProxy filterChain; @Autowired - OAuth2ClientContextFilter filter; + private OAuth2ClientContextFilter filter; private MockMvc mvc; @Before public void setUp() { - this.mvc = webAppContextSetup(this.context).addFilters(this.filter, this.filterChain) - .build(); + this.mvc = webAppContextSetup(this.context).addFilters(this.filter, + this.filterChain).build(); SecurityContextHolder.clearContext(); } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java index 3a158aab48d..a9a9445e7b1 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java @@ -43,8 +43,10 @@ public interface ConfigurableEmbeddedServletContainer { void setContextPath(String contextPath); /** - * Sets the display name of the application deployed in the embedded servlet container. + * Sets the display name of the application deployed in the embedded servlet + * container. * @param displayName the displayName to set + * @since 1.3.0 */ void setDisplayName(String displayName); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java index c35b60835fa..2fb0abde8d8 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java @@ -388,7 +388,7 @@ public class UndertowEmbeddedServletContainerFactory extends } private void createAccessLogDirectoryIfNecessary() { - Assert.notNull(this.accessLogDirectory, "accesslogDirectory must not be null"); + Assert.state(this.accessLogDirectory != null, "Access log directory is not set"); if (!this.accessLogDirectory.isDirectory() && !this.accessLogDirectory.mkdirs()) { throw new IllegalStateException("Failed to create access log directory '" + this.accessLogDirectory + "'"); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/web/SpringBootServletInitializer.java b/spring-boot/src/main/java/org/springframework/boot/context/web/SpringBootServletInitializer.java index 9bc3ae6da46..fdc161fce3f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/web/SpringBootServletInitializer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/web/SpringBootServletInitializer.java @@ -112,7 +112,6 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit * Returns the {@code SpringApplicationBuilder} that is used to configure and create * the {@link SpringApplication}. The default implementation returns a new * {@code SpringApplicationBuilder} in its default state. - * * @return the {@code SpringApplicationBuilder}. * @since 1.3.0 */ diff --git a/spring-boot/src/main/java/org/springframework/boot/json/JsonParserFactory.java b/spring-boot/src/main/java/org/springframework/boot/json/JsonParserFactory.java index a0de0c529b0..6441468de17 100644 --- a/spring-boot/src/main/java/org/springframework/boot/json/JsonParserFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/json/JsonParserFactory.java @@ -34,7 +34,6 @@ public abstract class JsonParserFactory { * Static factory for the "best" JSON parser available on the classpath. Tries Jackson * 2, then JSON (from eclipse), Simple JSON, Gson, Snake YAML, and then falls back to * the {@link BasicJsonParser}. - * * @return a {@link JsonParser} */ public static JsonParser getJsonParser() { diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java index 409a84814a2..04a188bb883 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java @@ -164,11 +164,9 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem { private ConfigurationSource getConfigurationSource(URL url) throws IOException { InputStream stream = url.openStream(); if (ResourceUtils.isFileURL(url)) { - return new ConfigurationSource(stream, - ResourceUtils.getFile(url)); - } else { - return new ConfigurationSource(stream, url); + return new ConfigurationSource(stream, ResourceUtils.getFile(url)); } + return new ConfigurationSource(stream, url); } @Override diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/BindingPreparationTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/BindingPreparationTests.java index 0ddf1e78c2b..7e0f552c6bb 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/BindingPreparationTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/BindingPreparationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -329,5 +329,7 @@ public class BindingPreparationTests { public void setFoo(String foo) { this.foo = foo; } + } + } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java index 2751efeb5b5..a1519b58bba 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java @@ -33,7 +33,6 @@ import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.WebApplicationContext; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /** @@ -77,7 +76,7 @@ public class SpringBootServletInitializerTests { public void applicationBuilderCanBeCustomized() throws Exception { CustomSpringBootServletInitializer servletInitializer = new CustomSpringBootServletInitializer(); servletInitializer.createRootApplicationContext(this.servletContext); - assertThat(servletInitializer.applicationBuilder.built, is(true)); + assertThat(servletInitializer.applicationBuilder.built, equalTo(true)); } private Matcher> equalToSet(Object... items) { diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index e90de8b6560..1b51e70ad28 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.Configuration; @@ -30,12 +29,13 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; - import org.springframework.boot.logging.AbstractLoggingSystemTests; import org.springframework.boot.logging.LogLevel; import org.springframework.boot.test.OutputCapture; import org.springframework.util.StringUtils; +import com.fasterxml.jackson.databind.ObjectMapper; + import static org.hamcrest.Matchers.arrayContaining; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; @@ -183,7 +183,8 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { } public Configuration getConfiguration() { - return ((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).getConfiguration(); + return ((org.apache.logging.log4j.core.LoggerContext) LogManager + .getContext(false)).getConfiguration(); } @Override diff --git a/spring-boot/src/test/java/org/springframework/boot/test/AbstractConfigurationClassTests.java b/spring-boot/src/test/java/org/springframework/boot/test/AbstractConfigurationClassTests.java index 7ab38c8e71d..648b3ee82c6 100644 --- a/spring-boot/src/test/java/org/springframework/boot/test/AbstractConfigurationClassTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/test/AbstractConfigurationClassTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,8 @@ import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; import static org.junit.Assert.assertEquals; /** + * Abstract base class for {@code @Configuration} sanity checks. + * * @author Andy Wilkinson */ public abstract class AbstractConfigurationClassTests { @@ -56,7 +58,6 @@ public abstract class AbstractConfigurationClassTests { } } } - assertEquals("Found non-public @Bean methods: " + nonPublicBeanMethods, 0, nonPublicBeanMethods.size()); } @@ -65,7 +66,6 @@ public abstract class AbstractConfigurationClassTests { Set configurationClasses = new HashSet(); Resource[] resources = this.resolver.getResources("classpath*:" + getClass().getPackage().getName().replace(".", "/") + "/**/*.class"); - for (Resource resource : resources) { if (!isTestClass(resource)) { MetadataReader metadataReader = new SimpleMetadataReaderFactory() @@ -89,7 +89,6 @@ public abstract class AbstractConfigurationClassTests { private boolean isPublic(MethodMetadata methodMetadata) { int access = (Integer) new DirectFieldAccessor(methodMetadata) .getPropertyValue("access"); - return (access & Opcodes.ACC_PUBLIC) != 0; }