Merge branch '1.4.x' into 1.5.x

This commit is contained in:
Phillip Webb
2016-10-03 22:38:22 -07:00
31 changed files with 216 additions and 94 deletions

View File

@@ -178,8 +178,7 @@ class JCacheCacheConfiguration {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage
.forCondition("JCache");
ConditionMessage.Builder message = ConditionMessage.forCondition("JCache");
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "spring.cache.jcache.");
if (resolver.containsProperty("provider")) {

View File

@@ -375,8 +375,8 @@ public final class ConditionMessage {
/**
* Indicate the items with a {@link Style}. For example
* {@code didNotFind("bean", "beans").items(Style.QUOTE, Collections.singleton("x")} results in
* the message "did not find bean 'x'".
* {@code didNotFind("bean", "beans").items(Style.QUOTE, Collections.singleton("x")}
* results in the message "did not find bean 'x'".
* @param style the render style
* @param items the source of the items (may be {@code null})
* @return a built {@link ConditionMessage}

View File

@@ -24,8 +24,8 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapt
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
/**
* A {@code RepositoryRestConfigurer} that applies configuration items from
* the {@code spring.data.rest} namespace to Spring Data REST. Also, if a
* A {@code RepositoryRestConfigurer} that applies configuration items from the
* {@code spring.data.rest} namespace to Spring Data REST. Also, if a
* {@link Jackson2ObjectMapperBuilder} is available, it is used to configure Spring Data
* REST's {@link ObjectMapper ObjectMappers}.
*

View File

@@ -16,8 +16,7 @@
package org.springframework.boot.autoconfigure.elasticsearch.jest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -34,8 +33,7 @@ public class JestProperties {
/**
* Comma-separated list of the Elasticsearch instances to use.
*/
private List<String> uris = new ArrayList<String>(Collections.singletonList(
"http://localhost:9200"));
private List<String> uris = Arrays.asList("http://localhost:9200");
/**
* Login user.

View File

@@ -108,7 +108,8 @@ public class ProjectInfoAutoConfiguration {
ConditionMessage.Builder message = ConditionMessage
.forCondition("GitResource");
if (loader.getResource(location).exists()) {
return ConditionOutcome.match(message.found("git info at").items(location));
return ConditionOutcome
.match(message.found("git info at").items(location));
}
return ConditionOutcome
.noMatch(message.didNotFind("git info at").items(location));

View File

@@ -232,8 +232,8 @@ public class DataSourceAutoConfiguration {
}
if (anyMatches(context, metadata, this.pooledCondition,
this.embeddedCondition)) {
return ConditionOutcome
.match(message.foundExactly("existing auto-configured data source bean"));
return ConditionOutcome.match(message
.foundExactly("existing auto-configured data source bean"));
}
return ConditionOutcome
.noMatch(message.didNotFind("any existing data source bean").atAll());

View File

@@ -132,8 +132,8 @@ public class OAuth2ResourceServerConfiguration {
if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
if (AuthorizationServerEndpointsConfigurationBeanCondition
.matches(context)) {
return ConditionOutcome
.match(message.found("class").items(AUTHORIZATION_ANNOTATION));
return ConditionOutcome.match(
message.found("class").items(AUTHORIZATION_ANNOTATION));
}
}
return ConditionOutcome.noMatch(

View File

@@ -58,8 +58,8 @@ class SessionCondition extends SpringBootCondition {
return ConditionOutcome.match(message
.found("spring.session.store-type property").items(sessionStoreType));
}
return ConditionOutcome
.noMatch(message.found("spring.session.store-type property").items(value));
return ConditionOutcome.noMatch(
message.found("spring.session.store-type property").items(value));
}
}

View File

@@ -50,8 +50,7 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
ConditionMessage.Builder message = ConditionMessage
.forCondition(ConditionalOnEnabledResourceChain.class);
if (match == null) {
if (ClassUtils.isPresent(WEBJAR_ASSET_LOCATOR,
getClass().getClassLoader())) {
if (ClassUtils.isPresent(WEBJAR_ASSET_LOCATOR, getClass().getClassLoader())) {
return ConditionOutcome
.match(message.found("class").items(WEBJAR_ASSET_LOCATOR));
}

View File

@@ -92,8 +92,9 @@ public class BatchAutoConfigurationTests {
this.context.refresh();
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
assertThat(this.context.getBean(JobExplorer.class)).isNotNull();
assertThat(this.context.getBean(BatchProperties.class)
.getInitializer().isEnabled()).isTrue();
assertThat(
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
.isTrue();
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from BATCH_JOB_EXECUTION")).isEmpty();
}
@@ -193,8 +194,9 @@ public class BatchAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
assertThat(this.context.getBean(BatchProperties.class)
.getInitializer().isEnabled()).isFalse();
assertThat(
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
.isFalse();
this.expected.expect(BadSqlGrammarException.class);
new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from BATCH_JOB_EXECUTION");
@@ -233,8 +235,9 @@ public class BatchAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
assertThat(this.context.getBean(BatchProperties.class)
.getInitializer().isEnabled()).isTrue();
assertThat(
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
.isTrue();
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
@@ -245,19 +248,20 @@ public class BatchAutoConfigurationTests {
}
@Test
public void testCustomTablePrefixWithDefaultSchemaDisablesInitializer() throws Exception {
public void testCustomTablePrefixWithDefaultSchemaDisablesInitializer()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.datasource.name:batchtest",
"spring.batch.tablePrefix:PREFIX_");
"spring.datasource.name:batchtest", "spring.batch.tablePrefix:PREFIX_");
this.context.register(TestConfiguration.class,
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
assertThat(this.context.getBean(BatchProperties.class)
.getInitializer().isEnabled()).isFalse();
assertThat(
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
.isFalse();
this.expected.expect(BadSqlGrammarException.class);
new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from BATCH_JOB_EXECUTION");

View File

@@ -107,8 +107,8 @@ public class IntegrationAutoConfigurationTests {
public void primaryExporterIsAllowed() {
load(CustomMBeanExporter.class);
assertThat(this.context.getBeansOfType(MBeanExporter.class)).hasSize(2);
assertThat(this.context.getBean(MBeanExporter.class)).isSameAs(
this.context.getBean("myMBeanExporter"));
assertThat(this.context.getBean(MBeanExporter.class))
.isSameAs(this.context.getBean("myMBeanExporter"));
}
private static void assertDomains(MBeanServer mBeanServer, boolean expected,

View File

@@ -54,8 +54,8 @@ public class SessionAutoConfigurationJdbcTests
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("SPRING_SESSION");
assertThat(this.context.getBean(SessionProperties.class)
.getJdbc().getInitializer().isEnabled()).isTrue();
assertThat(this.context.getBean(SessionProperties.class).getJdbc()
.getInitializer().isEnabled()).isTrue();
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from SPRING_SESSION")).isEmpty();
}
@@ -70,8 +70,8 @@ public class SessionAutoConfigurationJdbcTests
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("SPRING_SESSION");
assertThat(this.context.getBean(SessionProperties.class)
.getJdbc().getInitializer().isEnabled()).isFalse();
assertThat(this.context.getBean(SessionProperties.class).getJdbc()
.getInitializer().isEnabled()).isFalse();
this.thrown.expect(BadSqlGrammarException.class);
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from SPRING_SESSION")).isEmpty();
@@ -88,8 +88,8 @@ public class SessionAutoConfigurationJdbcTests
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("FOO_BAR");
assertThat(this.context.getBean(SessionProperties.class)
.getJdbc().getInitializer().isEnabled()).isTrue();
assertThat(this.context.getBean(SessionProperties.class).getJdbc()
.getInitializer().isEnabled()).isTrue();
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from FOO_BAR")).isEmpty();
}
@@ -104,8 +104,8 @@ public class SessionAutoConfigurationJdbcTests
JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName"))
.isEqualTo("FOO_BAR");
assertThat(this.context.getBean(SessionProperties.class)
.getJdbc().getInitializer().isEnabled()).isFalse();
assertThat(this.context.getBean(SessionProperties.class).getJdbc()
.getInitializer().isEnabled()).isFalse();
this.thrown.expect(BadSqlGrammarException.class);
assertThat(this.context.getBean(JdbcOperations.class)
.queryForList("select * from SPRING_SESSION")).isEmpty();

View File

@@ -50,7 +50,8 @@ public class SessionAutoConfigurationRedisTests
public void redisSessionStoreIsTheDefault() {
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class));
validateSpringSessionUsesRedis();
this.output.expect(containsString("Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"));
this.output.expect(containsString(
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"));
}
@Test
@@ -58,7 +59,8 @@ public class SessionAutoConfigurationRedisTests
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
"spring.session.store-type=redis");
validateSpringSessionUsesRedis();
this.output.expect(not(containsString("Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration")));
this.output.expect(not(containsString(
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration")));
}
private void validateSpringSessionUsesRedis() {