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