Commit 991314c6 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.5.x'

parents 57300716 59122358
...@@ -42,7 +42,6 @@ import org.springframework.data.cassandra.core.CassandraAdminOperations; ...@@ -42,7 +42,6 @@ import org.springframework.data.cassandra.core.CassandraAdminOperations;
import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.data.cassandra.core.CassandraTemplate;
import org.springframework.data.cassandra.core.convert.CassandraConverter; import org.springframework.data.cassandra.core.convert.CassandraConverter;
import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.core.mapping.BasicCassandraMappingContext;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext; import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver; import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -81,7 +80,7 @@ public class CassandraDataAutoConfiguration { ...@@ -81,7 +80,7 @@ public class CassandraDataAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public CassandraMappingContext cassandraMapping() throws ClassNotFoundException { public CassandraMappingContext cassandraMapping() throws ClassNotFoundException {
BasicCassandraMappingContext context = new BasicCassandraMappingContext(); CassandraMappingContext context = new CassandraMappingContext();
List<String> packages = EntityScanPackages.get(this.beanFactory) List<String> packages = EntityScanPackages.get(this.beanFactory)
.getPackageNames(); .getPackageNames();
if (packages.isEmpty() && AutoConfigurationPackages.has(this.beanFactory)) { if (packages.isEmpty() && AutoConfigurationPackages.has(this.beanFactory)) {
......
...@@ -36,7 +36,7 @@ import org.springframework.context.annotation.ComponentScan; ...@@ -36,7 +36,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
import org.springframework.data.cassandra.core.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories; import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories;
import org.springframework.data.cql.core.session.ReactiveSession; import org.springframework.data.cql.core.session.ReactiveSession;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
...@@ -87,8 +87,8 @@ public class CassandraReactiveRepositoriesAutoConfigurationTests { ...@@ -87,8 +87,8 @@ public class CassandraReactiveRepositoriesAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Set<Class<?>> getInitialEntitySet() { private Set<Class<?>> getInitialEntitySet() {
BasicCassandraMappingContext mappingContext = this.context CassandraMappingContext mappingContext = this.context
.getBean(BasicCassandraMappingContext.class); .getBean(CassandraMappingContext.class);
return (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext, return (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext,
"initialEntitySet"); "initialEntitySet");
} }
......
...@@ -36,7 +36,7 @@ import org.springframework.context.annotation.Bean; ...@@ -36,7 +36,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
import org.springframework.data.cassandra.core.mapping.BasicCassandraMappingContext; import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
...@@ -88,8 +88,8 @@ public class CassandraRepositoriesAutoConfigurationTests { ...@@ -88,8 +88,8 @@ public class CassandraRepositoriesAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Set<Class<?>> getInitialEntitySet() { private Set<Class<?>> getInitialEntitySet() {
BasicCassandraMappingContext mappingContext = this.context CassandraMappingContext mappingContext = this.context
.getBean(BasicCassandraMappingContext.class); .getBean(CassandraMappingContext.class);
return (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext, return (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext,
"initialEntitySet"); "initialEntitySet");
} }
......
...@@ -210,19 +210,16 @@ public class DataSourceAutoConfigurationTests { ...@@ -210,19 +210,16 @@ public class DataSourceAutoConfigurationTests {
@Test @Test
public void testExplicitDriverClassClearsUsername() throws Exception { public void testExplicitDriverClassClearsUsername() throws Exception {
TestPropertyValues.of( TestPropertyValues.of(
"spring.datasource.driverClassName:" "spring.datasource.driverClassName:" + DatabaseTestDriver.class.getName(),
+ "org.springframework.boot.autoconfigure.jdbc."
+ "DataSourceAutoConfigurationTests$DatabaseTestDriver",
"spring.datasource.url:jdbc:foo://localhost").applyTo(this.context); "spring.datasource.url:jdbc:foo://localhost").applyTo(this.context);
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
DataSource bean = this.context.getBean(DataSource.class); DataSource dataSource = this.context.getBean(DataSource.class);
assertThat(bean).isNotNull(); assertThat(dataSource).isNotNull();
HikariDataSource pool = (HikariDataSource) bean; assertThat(((HikariDataSource) dataSource).getDriverClassName())
assertThat(pool.getDriverClassName()).isEqualTo( .isEqualTo(DatabaseTestDriver.class.getName());
"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseTestDriver"); assertThat(((HikariDataSource) dataSource).getUsername()).isNull();
assertThat(pool.getUsername()).isNull();
} }
@Test @Test
......
...@@ -168,6 +168,7 @@ public class KafkaAutoConfigurationTests { ...@@ -168,6 +168,7 @@ public class KafkaAutoConfigurationTests {
.isEmpty(); .isEmpty();
} }
@SuppressWarnings("unchecked")
@Test @Test
public void listenerProperties() { public void listenerProperties() {
load("spring.kafka.template.default-topic=testTopic", load("spring.kafka.template.default-topic=testTopic",
...@@ -176,8 +177,8 @@ public class KafkaAutoConfigurationTests { ...@@ -176,8 +177,8 @@ public class KafkaAutoConfigurationTests {
"spring.kafka.listener.ack-time=456", "spring.kafka.listener.ack-time=456",
"spring.kafka.listener.concurrency=3", "spring.kafka.listener.concurrency=3",
"spring.kafka.listener.poll-timeout=2000", "spring.kafka.listener.poll-timeout=2000",
"spring.kafka.listener.type=batch", "spring.kafka.listener.type=batch", "spring.kafka.jaas.enabled=true",
"spring.kafka.jaas.enabled=true", "spring.kafka.jaas.login-module=foo", "spring.kafka.jaas.login-module=foo",
"spring.kafka.jaas.control-flag=REQUISITE", "spring.kafka.jaas.control-flag=REQUISITE",
"spring.kafka.jaas.options.useKeyTab=true"); "spring.kafka.jaas.options.useKeyTab=true");
DefaultKafkaProducerFactory<?, ?> producerFactory = this.context DefaultKafkaProducerFactory<?, ?> producerFactory = this.context
...@@ -199,8 +200,7 @@ public class KafkaAutoConfigurationTests { ...@@ -199,8 +200,7 @@ public class KafkaAutoConfigurationTests {
assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3); assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3);
assertThat(dfa.getPropertyValue("containerProperties.pollTimeout")) assertThat(dfa.getPropertyValue("containerProperties.pollTimeout"))
.isEqualTo(2000L); .isEqualTo(2000L);
assertThat(dfa.getPropertyValue("batchListener")) assertThat(dfa.getPropertyValue("batchListener")).isEqualTo(true);
.isEqualTo(true);
assertThat(this.context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)) assertThat(this.context.getBeansOfType(KafkaJaasLoginModuleInitializer.class))
.hasSize(1); .hasSize(1);
KafkaJaasLoginModuleInitializer jaas = this.context KafkaJaasLoginModuleInitializer jaas = this.context
......
...@@ -354,11 +354,8 @@ public class QuartzAutoConfigurationTests { ...@@ -354,11 +354,8 @@ public class QuartzAutoConfigurationTests {
public static class ComponentThatUsesScheduler { public static class ComponentThatUsesScheduler {
private Scheduler scheduler;
public ComponentThatUsesScheduler(Scheduler scheduler) { public ComponentThatUsesScheduler(Scheduler scheduler) {
Assert.notNull(scheduler, "Scheduler must not be null"); Assert.notNull(scheduler, "Scheduler must not be null");
this.scheduler = scheduler;
} }
} }
......
...@@ -216,8 +216,8 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe ...@@ -216,8 +216,8 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
ApplicationContext applicationContext) { ApplicationContext applicationContext) {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
if (applicationContext instanceof DefaultResourceLoader) { if (applicationContext instanceof DefaultResourceLoader) {
Collection<ProtocolResolver> protocolResolvers = Collection<ProtocolResolver> protocolResolvers = ((DefaultResourceLoader) applicationContext)
((DefaultResourceLoader) applicationContext).getProtocolResolvers(); .getProtocolResolvers();
for (ProtocolResolver protocolResolver : protocolResolvers) { for (ProtocolResolver protocolResolver : protocolResolvers) {
resourceLoader.addProtocolResolver(protocolResolver); resourceLoader.addProtocolResolver(protocolResolver);
} }
...@@ -247,11 +247,11 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe ...@@ -247,11 +247,11 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
private ResourceLoader createResourceLoader( private ResourceLoader createResourceLoader(
WebApplicationContext applicationContext) { WebApplicationContext applicationContext) {
WebApplicationContextResourceLoader resourceLoader = WebApplicationContextResourceLoader resourceLoader = new WebApplicationContextResourceLoader(
new WebApplicationContextResourceLoader(applicationContext); applicationContext);
if (applicationContext instanceof DefaultResourceLoader) { if (applicationContext instanceof DefaultResourceLoader) {
Collection<ProtocolResolver> protocolResolvers = Collection<ProtocolResolver> protocolResolvers = ((DefaultResourceLoader) applicationContext)
((DefaultResourceLoader) applicationContext).getProtocolResolvers(); .getProtocolResolvers();
for (ProtocolResolver protocolResolver : protocolResolvers) { for (ProtocolResolver protocolResolver : protocolResolvers) {
resourceLoader.addProtocolResolver(protocolResolver); resourceLoader.addProtocolResolver(protocolResolver);
} }
......
...@@ -110,8 +110,9 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests { ...@@ -110,8 +110,9 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
context.register(classes); context.register(classes);
context.register(DevToolsDataSourceAutoConfiguration.class); context.register(DevToolsDataSourceAutoConfiguration.class);
if (driverClassName != null) { if (driverClassName != null) {
TestPropertyValues.of( TestPropertyValues
"spring.datasource.driver-class-name:" + driverClassName).applyTo(context); .of("spring.datasource.driver-class-name:" + driverClassName)
.applyTo(context);
} }
if (url != null) { if (url != null) {
TestPropertyValues.of("spring.datasource.url:" + url).applyTo(context); TestPropertyValues.of("spring.datasource.url:" + url).applyTo(context);
......
...@@ -39,9 +39,9 @@ import org.springframework.web.context.support.GenericWebApplicationContext; ...@@ -39,9 +39,9 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.context.support.ServletContextResource; import org.springframework.web.context.support.ServletContextResource;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -168,8 +168,7 @@ public class ClassLoaderFilesResourcePatternResolverTests { ...@@ -168,8 +168,7 @@ public class ClassLoaderFilesResourcePatternResolverTests {
private ProtocolResolver mockProtocolResolver(String path, Resource resource) { private ProtocolResolver mockProtocolResolver(String path, Resource resource) {
ProtocolResolver resolver = mock(ProtocolResolver.class); ProtocolResolver resolver = mock(ProtocolResolver.class);
given(resolver.resolve(eq(path), any(ResourceLoader.class))) given(resolver.resolve(eq(path), any(ResourceLoader.class))).willReturn(resource);
.willReturn(resource);
return resolver; return resolver;
} }
......
...@@ -47,16 +47,16 @@ public class SampleHypermediaUiSecureApplicationTests { ...@@ -47,16 +47,16 @@ public class SampleHypermediaUiSecureApplicationTests {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/env", ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/env",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
ResponseEntity<String> user = this.restTemplate.getForEntity("/application/env/foo", ResponseEntity<String> user = this.restTemplate
String.class); .getForEntity("/application/env/foo", String.class);
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(user.getBody()).contains("{\"foo\":"); assertThat(user.getBody()).contains("{\"foo\":");
} }
@Test @Test
public void testSecurePath() throws Exception { public void testSecurePath() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/metrics", ResponseEntity<String> entity = this.restTemplate
String.class); .getForEntity("/application/metrics", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
} }
} }
...@@ -20,7 +20,6 @@ import java.util.List; ...@@ -20,7 +20,6 @@ import java.util.List;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator; import javax.persistence.SequenceGenerator;
...@@ -29,7 +28,7 @@ import javax.persistence.SequenceGenerator; ...@@ -29,7 +28,7 @@ import javax.persistence.SequenceGenerator;
public class Tag { public class Tag {
@Id @Id
@SequenceGenerator(name="tag_generator", sequenceName="tag_sequence", initialValue = 4) @SequenceGenerator(name = "tag_generator", sequenceName = "tag_sequence", initialValue = 4)
@GeneratedValue(generator = "tag_generator") @GeneratedValue(generator = "tag_generator")
private long id; private long id;
......
...@@ -22,7 +22,7 @@ import org.quartz.JobExecutionException; ...@@ -22,7 +22,7 @@ import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean; import org.springframework.scheduling.quartz.QuartzJobBean;
public class SampleJob extends QuartzJobBean { public class SampleJob extends QuartzJobBean {
private String name; private String name;
// Invoked if a Job data map entry with that name // Invoked if a Job data map entry with that name
......
...@@ -70,7 +70,8 @@ public class SampleSecureOAuth2ActuatorApplicationTests { ...@@ -70,7 +70,8 @@ public class SampleSecureOAuth2ActuatorApplicationTests {
@Test @Test
public void healthAvailable() throws Exception { public void healthAvailable() throws Exception {
this.mvc.perform(get("/application/health")).andExpect(status().isOk()).andDo(print()); this.mvc.perform(get("/application/health")).andExpect(status().isOk())
.andDo(print());
} }
@Test @Test
......
...@@ -56,8 +56,9 @@ class OverrideAutoConfigurationContextCustomizerFactory ...@@ -56,8 +56,9 @@ class OverrideAutoConfigurationContextCustomizerFactory
@Override @Override
public void customizeContext(ConfigurableApplicationContext context, public void customizeContext(ConfigurableApplicationContext context,
MergedContextConfiguration mergedConfig) { MergedContextConfiguration mergedConfig) {
TestPropertyValues.of( TestPropertyValues
EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false").applyTo(context); .of(EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false")
.applyTo(context);
} }
@Override @Override
......
...@@ -26,9 +26,9 @@ import java.lang.annotation.Target; ...@@ -26,9 +26,9 @@ import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
/** /**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Data LDAP * {@link ImportAutoConfiguration Auto-configuration imports} for typical Data LDAP tests.
* tests. Most tests should consider using {@link DataLdapTest @DataLdapTest} rather * Most tests should consider using {@link DataLdapTest @DataLdapTest} rather than using
* than using this annotation directly. * this annotation directly.
* *
* @author Eddú Meléndez * @author Eddú Meléndez
* @since 2.0.0 * @since 2.0.0
......
...@@ -35,8 +35,8 @@ import org.springframework.test.context.BootstrapWith; ...@@ -35,8 +35,8 @@ import org.springframework.test.context.BootstrapWith;
/** /**
* Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)} * Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
* for a typical LDAP test. Can be used when a test focuses <strong>only</strong> on * for a typical LDAP test. Can be used when a test focuses <strong>only</strong> on LDAP
* LDAP components. * components.
* <p> * <p>
* Using this annotation will disable full auto-configuration and instead apply only * Using this annotation will disable full auto-configuration and instead apply only
* configuration relevant to LDAP tests. * configuration relevant to LDAP tests.
......
...@@ -46,12 +46,12 @@ class DataLdapTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter ...@@ -46,12 +46,12 @@ class DataLdapTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
@Override @Override
protected Filter[] getFilters(FilterType type) { protected Filter[] getFilters(FilterType type) {
switch (type) { switch (type) {
case INCLUDE: case INCLUDE:
return this.annotation.includeFilters(); return this.annotation.includeFilters();
case EXCLUDE: case EXCLUDE:
return this.annotation.excludeFilters(); return this.annotation.excludeFilters();
default: default:
throw new IllegalStateException("Unsupported type " + type); throw new IllegalStateException("Unsupported type " + type);
} }
} }
......
...@@ -46,12 +46,12 @@ class DataNeo4jTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter ...@@ -46,12 +46,12 @@ class DataNeo4jTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
@Override @Override
protected Filter[] getFilters(FilterType type) { protected Filter[] getFilters(FilterType type) {
switch (type) { switch (type) {
case INCLUDE: case INCLUDE:
return this.annotation.includeFilters(); return this.annotation.includeFilters();
case EXCLUDE: case EXCLUDE:
return this.annotation.excludeFilters(); return this.annotation.excludeFilters();
default: default:
throw new IllegalStateException("Unsupported type " + type); throw new IllegalStateException("Unsupported type " + type);
} }
} }
......
...@@ -46,12 +46,12 @@ class DataRedisTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter ...@@ -46,12 +46,12 @@ class DataRedisTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
@Override @Override
protected Filter[] getFilters(FilterType type) { protected Filter[] getFilters(FilterType type) {
switch (type) { switch (type) {
case INCLUDE: case INCLUDE:
return this.annotation.includeFilters(); return this.annotation.includeFilters();
case EXCLUDE: case EXCLUDE:
return this.annotation.excludeFilters(); return this.annotation.excludeFilters();
default: default:
throw new IllegalStateException("Unsupported type " + type); throw new IllegalStateException("Unsupported type " + type);
} }
} }
......
...@@ -42,8 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -42,8 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@DataLdapTest @DataLdapTest
@TestPropertySource(properties = {"spring.ldap.embedded.base-dn=dc=spring,dc=org", @TestPropertySource(properties = { "spring.ldap.embedded.base-dn=dc=spring,dc=org",
"spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif"}) "spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif" })
public class DataLdapTestIntegrationTests { public class DataLdapTestIntegrationTests {
@Rule @Rule
...@@ -63,10 +63,11 @@ public class DataLdapTestIntegrationTests { ...@@ -63,10 +63,11 @@ public class DataLdapTestIntegrationTests {
LdapQuery ldapQuery = LdapQueryBuilder.query().where("cn").is("Bob Smith"); LdapQuery ldapQuery = LdapQueryBuilder.query().where("cn").is("Bob Smith");
Optional<ExampleEntry> entry = this.exampleRepository.findOne(ldapQuery); Optional<ExampleEntry> entry = this.exampleRepository.findOne(ldapQuery);
assertThat(entry.isPresent()); assertThat(entry.isPresent());
assertThat(entry.get().getDn()) assertThat(entry.get().getDn()).isEqualTo(LdapUtils
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org")); .newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
assertThat(this.ldapTemplate.findOne(ldapQuery, ExampleEntry.class) .getDn()) assertThat(this.ldapTemplate.findOne(ldapQuery, ExampleEntry.class).getDn())
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org")); .isEqualTo(LdapUtils.newLdapName(
"cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
} }
@Test @Test
......
...@@ -36,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -36,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@DataLdapTest(includeFilters = @Filter(Service.class)) @DataLdapTest(includeFilters = @Filter(Service.class))
@TestPropertySource(properties = {"spring.ldap.embedded.base-dn=dc=spring,dc=org", @TestPropertySource(properties = { "spring.ldap.embedded.base-dn=dc=spring,dc=org",
"spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif"}) "spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif" })
public class DataLdapTestWithIncludeFilterIntegrationTests { public class DataLdapTestWithIncludeFilterIntegrationTests {
@Autowired @Autowired
......
...@@ -38,7 +38,7 @@ public class DataNeo4jTestWithIncludeFilterIntegrationTests { ...@@ -38,7 +38,7 @@ public class DataNeo4jTestWithIncludeFilterIntegrationTests {
@Rule @Rule
public Neo4jTestServer server = new Neo4jTestServer( public Neo4jTestServer server = new Neo4jTestServer(
new String[]{"org.springframework.boot.test.autoconfigure.data.neo4j"}); new String[] { "org.springframework.boot.test.autoconfigure.data.neo4j" });
@Autowired @Autowired
private ExampleService service; private ExampleService service;
......
...@@ -104,8 +104,9 @@ public class Neo4jTestServer implements TestRule { ...@@ -104,8 +104,9 @@ public class Neo4jTestServer implements TestRule {
@Override @Override
public void evaluate() throws Throwable { public void evaluate() throws Throwable {
Assume.assumeTrue("Skipping test due to Neo4j SessionFactory" Assume.assumeTrue(
+ " not being available", false); "Skipping test due to Neo4j SessionFactory" + " not being available",
false);
} }
} }
......
...@@ -66,7 +66,8 @@ public class DataRedisTestIntegrationTests { ...@@ -66,7 +66,8 @@ public class DataRedisTestIntegrationTests {
assertThat(personHash.getId()).isNull(); assertThat(personHash.getId()).isNull();
PersonHash savedEntity = this.exampleRepository.save(personHash); PersonHash savedEntity = this.exampleRepository.save(personHash);
assertThat(savedEntity.getId()).isNotNull(); assertThat(savedEntity.getId()).isNotNull();
assertThat(this.operations.execute((RedisConnection connection) -> connection.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue(); assertThat(this.operations.execute((RedisConnection connection) -> connection
.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue();
this.exampleRepository.deleteAll(); this.exampleRepository.deleteAll();
} }
......
...@@ -39,8 +39,8 @@ public class ExampleService { ...@@ -39,8 +39,8 @@ public class ExampleService {
} }
public boolean hasRecord(PersonHash personHash) { public boolean hasRecord(PersonHash personHash) {
return this.operations.execute((RedisConnection connection) -> return this.operations.execute((RedisConnection connection) -> connection
connection.exists(("persons:" + personHash.getId()).getBytes(CHARSET))); .exists(("persons:" + personHash.getId()).getBytes(CHARSET)));
} }
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
/** /**
* Example exception used in {@link WebMvcTest} tests. * Example exception used in {@link WebMvcTest} tests.
* *
......
...@@ -150,8 +150,10 @@ public class SpringBootContextLoader extends AbstractContextLoader { ...@@ -150,8 +150,10 @@ public class SpringBootContextLoader extends AbstractContextLoader {
private void setActiveProfiles(ConfigurableEnvironment environment, private void setActiveProfiles(ConfigurableEnvironment environment,
String[] profiles) { String[] profiles) {
TestPropertyValues.of("spring.profiles.active=" TestPropertyValues
+ StringUtils.arrayToCommaDelimitedString(profiles)).applyTo(environment); .of("spring.profiles.active="
+ StringUtils.arrayToCommaDelimitedString(profiles))
.applyTo(environment);
} }
protected String[] getInlinedProperties(MergedContextConfiguration config) { protected String[] getInlinedProperties(MergedContextConfiguration config) {
......
...@@ -31,15 +31,15 @@ import org.springframework.web.reactive.config.EnableWebFlux; ...@@ -31,15 +31,15 @@ import org.springframework.web.reactive.config.EnableWebFlux;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@link SpringBootTest} in a reactive environment configured with * Tests for {@link SpringBootTest} in a reactive environment configured with a
* a user-defined {@link RestTemplate} that is named {@code testRestTemplate}. * user-defined {@link RestTemplate} that is named {@code testRestTemplate}.
* *
* @author Madhura Bhave * @author Madhura Bhave
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@DirtiesContext @DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
properties = { "spring.main.web-application-type=reactive", "value=123" }) "spring.main.web-application-type=reactive", "value=123" })
public class SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests public class SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests
extends AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests { extends AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
......
...@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@Deprecated
public class EnvironmentTestUtilsTests { public class EnvironmentTestUtilsTests {
private final ConfigurableEnvironment environment = new StandardEnvironment(); private final ConfigurableEnvironment environment = new StandardEnvironment();
......
...@@ -71,8 +71,8 @@ public class ItemDeprecation { ...@@ -71,8 +71,8 @@ public class ItemDeprecation {
@Override @Override
public String toString() { public String toString() {
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", " return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", "
+ "replacement='" + this.replacement + '\'' + ", " + "replacement='" + this.replacement + '\'' + ", " + "level='"
+ "level='" + this.level + '\'' + '}'; + this.level + '\'' + '}';
} }
@Override @Override
......
...@@ -556,16 +556,14 @@ public class ConfigurationMetadataAnnotationProcessorTests { ...@@ -556,16 +556,14 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test @Test
public void mergeExistingPropertyDeprecation() throws Exception { public void mergeExistingPropertyDeprecation() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null, ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
null, null, null, null, null, null, null, null, new ItemDeprecation("Don't use this.",
new ItemDeprecation("Don't use this.", "simple.complex-comparator", "simple.complex-comparator", "error"));
"error"));
writeAdditionalMetadata(property); writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class); ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata) assertThat(metadata)
.has(Metadata.withProperty("simple.comparator", "java.util.Comparator<?>") .has(Metadata.withProperty("simple.comparator", "java.util.Comparator<?>")
.fromSource(SimpleProperties.class) .fromSource(SimpleProperties.class).withDeprecation(
.withDeprecation("Don't use this.", "simple.complex-comparator", "Don't use this.", "simple.complex-comparator", "error"));
"error"));
assertThat(metadata.getItems()).hasSize(4); assertThat(metadata.getItems()).hasSize(4);
} }
...@@ -591,8 +589,8 @@ public class ConfigurationMetadataAnnotationProcessorTests { ...@@ -591,8 +589,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class); ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
assertThat(metadata).has( assertThat(metadata).has(
Metadata.withProperty("singledeprecated.name", String.class.getName()) Metadata.withProperty("singledeprecated.name", String.class.getName())
.fromSource(DeprecatedSingleProperty.class) .fromSource(DeprecatedSingleProperty.class).withDeprecation(
.withDeprecation("renamed", "singledeprecated.new-name", "error")); "renamed", "singledeprecated.new-name", "error"));
assertThat(metadata.getItems()).hasSize(3); assertThat(metadata.getItems()).hasSize(3);
} }
......
...@@ -63,12 +63,10 @@ public class RedisTestServer implements TestRule { ...@@ -63,12 +63,10 @@ public class RedisTestServer implements TestRule {
ClassLoader classLoader = RedisTestServer.class.getClassLoader(); ClassLoader classLoader = RedisTestServer.class.getClassLoader();
RedisConnectionFactory cf; RedisConnectionFactory cf;
if (ClassUtils.isPresent("redis.clients.jedis.Jedis", classLoader)) { if (ClassUtils.isPresent("redis.clients.jedis.Jedis", classLoader)) {
cf = new JedisConnectionFactoryConfiguration() cf = new JedisConnectionFactoryConfiguration().createConnectionFactory();
.createConnectionFactory();
} }
else { else {
cf = new LettuceConnectionFactoryConfiguration() cf = new LettuceConnectionFactoryConfiguration().createConnectionFactory();
.createConnectionFactory();
} }
testConnection(cf); testConnection(cf);
...@@ -142,8 +140,7 @@ public class RedisTestServer implements TestRule { ...@@ -142,8 +140,7 @@ public class RedisTestServer implements TestRule {
RedisConnectionFactory createConnectionFactory() { RedisConnectionFactory createConnectionFactory() {
LettuceClientConfiguration config = LettuceClientConfiguration.builder() LettuceClientConfiguration config = LettuceClientConfiguration.builder()
.shutdownTimeout(Duration.ofMillis(0)) .shutdownTimeout(Duration.ofMillis(0)).build();
.build();
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory( LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(
new RedisStandaloneConfiguration(), config); new RedisStandaloneConfiguration(), config);
connectionFactory.afterPropertiesSet(); connectionFactory.afterPropertiesSet();
......
...@@ -79,8 +79,8 @@ public class JsonComponentModule extends SimpleModule implements BeanFactoryAwar ...@@ -79,8 +79,8 @@ public class JsonComponentModule extends SimpleModule implements BeanFactoryAwar
addDeserializerWithDeducedType((JsonDeserializer<?>) bean); addDeserializerWithDeducedType((JsonDeserializer<?>) bean);
} }
for (Class<?> innerClass : bean.getClass().getDeclaredClasses()) { for (Class<?> innerClass : bean.getClass().getDeclaredClasses()) {
if (!Modifier.isAbstract(innerClass.getModifiers()) && if (!Modifier.isAbstract(innerClass.getModifiers())
(JsonSerializer.class.isAssignableFrom(innerClass) && (JsonSerializer.class.isAssignableFrom(innerClass)
|| JsonDeserializer.class.isAssignableFrom(innerClass))) { || JsonDeserializer.class.isAssignableFrom(innerClass))) {
try { try {
addJsonBean(innerClass.newInstance()); addJsonBean(innerClass.newInstance());
......
...@@ -987,7 +987,7 @@ public class SpringApplicationTests { ...@@ -987,7 +987,7 @@ public class SpringApplicationTests {
public void run() { public void run() {
SpringApplication application = new SpringApplication( SpringApplication application = new SpringApplication(
FailingConfig.class); FailingConfig.class);
application.setWebEnvironment(false); application.setWebApplicationType(WebApplicationType.NONE);
application.run(); application.run();
}; };
}; };
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 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.
...@@ -73,7 +73,8 @@ public class CloudPlatformTests { ...@@ -73,7 +73,8 @@ public class CloudPlatformTests {
@Test @Test
public void getActiveWhenHasHcLandscapeShouldReturnHcp() throws Exception { public void getActiveWhenHasHcLandscapeShouldReturnHcp() throws Exception {
Environment environment = new MockEnvironment().withProperty("HC_LANDSCAPE", "---"); Environment environment = new MockEnvironment().withProperty("HC_LANDSCAPE",
"---");
CloudPlatform platform = CloudPlatform.getActive(environment); CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.HCP); assertThat(platform).isEqualTo(CloudPlatform.HCP);
assertThat(platform.isActive(environment)).isTrue(); assertThat(platform.isActive(environment)).isTrue();
......
...@@ -109,7 +109,8 @@ public class JsonComponentModuleTests { ...@@ -109,7 +109,8 @@ public class JsonComponentModuleTests {
@JsonComponent @JsonComponent
static class ComponentWithInnerAbstractClass { static class ComponentWithInnerAbstractClass {
private static abstract class AbstractSerializer extends NameAndAgeJsonComponent.Serializer { private static abstract class AbstractSerializer
extends NameAndAgeJsonComponent.Serializer {
} }
......
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