Commit b4c3f4f5 authored by Phillip Webb's avatar Phillip Webb

Merge branch '1.5.x'

parents 48703494 ec731442
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
<main.basedir>${basedir}/..</main.basedir> <main.basedir>${basedir}/..</main.basedir>
</properties> </properties>
<dependencies> <dependencies>
<!-- Compile -->
<dependency> <dependency>
<groupId>org.springframework.hateoas</groupId> <groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId> <artifactId>spring-hateoas</artifactId>
</dependency> </dependency>
<!-- Provided --> <!-- Provided -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -627,7 +627,6 @@ ...@@ -627,7 +627,6 @@
<dependency> <dependency>
<groupId>org.springframework.kafka</groupId> <groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId> <artifactId>spring-kafka-test</artifactId>
<version>${spring-kafka.version}</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
......
...@@ -49,8 +49,7 @@ import org.springframework.context.annotation.Primary; ...@@ -49,8 +49,7 @@ import org.springframework.context.annotation.Primary;
public class CouchbaseAutoConfiguration { public class CouchbaseAutoConfiguration {
@Configuration @Configuration
@ConditionalOnMissingBean(value = CouchbaseConfiguration.class, @ConditionalOnMissingBean(value = CouchbaseConfiguration.class, type = "org.springframework.data.couchbase.config.CouchbaseConfigurer")
type = "org.springframework.data.couchbase.config.CouchbaseConfigurer")
public static class CouchbaseConfiguration { public static class CouchbaseConfiguration {
private final CouchbaseProperties properties; private final CouchbaseProperties properties;
...@@ -124,8 +123,9 @@ public class CouchbaseAutoConfiguration { ...@@ -124,8 +123,9 @@ public class CouchbaseAutoConfiguration {
* Determine if Couchbase should be configured. This happens if either the * Determine if Couchbase should be configured. This happens if either the
* user-configuration defines a {@code CouchbaseConfigurer} or if at least the * user-configuration defines a {@code CouchbaseConfigurer} or if at least the
* "bootstrapHosts" property is specified. * "bootstrapHosts" property is specified.
* <p>The reason why we check for the presence of {@code CouchbaseConfigurer} is * <p>
* that it might use {@link CouchbaseProperties} for its internal customization. * The reason why we check for the presence of {@code CouchbaseConfigurer} is that it
* might use {@link CouchbaseProperties} for its internal customization.
*/ */
static class CouchbaseCondition extends AnyNestedCondition { static class CouchbaseCondition extends AnyNestedCondition {
......
...@@ -42,6 +42,9 @@ abstract class DataSourceConfiguration { ...@@ -42,6 +42,9 @@ abstract class DataSourceConfiguration {
return (T) properties.initializeDataSourceBuilder().type(type).build(); return (T) properties.initializeDataSourceBuilder().type(type).build();
} }
/**
* Tomcat Pool DataSource configuration.
*/
@ConditionalOnClass(org.apache.tomcat.jdbc.pool.DataSource.class) @ConditionalOnClass(org.apache.tomcat.jdbc.pool.DataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.tomcat.jdbc.pool.DataSource", matchIfMissing = true) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.tomcat.jdbc.pool.DataSource", matchIfMissing = true)
static class Tomcat extends DataSourceConfiguration { static class Tomcat extends DataSourceConfiguration {
...@@ -64,6 +67,9 @@ abstract class DataSourceConfiguration { ...@@ -64,6 +67,9 @@ abstract class DataSourceConfiguration {
} }
/**
* Hikari DataSource configuration.
*/
@ConditionalOnClass(HikariDataSource.class) @ConditionalOnClass(HikariDataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.zaxxer.hikari.HikariDataSource", matchIfMissing = true) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.zaxxer.hikari.HikariDataSource", matchIfMissing = true)
static class Hikari extends DataSourceConfiguration { static class Hikari extends DataSourceConfiguration {
...@@ -75,6 +81,9 @@ abstract class DataSourceConfiguration { ...@@ -75,6 +81,9 @@ abstract class DataSourceConfiguration {
} }
} }
/**
* DBCP DataSource configuration.
*/
@ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class) @ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp2.BasicDataSource", matchIfMissing = true) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp2.BasicDataSource", matchIfMissing = true)
static class Dbcp2 extends DataSourceConfiguration { static class Dbcp2 extends DataSourceConfiguration {
...@@ -88,6 +97,9 @@ abstract class DataSourceConfiguration { ...@@ -88,6 +97,9 @@ abstract class DataSourceConfiguration {
} }
} }
/**
* Generic DataSource configuration.
*/
@ConditionalOnMissingBean(DataSource.class) @ConditionalOnMissingBean(DataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type") @ConditionalOnProperty(name = "spring.datasource.type")
static class Generic { static class Generic {
......
...@@ -58,8 +58,8 @@ public class ValidationAutoConfiguration { ...@@ -58,8 +58,8 @@ public class ValidationAutoConfiguration {
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) { AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition( ConditionMessage.Builder message = ConditionMessage
getClass().getName()); .forCondition(getClass().getName());
try { try {
Validation.buildDefaultValidatorFactory().getValidator(); Validation.buildDefaultValidatorFactory().getValidator();
return ConditionOutcome.match(message.available("JSR-303 provider")); return ConditionOutcome.match(message.available("JSR-303 provider"));
......
...@@ -66,7 +66,8 @@ public class CassandraAutoConfigurationTests { ...@@ -66,7 +66,8 @@ public class CassandraAutoConfigurationTests {
public void createCustomizeCluster() { public void createCustomizeCluster() {
load(ClusterConfig.class); load(ClusterConfig.class);
assertThat(this.context.getBeanNamesForType(Cluster.class).length).isEqualTo(1); assertThat(this.context.getBeanNamesForType(Cluster.class).length).isEqualTo(1);
assertThat(this.context.getBeanNamesForType(ClusterCustomizer.class).length).isEqualTo(1); assertThat(this.context.getBeanNamesForType(ClusterCustomizer.class).length)
.isEqualTo(1);
} }
private void load(String... environment) { private void load(String... environment) {
...@@ -85,7 +86,6 @@ public class CassandraAutoConfigurationTests { ...@@ -85,7 +86,6 @@ public class CassandraAutoConfigurationTests {
this.context = ctx; this.context = ctx;
} }
@Configuration @Configuration
static class ClusterConfig { static class ClusterConfig {
......
...@@ -53,7 +53,6 @@ public class ConditionalOnMissingBeanWithFilteredClasspathTests { ...@@ -53,7 +53,6 @@ public class ConditionalOnMissingBeanWithFilteredClasspathTests {
assertThat(this.context.containsBean("foo")).isTrue(); assertThat(this.context.containsBean("foo")).isTrue();
} }
@Configuration @Configuration
static class OnBeanTypeConfiguration { static class OnBeanTypeConfiguration {
...@@ -66,6 +65,7 @@ public class ConditionalOnMissingBeanWithFilteredClasspathTests { ...@@ -66,6 +65,7 @@ public class ConditionalOnMissingBeanWithFilteredClasspathTests {
} }
static class TestCacheManager extends CaffeineCacheManager { static class TestCacheManager extends CaffeineCacheManager {
} }
} }
...@@ -70,8 +70,9 @@ public class SessionAutoConfigurationHazelcastTests ...@@ -70,8 +70,9 @@ public class SessionAutoConfigurationHazelcastTests
"spring.session.hazelcast.flush-mode=immediate"); "spring.session.hazelcast.flush-mode=immediate");
HazelcastSessionRepository repository = validateSessionRepository( HazelcastSessionRepository repository = validateSessionRepository(
HazelcastSessionRepository.class); HazelcastSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue( assertThat(new DirectFieldAccessor(repository)
"hazelcastFlushMode")).isEqualTo(HazelcastFlushMode.IMMEDIATE); .getPropertyValue("hazelcastFlushMode"))
.isEqualTo(HazelcastFlushMode.IMMEDIATE);
} }
@Configuration @Configuration
......
...@@ -97,7 +97,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat ...@@ -97,7 +97,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
} }
@Test @Test
@SuppressWarnings("unchecked")
public void mongoSessionStore() { public void mongoSessionStore() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class, load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class), MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
...@@ -106,7 +105,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat ...@@ -106,7 +105,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
} }
@Test @Test
@SuppressWarnings("unchecked")
public void mongoSessionStoreWithCustomizations() { public void mongoSessionStoreWithCustomizations() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class, load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class), MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
......
...@@ -65,7 +65,8 @@ public class ValidationAutoConfigurationTests { ...@@ -65,7 +65,8 @@ public class ValidationAutoConfigurationTests {
load(SampleConfiguration.class); load(SampleConfiguration.class);
assertThat(this.context.getBean(MethodValidationPostProcessor.class)) assertThat(this.context.getBean(MethodValidationPostProcessor.class))
.isSameAs(this.context.getBean("testMethodValidationPostProcessor")); .isSameAs(this.context.getBean("testMethodValidationPostProcessor"));
assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class)).hasSize(1); assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class))
.hasSize(1);
} }
public void load(Class<?> config) { public void load(Class<?> config) {
...@@ -84,6 +85,7 @@ public class ValidationAutoConfigurationTests { ...@@ -84,6 +85,7 @@ public class ValidationAutoConfigurationTests {
public void doSomething(@Size(min = 3, max = 10) String name) { public void doSomething(@Size(min = 3, max = 10) String name) {
} }
} }
@Configuration @Configuration
......
...@@ -28,8 +28,8 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess ...@@ -28,8 +28,8 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Test for {{@link ValidationAutoConfiguration} when Hibernate validator is present * Test for {@link ValidationAutoConfiguration} when Hibernate validator is present but no
* but no EL implementation is available. * EL implementation is available.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
......
...@@ -425,10 +425,8 @@ public class ServerPropertiesTests { ...@@ -425,10 +425,8 @@ public class ServerPropertiesTests {
map.put("server.tomcat.port-header", "x-my-forward-port"); map.put("server.tomcat.port-header", "x-my-forward-port");
map.put("server.tomcat.protocol-header-https-value", "On"); map.put("server.tomcat.protocol-header-https-value", "On");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
assertThat(container.getEngineValves()).hasSize(1); assertThat(container.getEngineValves()).hasSize(1);
Valve valve = container.getEngineValves().iterator().next(); Valve valve = container.getEngineValves().iterator().next();
assertThat(valve).isInstanceOf(RemoteIpValve.class); assertThat(valve).isInstanceOf(RemoteIpValve.class);
...@@ -445,7 +443,6 @@ public class ServerPropertiesTests { ...@@ -445,7 +443,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.accept-count", "10"); map.put("server.tomcat.accept-count", "10");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
...@@ -459,7 +456,6 @@ public class ServerPropertiesTests { ...@@ -459,7 +456,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.max-connections", "5"); map.put("server.tomcat.max-connections", "5");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
...@@ -473,7 +469,6 @@ public class ServerPropertiesTests { ...@@ -473,7 +469,6 @@ public class ServerPropertiesTests {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.max-http-post-size", "10000"); map.put("server.tomcat.max-http-post-size", "10000");
bindProperties(map); bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container); this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
......
...@@ -60,7 +60,6 @@ public class TestDatabaseAutoConfigurationTests { ...@@ -60,7 +60,6 @@ public class TestDatabaseAutoConfigurationTests {
DataSource datasource = this.context.getBean(DataSource.class); DataSource datasource = this.context.getBean(DataSource.class);
JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource); JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
jdbcTemplate.execute("create table example (id int, name varchar);"); jdbcTemplate.execute("create table example (id int, name varchar);");
ConfigurableApplicationContext anotherContext = doLoad( ConfigurableApplicationContext anotherContext = doLoad(
ExistingDataSourceConfiguration.class); ExistingDataSourceConfiguration.class);
try { try {
......
...@@ -198,24 +198,23 @@ public class Handler extends URLStreamHandler { ...@@ -198,24 +198,23 @@ public class Handler extends URLStreamHandler {
@Override @Override
protected int hashCode(URL u) { protected int hashCode(URL u) {
int result = 0; return hashCode(u.getProtocol(), u.getFile());
String protocol = u.getProtocol();
if (protocol != null) {
result += protocol.hashCode();
} }
String file = u.getFile();
private int hashCode(String protocol, String file) {
int result = (protocol == null ? 0 : protocol.hashCode());
int separatorIndex = file.indexOf(SEPARATOR); int separatorIndex = file.indexOf(SEPARATOR);
if (separatorIndex == -1) { if (separatorIndex == -1) {
return result + file.hashCode(); return result + file.hashCode();
} }
String fileWithoutEntry = file.substring(0, separatorIndex); String source = file.substring(0, separatorIndex);
String entry = canonicalize(file.substring(separatorIndex + 2));
try { try {
result += new URL(fileWithoutEntry).hashCode(); result += new URL(source).hashCode();
} }
catch (MalformedURLException ex) { catch (MalformedURLException ex) {
result += fileWithoutEntry.hashCode(); result += source.hashCode();
} }
String entry = canonicalize(file.substring(separatorIndex + 2));
result += entry.hashCode(); result += entry.hashCode();
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment