diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java index e9659c17648..f850b4d57ac 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java @@ -28,6 +28,7 @@ import org.springframework.cache.Cache; * @author Stephane Nicoll * @since 2.0.0 */ +@FunctionalInterface public interface CacheMeterBinderProvider { /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicator.java index 457a24f2148..ec9d7c6caa8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.neo4j.ogm.session.SessionFactory; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.actuate.health.Health.Builder; import org.springframework.boot.actuate.health.HealthIndicator; /** @@ -59,8 +60,8 @@ public class Neo4jHealthIndicator extends AbstractHealthIndicator { } /** - * Provide health details using the specified {@link Session} and - * {@link Health.Builder Builder}. + * Provide health details using the specified {@link Session} and {@link Builder + * Builder}. * @param session the session to use to execute a cypher statement * @param builder the builder to add details to * @throws Exception if getting health details failed diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/MetricsEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/MetricsEndpointTests.java index d2c8fe3c16b..b5784b3f3d6 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/MetricsEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/MetricsEndpointTests.java @@ -93,11 +93,9 @@ public class MetricsEndpointTests { this.registry.counter("cache", "host", "1", "region", "east", "result", "miss"); MetricsEndpoint.MetricResponse response = this.endpoint.metric("cache", Collections.singletonList("host:1")); - assertThat(response.getAvailableTags() - .stream() - .filter(t -> t.getTag().equals("region")) - .flatMap(t -> t.getValues().stream())) - .containsExactly("east"); + assertThat(response.getAvailableTags().stream() + .filter((t) -> t.getTag().equals("region")) + .flatMap((t) -> t.getValues().stream())).containsExactly("east"); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java index b6b28139a76..6550836239f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class MongoClientFactory { String host = this.properties.getHost() == null ? "localhost" : this.properties.getHost(); return new MongoClient(Collections.singletonList(new ServerAddress(host, port)), - Collections.emptyList(), options); + options); } private MongoClient createNetworkMongoClient(MongoClientOptions options) { @@ -96,12 +96,13 @@ public class MongoClientFactory { if (options == null) { options = MongoClientOptions.builder().build(); } - List credentials = getCredentials(properties); + MongoCredential credentials = getCredentials(properties); String host = getValue(properties.getHost(), "localhost"); int port = getValue(properties.getPort(), MongoProperties.DEFAULT_PORT); List seeds = Collections .singletonList(new ServerAddress(host, port)); - return new MongoClient(seeds, credentials, options); + return credentials == null ? new MongoClient(seeds, options) + : new MongoClient(seeds, credentials, options); } return createMongoClient(MongoProperties.DEFAULT_URI, options); } @@ -118,16 +119,15 @@ public class MongoClientFactory { return this.properties.getHost() != null || this.properties.getPort() != null; } - private List getCredentials(MongoProperties properties) { + private MongoCredential getCredentials(MongoProperties properties) { if (!hasCustomCredentials()) { - return Collections.emptyList(); + return null; } String username = properties.getUsername(); String database = getValue(properties.getAuthenticationDatabase(), properties.getMongoClientDatabase()); char[] password = properties.getPassword(); - return Collections.singletonList( - MongoCredential.createCredential(username, database, password)); + return MongoCredential.createCredential(username, database, password); } private boolean hasCustomCredentials() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java index 61d3c6eb0d2..afab018ec50 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure.mongo; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -120,13 +119,12 @@ public class ReactiveMongoClientFactory { } private void applyCredentials(Builder builder) { - List credentials = new ArrayList<>(); String database = this.properties.getAuthenticationDatabase() == null ? this.properties.getMongoClientDatabase() : this.properties.getAuthenticationDatabase(); - credentials.add(MongoCredential.createCredential(this.properties.getUsername(), - database, this.properties.getPassword())); - builder.credentialList(credentials); + builder.credential((MongoCredential.createCredential( + this.properties.getUsername(), database, this.properties.getPassword()))); + } private T getOrDefault(T value, T defaultValue) { @@ -144,7 +142,7 @@ public class ReactiveMongoClientFactory { builder.clusterSettings(getClusterSettings(connection)); builder.connectionPoolSettings(getConnectionPoolSettings(connection)); builder.serverSettings(getServerSettings(connection)); - builder.credentialList(connection.getCredentialList()); + builder.credential(connection.getCredential()); builder.sslSettings(getSslSettings(connection)); builder.socketSettings(getSocketSettings(connection)); if (connection.getReadPreference() != null) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java index 512cf140f2c..fc81cb1f491 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java @@ -106,7 +106,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { this.physicalNamingStrategy = physicalNamingStrategy.getIfAvailable(); this.implicitNamingStrategy = implicitNamingStrategy.getIfAvailable(); this.hibernatePropertiesCustomizers = hibernatePropertiesCustomizers - .getIfAvailable(() -> Collections.EMPTY_LIST); + .getIfAvailable(() -> Collections.emptyList()); } @Override @@ -122,7 +122,8 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { .getHibernateProperties(new HibernateSettings().ddlAuto(defaultDdlMode) .implicitNamingStrategy(this.implicitNamingStrategy) .physicalNamingStrategy(this.physicalNamingStrategy) - .hibernatePropertiesCustomizers(this.hibernatePropertiesCustomizers))); + .hibernatePropertiesCustomizers( + this.hibernatePropertiesCustomizers))); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/DockerTestContainer.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/DockerTestContainer.java index 35159889aa3..d51de5e61d0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/DockerTestContainer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/DockerTestContainer.java @@ -26,12 +26,13 @@ import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.GenericContainer; /** - * {@link TestRule} for working with an optional Docker environment. Spins up a {@link GenericContainer} - * if a valid docker environment is found. + * {@link TestRule} for working with an optional Docker environment. Spins up a + * {@link GenericContainer} if a valid docker environment is found. * + * @param the type of the container * @author Madhura Bhave */ -public class DockerTestContainer implements TestRule { +public class DockerTestContainer> implements TestRule { private Supplier containerSupplier; @@ -60,4 +61,3 @@ public class DockerTestContainer implements TestRule } } - diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java index fd8309c5079..fb9a085dd4b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.cassandra; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; @@ -29,7 +28,6 @@ import org.junit.Test; import org.rnorth.ducttape.TimeoutException; import org.rnorth.ducttape.unreliables.Unreliables; import org.testcontainers.containers.FixedHostPortGenericContainer; -import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.HostPortWaitStrategy; import org.springframework.boot.autoconfigure.AutoConfigurationPackages; @@ -52,10 +50,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class CassandraDataAutoConfigurationIntegrationTests { @ClassRule - public static DockerTestContainer genericContainer = new DockerTestContainer<>((Supplier) () -> new FixedHostPortGenericContainer("cassandra:latest") - .withFixedExposedPort(9042, 9042) - .waitingFor(new ConnectionVerifyingWaitStrategy())); - + public static DockerTestContainer> cassandra = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("cassandra:latest") + .withFixedExposedPort(9042, 9042) + .waitingFor(new ConnectionVerifyingWaitStrategy())); private AnnotationConfigApplicationContext context; @@ -113,8 +111,8 @@ public class CassandraDataAutoConfigurationIntegrationTests { super.waitUntilReady(); Cluster cluster = Cluster.builder().addContactPoint("localhost").build(); try { - Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, - checkConnection(cluster)); + Unreliables.retryUntilTrue((int) this.startupTimeout.getSeconds(), + TimeUnit.SECONDS, checkConnection(cluster)); } catch (TimeoutException e) { throw new IllegalStateException(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java index 27acba2cd47..dc02abbbf44 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,9 +42,9 @@ import static org.assertj.core.api.Assertions.assertThat; public class RedisRepositoriesAutoConfigurationTests { @ClassRule - public static DockerTestContainer genericContainer = new DockerTestContainer<>(() -> - new FixedHostPortGenericContainer("redis:latest") - .withFixedExposedPort(6379, 6379)); + public static DockerTestContainer> redis = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("redis:latest") + .withFixedExposedPort(6379, 6379)); private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java index 75a252ba593..0a73abda88a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests { @Test public void defaultConfiguration() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { assertThat(context.getBean(FreeMarkerViewResolver.class)).isNotNull(); assertThat(context.getBean(FreeMarkerConfigurer.class)).isNotNull(); assertThat(context.getBean(FreeMarkerConfig.class)).isNotNull(); @@ -58,7 +58,7 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests { @Test public void defaultViewResolution() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { MockServerWebExchange exchange = render(context, "home"); String result = exchange.getResponse().getBodyAsString().block(); assertThat(result).contains("home"); @@ -70,7 +70,7 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests { @Test public void customPrefix() { this.contextRunner.withPropertyValues("spring.freemarker.prefix:prefix/") - .run(context -> { + .run((context) -> { MockServerWebExchange exchange = render(context, "prefixed"); String result = exchange.getResponse().getBodyAsString().block(); assertThat(result).contains("prefixed"); @@ -80,7 +80,7 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests { @Test public void customSuffix() { this.contextRunner.withPropertyValues("spring.freemarker.suffix:.freemarker") - .run(context -> { + .run((context) -> { MockServerWebExchange exchange = render(context, "suffixed"); String result = exchange.getResponse().getBodyAsString().block(); assertThat(result).contains("suffixed"); @@ -92,7 +92,7 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests { this.contextRunner .withPropertyValues( "spring.freemarker.templateLoaderPath:classpath:/custom-templates/") - .run(context -> { + .run((context) -> { MockServerWebExchange exchange = render(context, "custom"); String result = exchange.getResponse().getBodyAsString().block(); assertThat(result).contains("custom"); @@ -104,14 +104,14 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests { public void customFreeMarkerSettings() { this.contextRunner .withPropertyValues("spring.freemarker.settings.boolean_format:yup,nope") - .run(context -> assertThat(context.getBean(FreeMarkerConfigurer.class) + .run((context) -> assertThat(context.getBean(FreeMarkerConfigurer.class) .getConfiguration().getSetting("boolean_format")) .isEqualTo("yup,nope")); } @Test public void renderTemplate() { - this.contextRunner.withPropertyValues().run(context -> { + this.contextRunner.withPropertyValues().run((context) -> { FreeMarkerConfigurer freemarker = context.getBean(FreeMarkerConfigurer.class); StringWriter writer = new StringWriter(); freemarker.getConfiguration().getTemplate("message.ftl").process(this, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java index d4cca1a9ad7..2f4f243e194 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public class FreeMarkerAutoConfigurationTests { @Test public void renderNonWebAppTemplate() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { freemarker.template.Configuration freemarker = context .getBean(freemarker.template.Configuration.class); StringWriter writer = new StringWriter(); @@ -63,7 +63,7 @@ public class FreeMarkerAutoConfigurationTests { this.contextRunner .withPropertyValues("spring.freemarker.templateLoaderPath:" + "classpath:/does-not-exist/,classpath:/also-does-not-exist") - .run(context -> this.output + .run((context) -> this.output .expect(containsString("Cannot find template location"))); } @@ -71,7 +71,7 @@ public class FreeMarkerAutoConfigurationTests { public void emptyTemplateLocation() { new File("target/test-classes/templates/empty-directory").mkdir(); this.contextRunner.withPropertyValues("spring.freemarker.templateLoaderPath:" - + "classpath:/templates/empty-directory/").run(context -> { + + "classpath:/templates/empty-directory/").run((context) -> { }); } @@ -81,7 +81,7 @@ public class FreeMarkerAutoConfigurationTests { this.contextRunner .withPropertyValues("spring.freemarker.templateLoaderPath:" + "classpath:/does-not-exist/,classpath:/templates/empty-directory/") - .run(context -> { + .run((context) -> { }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java index 6699ad32151..aa5213da1cb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class JacksonAutoConfigurationTests { @Test public void registersJodaModuleAutomatically() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { ObjectMapper objectMapper = context.getBean(ObjectMapper.class); assertThat(objectMapper.canSerialize(LocalDateTime.class)).isTrue(); }); @@ -93,7 +93,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner.withUserConfiguration(DoubleModulesConfig.class) .withConfiguration(AutoConfigurations .of(HttpMessageConvertersAutoConfiguration.class)) - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.writeValueAsString(new Foo())) .isEqualTo("{\"foo\":\"bar\"}"); @@ -108,7 +108,7 @@ public class JacksonAutoConfigurationTests { @Test public void noCustomDateFormat() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.getDateFormat()).isInstanceOf(StdDateFormat.class); }); @@ -117,7 +117,7 @@ public class JacksonAutoConfigurationTests { @Test public void customDateFormat() { this.contextRunner.withPropertyValues("spring.jackson.date-format:yyyyMMddHHmmss") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); DateFormat dateFormat = mapper.getDateFormat(); assertThat(dateFormat).isInstanceOf(SimpleDateFormat.class); @@ -131,7 +131,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues("spring.jackson.date-format:yyyyMMddHHmmss", "spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC); @@ -148,7 +148,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class); }); @@ -156,7 +156,7 @@ public class JacksonAutoConfigurationTests { @Test public void noCustomPropertyNamingStrategy() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.getPropertyNamingStrategy()).isNull(); }); @@ -166,7 +166,7 @@ public class JacksonAutoConfigurationTests { public void customPropertyNamingStrategyField() { this.contextRunner .withPropertyValues("spring.jackson.property-naming-strategy:SNAKE_CASE") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.getPropertyNamingStrategy()) .isInstanceOf(SnakeCaseStrategy.class); @@ -178,7 +178,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.getPropertyNamingStrategy()) .isInstanceOf(SnakeCaseStrategy.class); @@ -189,7 +189,7 @@ public class JacksonAutoConfigurationTests { public void enableSerializationFeature() { this.contextRunner .withPropertyValues("spring.jackson.serialization.indent_output:true") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(SerializationFeature.INDENT_OUTPUT.enabledByDefault()) .isFalse(); @@ -203,7 +203,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.serialization.write_dates_as_timestamps:false") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS .enabledByDefault()).isTrue(); @@ -218,7 +218,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.deserialization.use_big_decimal_for_floats:true") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS .enabledByDefault()).isFalse(); @@ -234,7 +234,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.deserialization.fail-on-unknown-properties:false") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES .enabledByDefault()).isTrue(); @@ -250,7 +250,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.mapper.require_setters_for_getters:true") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat( MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault()) @@ -268,7 +268,7 @@ public class JacksonAutoConfigurationTests { public void disableMapperFeature() { this.contextRunner .withPropertyValues("spring.jackson.mapper.use_annotations:false") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(MapperFeature.USE_ANNOTATIONS.enabledByDefault()).isTrue(); assertThat(mapper.getDeserializationConfig() @@ -284,7 +284,7 @@ public class JacksonAutoConfigurationTests { public void enableParserFeature() { this.contextRunner .withPropertyValues("spring.jackson.parser.allow_single_quotes:true") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(JsonParser.Feature.ALLOW_SINGLE_QUOTES.enabledByDefault()) .isFalse(); @@ -297,7 +297,7 @@ public class JacksonAutoConfigurationTests { public void disableParserFeature() { this.contextRunner .withPropertyValues("spring.jackson.parser.auto_close_source:false") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledByDefault()) .isTrue(); @@ -311,7 +311,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues( "spring.jackson.generator.write_numbers_as_strings:true") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS .enabledByDefault()).isFalse(); @@ -325,7 +325,7 @@ public class JacksonAutoConfigurationTests { public void disableGeneratorFeature() { this.contextRunner .withPropertyValues("spring.jackson.generator.auto_close_target:false") - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault()) .isTrue(); @@ -337,7 +337,7 @@ public class JacksonAutoConfigurationTests { @Test public void defaultObjectMapperBuilder() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { Jackson2ObjectMapperBuilder builder = context .getBean(Jackson2ObjectMapperBuilder.class); ObjectMapper mapper = builder.build(); @@ -360,7 +360,7 @@ public class JacksonAutoConfigurationTests { @Test public void moduleBeansAndWellKnownModulesAreRegisteredWithTheObjectMapperBuilder() { - this.contextRunner.withUserConfiguration(ModuleConfig.class).run(context -> { + this.contextRunner.withUserConfiguration(ModuleConfig.class).run((context) -> { ObjectMapper objectMapper = context.getBean(Jackson2ObjectMapperBuilder.class) .build(); assertThat(context.getBean(CustomModule.class).getOwners()) @@ -372,7 +372,7 @@ public class JacksonAutoConfigurationTests { @Test public void defaultSerializationInclusion() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { ObjectMapper objectMapper = context.getBean(Jackson2ObjectMapperBuilder.class) .build(); assertThat(objectMapper.getSerializationConfig().getDefaultPropertyInclusion() @@ -384,7 +384,7 @@ public class JacksonAutoConfigurationTests { public void customSerializationInclusion() { this.contextRunner .withPropertyValues("spring.jackson.default-property-inclusion:non_null") - .run(context -> { + .run((context) -> { ObjectMapper objectMapper = context .getBean(Jackson2ObjectMapperBuilder.class).build(); assertThat(objectMapper.getSerializationConfig() @@ -398,7 +398,7 @@ public class JacksonAutoConfigurationTests { this.contextRunner .withPropertyValues("spring.jackson.time-zone:America/Los_Angeles", "spring.jackson.date-format:zzzz", "spring.jackson.locale:en") - .run(context -> { + .run((context) -> { ObjectMapper objectMapper = context .getBean(Jackson2ObjectMapperBuilder.class).build(); DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC); @@ -410,7 +410,7 @@ public class JacksonAutoConfigurationTests { @Test public void customTimeZoneFormattingADate() throws JsonProcessingException { this.contextRunner.withPropertyValues("spring.jackson.time-zone:GMT+10", - "spring.jackson.date-format:z").run(context -> { + "spring.jackson.date-format:z").run((context) -> { ObjectMapper objectMapper = context .getBean(Jackson2ObjectMapperBuilder.class).build(); Date date = new Date(1436966242231L); @@ -425,7 +425,7 @@ public class JacksonAutoConfigurationTests { .withPropertyValues("spring.jackson.locale:de_DE", "spring.jackson.date-format:zzzz", "spring.jackson.serialization.write-dates-with-zone-id:true") - .run(context -> { + .run((context) -> { ObjectMapper objectMapper = context.getBean(ObjectMapper.class); DateTime jodaTime = new DateTime(1478424650000L, DateTimeZone.forID("Europe/Rome")); @@ -437,7 +437,7 @@ public class JacksonAutoConfigurationTests { @Test public void additionalJacksonBuilderCustomization() { this.contextRunner.withUserConfiguration(ObjectMapperBuilderCustomConfig.class) - .run(context -> { + .run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class); }); @@ -457,7 +457,7 @@ public class JacksonAutoConfigurationTests { @Test public void writeDatesAsTimestampsDefault() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { ObjectMapper mapper = context.getBean(ObjectMapper.class); DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC); String expected = FormatConfig.DEFAULT_DATETIME_PRINTER.rawFormatter() @@ -469,7 +469,7 @@ public class JacksonAutoConfigurationTests { private void assertParameterNamesModuleCreatorBinding(Mode expectedMode, Class... configClasses) { - this.contextRunner.withUserConfiguration(configClasses).run(context -> { + this.contextRunner.withUserConfiguration(configClasses).run((context) -> { DeserializationConfig deserializationConfig = context .getBean(ObjectMapper.class).getDeserializationConfig(); AnnotationIntrospector annotationIntrospector = deserializationConfig diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java index 2ff9ec3b1da..68758db56d8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java @@ -47,31 +47,33 @@ import static org.mockito.Mockito.mock; public class MongoReactiveAutoConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of( - MongoReactiveAutoConfiguration.class)); + .withConfiguration( + AutoConfigurations.of(MongoReactiveAutoConfiguration.class)); @Test public void clientExists() { - this.contextRunner.run((context) -> - assertThat(context).hasSingleBean(MongoClient.class)); + this.contextRunner + .run((context) -> assertThat(context).hasSingleBean(MongoClient.class)); } @Test public void optionsAdded() { this.contextRunner.withPropertyValues("spring.data.mongodb.host:localhost") - .withUserConfiguration(OptionsConfig.class).run((context) -> - assertThat(context.getBean(MongoClient.class).getSettings() - .getSocketSettings().getReadTimeout(TimeUnit.SECONDS)) - .isEqualTo(300)); + .withUserConfiguration(OptionsConfig.class) + .run((context) -> assertThat( + context.getBean(MongoClient.class).getSettings() + .getSocketSettings().getReadTimeout(TimeUnit.SECONDS)) + .isEqualTo(300)); } @Test public void optionsAddedButNoHost() { this.contextRunner .withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test") - .withUserConfiguration(OptionsConfig.class).run((context) -> - assertThat(context.getBean(MongoClient.class).getSettings() - .getReadPreference()).isEqualTo(ReadPreference.nearest())); + .withUserConfiguration(OptionsConfig.class) + .run((context) -> assertThat(context.getBean(MongoClient.class) + .getSettings().getReadPreference()) + .isEqualTo(ReadPreference.nearest())); } @Test @@ -79,13 +81,13 @@ public class MongoReactiveAutoConfigurationTests { this.contextRunner .withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test") .withUserConfiguration(SslOptionsConfig.class).run((context) -> { - assertThat(context).hasSingleBean(MongoClient.class); - MongoClient mongo = context.getBean(MongoClient.class); - MongoClientSettings settings = mongo.getSettings(); - assertThat(settings.getApplicationName()).isEqualTo("test-config"); - assertThat(settings.getStreamFactoryFactory()) - .isSameAs(context.getBean("myStreamFactoryFactory")); - }); + assertThat(context).hasSingleBean(MongoClient.class); + MongoClient mongo = context.getBean(MongoClient.class); + MongoClientSettings settings = mongo.getSettings(); + assertThat(settings.getApplicationName()).isEqualTo("test-config"); + assertThat(settings.getStreamFactoryFactory()) + .isSameAs(context.getBean("myStreamFactoryFactory")); + }); } @Test @@ -94,22 +96,23 @@ public class MongoReactiveAutoConfigurationTests { assertThat(context).hasSingleBean(MongoClient.class); assertThat(context.getBean(MongoClient.class).getSettings() .getStreamFactoryFactory()) - .isInstanceOf(NettyStreamFactoryFactory.class); + .isInstanceOf(NettyStreamFactoryFactory.class); }); } @Test public void customizerOverridesAutoConfig() { this.contextRunner - .withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test?appname=auto-config") + .withPropertyValues( + "spring.data.mongodb.uri:mongodb://localhost/test?appname=auto-config") .withUserConfiguration(SimpleCustomizerConfig.class).run((context) -> { - assertThat(context).hasSingleBean(MongoClient.class); - MongoClient client = context.getBean(MongoClient.class); - assertThat(client.getSettings().getApplicationName()) - .isEqualTo("overridden-name"); - assertThat(client.getSettings().getStreamFactoryFactory()) - .isEqualTo(SimpleCustomizerConfig.streamFactoryFactory); - }); + assertThat(context).hasSingleBean(MongoClient.class); + MongoClient client = context.getBean(MongoClient.class); + assertThat(client.getSettings().getApplicationName()) + .isEqualTo("overridden-name"); + assertThat(client.getSettings().getStreamFactoryFactory()) + .isEqualTo(SimpleCustomizerConfig.streamFactoryFactory); + }); } @Configuration @@ -147,8 +150,8 @@ public class MongoReactiveAutoConfigurationTests { @Configuration static class SimpleCustomizerConfig { - private static final StreamFactoryFactory streamFactoryFactory = - new AsynchronousSocketChannelStreamFactoryFactory(); + private static final StreamFactoryFactory streamFactoryFactory = new AsynchronousSocketChannelStreamFactoryFactory.Builder() + .build(); @Bean public MongoClientSettingsBuilderCustomizer customizer() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactoryTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactoryTests.java index 48eb1144a5b..edcf05945d6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactoryTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,8 +75,7 @@ public class ReactiveMongoClientFactoryTests { properties.setUsername("user"); properties.setPassword("secret".toCharArray()); MongoClient client = createMongoClient(properties); - assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret", - "test"); + assertMongoCredential(extractMongoCredentials(client), "user", "secret", "test"); } @Test @@ -86,8 +85,7 @@ public class ReactiveMongoClientFactoryTests { properties.setUsername("user"); properties.setPassword("secret".toCharArray()); MongoClient client = createMongoClient(properties); - assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret", - "foo"); + assertMongoCredential(extractMongoCredentials(client), "user", "secret", "foo"); } @Test @@ -97,8 +95,7 @@ public class ReactiveMongoClientFactoryTests { properties.setUsername("user"); properties.setPassword("secret".toCharArray()); MongoClient client = createMongoClient(properties); - assertMongoCredential(extractMongoCredentials(client).get(0), "user", "secret", - "foo"); + assertMongoCredential(extractMongoCredentials(client), "user", "secret", "foo"); } @Test @@ -111,9 +108,8 @@ public class ReactiveMongoClientFactoryTests { assertThat(allAddresses).hasSize(2); assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345); assertServerAddress(allAddresses.get(1), "mongo2.example.com", 23456); - List credentialsList = extractMongoCredentials(client); - assertThat(credentialsList).hasSize(1); - assertMongoCredential(credentialsList.get(0), "user", "secret", "test"); + MongoCredential credential = extractMongoCredentials(client); + assertMongoCredential(credential, "user", "secret", "test"); } @Test @@ -197,9 +193,9 @@ public class ReactiveMongoClientFactoryTests { return clusterSettings.getHosts(); } - private List extractMongoCredentials(MongoClient client) { + private MongoCredential extractMongoCredentials(MongoClient client) { MongoClientSettings settings = client.getSettings(); - return settings.getCredentialList(); + return settings.getCredential(); } private void assertServerAddress(ServerAddress serverAddress, String expectedHost, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfigurationTests.java index 45c43cb1d86..b85a2c7de8c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class AuthenticationManagerConfigurationTests { @Test public void userDetailsServiceWhenPasswordEncoderAbsentAndDefaultPassword() { this.contextRunner.withUserConfiguration(TestSecurityConfiguration.class, - AuthenticationManagerConfiguration.class).run((context -> { + AuthenticationManagerConfiguration.class).run(((context) -> { InMemoryUserDetailsManager userDetailsService = context .getBean(InMemoryUserDetailsManager.class); String password = userDetailsService.loadUserByUsername("user") @@ -73,7 +73,7 @@ public class AuthenticationManagerConfigurationTests { .withUserConfiguration(configClass, AuthenticationManagerConfiguration.class) .withPropertyValues("spring.security.user.password=" + providedPassword) - .run((context -> { + .run(((context) -> { InMemoryUserDetailsManager userDetailsService = context .getBean(InMemoryUserDetailsManager.class); String password = userDetailsService.loadUserByUsername("user") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveAuthenticationManagerConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveAuthenticationManagerConfigurationTests.java index 4f07a8b2ac5..bc546623ea8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveAuthenticationManagerConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveAuthenticationManagerConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public class ReactiveAuthenticationManagerConfigurationTests { this.contextRunner .withUserConfiguration(TestSecurityConfiguration.class, ReactiveAuthenticationManagerConfiguration.class) - .run((context -> { + .run(((context) -> { MapReactiveUserDetailsService userDetailsService = context .getBean(MapReactiveUserDetailsService.class); String password = userDetailsService.findByUsername("user").block() @@ -76,7 +76,7 @@ public class ReactiveAuthenticationManagerConfigurationTests { .withUserConfiguration(configClass, ReactiveAuthenticationManagerConfiguration.class) .withPropertyValues("spring.security.user.password=" + providedPassword) - .run((context -> { + .run(((context) -> { MapReactiveUserDetailsService userDetailsService = context .getBean(MapReactiveUserDetailsService.class); String password = userDetailsService.findByUsername("user").block() diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/ReactiveSessionAutoConfigurationRedisTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/ReactiveSessionAutoConfigurationRedisTests.java index 982e3efb174..c850b5d7647 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/ReactiveSessionAutoConfigurationRedisTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/ReactiveSessionAutoConfigurationRedisTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ public class ReactiveSessionAutoConfigurationRedisTests extends AbstractSessionAutoConfigurationTests { @ClassRule - public static DockerTestContainer redis = new DockerTestContainer<>(() -> - new FixedHostPortGenericContainer("redis:latest") + public static DockerTestContainer> redis = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("redis:latest") .withFixedExposedPort(6379, 6379)); protected final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner() diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java index 06481c929fd..98649edee64 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,8 +47,8 @@ public class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfigurationTests { @ClassRule - public static DockerTestContainer redis = new DockerTestContainer<>(() -> - new FixedHostPortGenericContainer("redis:latest") + public static DockerTestContainer> redis = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("redis:latest") .withFixedExposedPort(6379, 6379)); protected final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index 9fe0a30c2e1..471aa8797ae 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldNotProcessIfExistingWebReactiveConfiguration() { this.contextRunner.withUserConfiguration(WebFluxConfigurationSupport.class) - .run(context -> { + .run((context) -> { assertThat(context).getBeans(RequestMappingHandlerMapping.class) .hasSize(1); assertThat(context).getBeans(RequestMappingHandlerAdapter.class) @@ -88,7 +88,7 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldCreateDefaultBeans() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { assertThat(context).getBeans(RequestMappingHandlerMapping.class).hasSize(1); assertThat(context).getBeans(RequestMappingHandlerAdapter.class).hasSize(1); assertThat(context).getBeans(RequestedContentTypeResolver.class).hasSize(1); @@ -101,7 +101,7 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldRegisterCustomHandlerMethodArgumentResolver() { this.contextRunner.withUserConfiguration(CustomArgumentResolvers.class) - .run(context -> { + .run((context) -> { RequestMappingHandlerAdapter adapter = context .getBean(RequestMappingHandlerAdapter.class); List customResolvers = (List) ReflectionTestUtils @@ -118,7 +118,7 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldCustomizeCodecs() { this.contextRunner.withUserConfiguration(CustomCodecCustomizers.class) - .run(context -> { + .run((context) -> { CodecCustomizer codecCustomizer = context .getBean("firstCodecCustomizer", CodecCustomizer.class); assertThat(codecCustomizer).isNotNull(); @@ -128,7 +128,7 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldRegisterResourceHandlerMapping() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class); assertThat(hm.getUrlMap().get("/**")).isInstanceOf(ResourceWebHandler.class); @@ -149,7 +149,7 @@ public class WebFluxAutoConfigurationTests { public void shouldMapResourcesToCustomPath() { this.contextRunner .withPropertyValues("spring.webflux.static-path-pattern:/static/**") - .run(context -> { + .run((context) -> { SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class); assertThat(hm.getUrlMap().get("/static/**")) @@ -163,16 +163,14 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldNotMapResourcesWhenDisabled() { this.contextRunner.withPropertyValues("spring.resources.add-mappings:false") - .run(context -> { - assertThat(context.getBean("resourceHandlerMapping")) - .isNotInstanceOf(SimpleUrlHandlerMapping.class); - }); + .run((context) -> assertThat(context.getBean("resourceHandlerMapping")) + .isNotInstanceOf(SimpleUrlHandlerMapping.class)); } @Test public void resourceHandlerChainEnabled() { this.contextRunner.withPropertyValues("spring.resources.chain.enabled:true") - .run(context -> { + .run((context) -> { SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class); assertThat(hm.getUrlMap().get("/**")) @@ -191,7 +189,7 @@ public class WebFluxAutoConfigurationTests { @Test public void shouldRegisterViewResolvers() { - this.contextRunner.withUserConfiguration(ViewResolvers.class).run(context -> { + this.contextRunner.withUserConfiguration(ViewResolvers.class).run((context) -> { ViewResolutionResultHandler resultHandler = context .getBean(ViewResolutionResultHandler.class); assertThat(resultHandler.getViewResolvers()).containsExactly( @@ -226,7 +224,7 @@ public class WebFluxAutoConfigurationTests { @Test public void validatorWhenNoValidatorShouldUseDefault() { - this.contextRunner.run(context -> { + this.contextRunner.run((context) -> { assertThat(context).doesNotHaveBean(ValidatorFactory.class); assertThat(context).doesNotHaveBean(javax.validation.Validator.class); assertThat(context).getBeanNames(Validator.class) @@ -239,7 +237,7 @@ public class WebFluxAutoConfigurationTests { this.contextRunner .withConfiguration( AutoConfigurations.of(ValidationAutoConfiguration.class)) - .run(context -> { + .run((context) -> { assertThat(context).getBeanNames(javax.validation.Validator.class) .containsExactly("defaultValidator"); assertThat(context).getBeanNames(Validator.class) @@ -261,7 +259,7 @@ public class WebFluxAutoConfigurationTests { @Test public void validatorWithConfigurerShouldUseSpringValidator() { this.contextRunner.withUserConfiguration(ValidatorWebFluxConfigurer.class) - .run(context -> { + .run((context) -> { assertThat(context).doesNotHaveBean(ValidatorFactory.class); assertThat(context).doesNotHaveBean(javax.validation.Validator.class); assertThat(context).getBeanNames(Validator.class) @@ -274,7 +272,7 @@ public class WebFluxAutoConfigurationTests { @Test public void validatorWithConfigurerDoesNotExposeJsr303() { this.contextRunner.withUserConfiguration(ValidatorJsr303WebFluxConfigurer.class) - .run(context -> { + .run((context) -> { assertThat(context).doesNotHaveBean(ValidatorFactory.class); assertThat(context).doesNotHaveBean(javax.validation.Validator.class); assertThat(context).getBeanNames(Validator.class) @@ -293,7 +291,8 @@ public class WebFluxAutoConfigurationTests { this.contextRunner .withConfiguration( AutoConfigurations.of(ValidationAutoConfiguration.class)) - .withUserConfiguration(ValidatorWebFluxConfigurer.class).run(context -> { + .withUserConfiguration(ValidatorWebFluxConfigurer.class) + .run((context) -> { assertThat(context).getBeans(ValidatorFactory.class).hasSize(1); assertThat(context).getBeans(javax.validation.Validator.class) .hasSize(1); @@ -315,7 +314,7 @@ public class WebFluxAutoConfigurationTests { this.contextRunner .withConfiguration( AutoConfigurations.of(ValidationAutoConfiguration.class)) - .withUserConfiguration(CustomSpringValidator.class).run(context -> { + .withUserConfiguration(CustomSpringValidator.class).run((context) -> { assertThat(context).getBeanNames(javax.validation.Validator.class) .containsExactly("defaultValidator"); assertThat(context).getBeanNames(Validator.class) @@ -337,7 +336,7 @@ public class WebFluxAutoConfigurationTests { @Test public void validatorWithCustomJsr303ValidatorExposedAsSpringValidator() { this.contextRunner.withUserConfiguration(CustomJsr303Validator.class) - .run(context -> { + .run((context) -> { assertThat(context).doesNotHaveBean(ValidatorFactory.class); assertThat(context).getBeanNames(javax.validation.Validator.class) .containsExactly("customValidator"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java index 05c4c820bde..e136e358800 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java @@ -57,11 +57,14 @@ import static org.hamcrest.Matchers.not; public class DefaultErrorWebExceptionHandlerIntegrationTests { private ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ReactiveWebServerAutoConfiguration.class, + .withConfiguration(AutoConfigurations.of( + ReactiveWebServerAutoConfiguration.class, HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class, ErrorWebFluxAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class, MustacheAutoConfiguration.class)) - .withPropertyValues("spring.main.web-application-type=reactive", "server.port=0") + PropertyPlaceholderAutoConfiguration.class, + MustacheAutoConfiguration.class)) + .withPropertyValues("spring.main.web-application-type=reactive", + "server.port=0") .withUserConfiguration(Application.class); @Rule @@ -72,8 +75,9 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { @Test public void jsonError() throws Exception { - this.contextRunner.run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.get().uri("/").exchange().expectStatus() .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR).expectBody() .jsonPath("status").isEqualTo("500").jsonPath("error") @@ -88,8 +92,9 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { @Test public void notFound() throws Exception { - this.contextRunner.run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.get().uri("/notFound").exchange().expectStatus() .isEqualTo(HttpStatus.NOT_FOUND).expectBody().jsonPath("status") .isEqualTo("404").jsonPath("error") @@ -100,12 +105,13 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { @Test public void htmlError() throws Exception { - this.contextRunner.run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); - String body = client.get().uri("/").accept(MediaType.TEXT_HTML) - .exchange().expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) - .expectHeader().contentType(MediaType.TEXT_HTML).expectBody(String.class) - .returnResult().getResponseBody(); + this.contextRunner.run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); + String body = client.get().uri("/").accept(MediaType.TEXT_HTML).exchange() + .expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) + .expectHeader().contentType(MediaType.TEXT_HTML) + .expectBody(String.class).returnResult().getResponseBody(); assertThat(body).contains("status: 500").contains("message: Expected!"); this.output.expect(allOf(containsString("Failed to handle request [GET /]"), containsString("IllegalStateException"))); @@ -114,8 +120,9 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { @Test public void bindingResultError() throws Exception { - this.contextRunner.run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON) .syncBody("{}").exchange().expectStatus() .isEqualTo(HttpStatus.BAD_REQUEST).expectBody().jsonPath("status") @@ -131,45 +138,47 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { this.contextRunner .withPropertyValues("server.error.include-exception=true", "server.error.include-stacktrace=on-trace-param") - .run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + .run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.get().uri("/?trace=true").exchange().expectStatus() .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR).expectBody() .jsonPath("status").isEqualTo("500").jsonPath("error") .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()) - .jsonPath("exception").isEqualTo(IllegalStateException.class.getName()) + .jsonPath("exception") + .isEqualTo(IllegalStateException.class.getName()) .jsonPath("trace").exists(); }); } @Test public void alwaysIncludeStackTrace() throws Exception { - this.contextRunner - .withPropertyValues("server.error.include-exception=true", - "server.error.include-stacktrace=always") - .run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.withPropertyValues("server.error.include-exception=true", + "server.error.include-stacktrace=always").run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.get().uri("/?trace=false").exchange().expectStatus() .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR).expectBody() .jsonPath("status").isEqualTo("500").jsonPath("error") .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()) - .jsonPath("exception").isEqualTo(IllegalStateException.class.getName()) + .jsonPath("exception") + .isEqualTo(IllegalStateException.class.getName()) .jsonPath("trace").exists(); }); } @Test public void neverIncludeStackTrace() throws Exception { - this.contextRunner - .withPropertyValues("server.error.include-exception=true", - "server.error.include-stacktrace=never") - .run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.withPropertyValues("server.error.include-exception=true", + "server.error.include-stacktrace=never").run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.get().uri("/?trace=true").exchange().expectStatus() .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR).expectBody() .jsonPath("status").isEqualTo("500").jsonPath("error") .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()) - .jsonPath("exception").isEqualTo(IllegalStateException.class.getName()) + .jsonPath("exception") + .isEqualTo(IllegalStateException.class.getName()) .jsonPath("trace").doesNotExist(); }); @@ -177,14 +186,15 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { @Test public void statusException() throws Exception { - this.contextRunner - .withPropertyValues("server.error.include-exception=true") - .run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.withPropertyValues("server.error.include-exception=true") + .run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); client.get().uri("/badRequest").exchange().expectStatus() - .isEqualTo(HttpStatus.BAD_REQUEST).expectBody().jsonPath("status") - .isEqualTo("400").jsonPath("error") - .isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()).jsonPath("exception") + .isEqualTo(HttpStatus.BAD_REQUEST).expectBody() + .jsonPath("status").isEqualTo("400").jsonPath("error") + .isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()) + .jsonPath("exception") .isEqualTo(ResponseStatusException.class.getName()); this.output.expect(not(containsString("ResponseStatusException"))); }); @@ -194,27 +204,31 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests { public void defaultErrorView() throws Exception { this.contextRunner .withPropertyValues("spring.mustache.prefix=classpath:/unknown/") - .run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + .run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); String body = client.get().uri("/").accept(MediaType.TEXT_HTML) - .exchange().expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) - .expectHeader().contentType(MediaType.TEXT_HTML).expectBody(String.class) + .exchange().expectStatus() + .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR).expectHeader() + .contentType(MediaType.TEXT_HTML).expectBody(String.class) .returnResult().getResponseBody(); assertThat(body).contains("Whitelabel Error Page") .contains("
Expected!
"); - this.output.expect(allOf(containsString("Failed to handle request [GET /]"), - containsString("IllegalStateException"))); + this.output.expect( + allOf(containsString("Failed to handle request [GET /]"), + containsString("IllegalStateException"))); }); } @Test public void responseCommitted() throws Exception { - this.contextRunner.run(context -> { - WebTestClient client = WebTestClient.bindToApplicationContext(context).build(); + this.contextRunner.run((context) -> { + WebTestClient client = WebTestClient.bindToApplicationContext(context) + .build(); this.thrown.expectCause(instanceOf(IllegalStateException.class)); this.thrown.expectMessage("already committed!"); - client.get().uri("/commit").exchange().expectStatus() - .isEqualTo(HttpStatus.OK).expectBody().isEmpty(); + client.get().uri("/commit").exchange().expectStatus().isEqualTo(HttpStatus.OK) + .expectBody().isEmpty(); }); } diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/autoconfigure/UserServiceAutoConfigurationTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/autoconfigure/UserServiceAutoConfigurationTests.java index 3b1278eb54b..8fe267d8751 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/autoconfigure/UserServiceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/autoconfigure/UserServiceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,17 +35,15 @@ public class UserServiceAutoConfigurationTests { // tag::runner[] private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class)); - // end::runner[] + // end::runner[] // tag::test-env[] @Test public void serviceNameCanBeConfigured() { - this.contextRunner.withPropertyValues("user.name=test123") - .run((context) -> { - assertThat(context).hasSingleBean(UserService.class); - assertThat(context.getBean(UserService.class).getName()) - .isEqualTo("test123"); - }); + this.contextRunner.withPropertyValues("user.name=test123").run((context) -> { + assertThat(context).hasSingleBean(UserService.class); + assertThat(context.getBean(UserService.class).getName()).isEqualTo("test123"); + }); } // end::test-env[] @@ -53,13 +51,10 @@ public class UserServiceAutoConfigurationTests { @Test public void serviceIsIgnoredIfLibraryIsNotPresent() { this.contextRunner.withClassLoader(new FilteredClassLoader(UserService.class)) - .run((context) -> { - assertThat(context).doesNotHaveBean("userService"); - }); + .run((context) -> assertThat(context).doesNotHaveBean("userService")); } // end::test-classloader[] - // tag::test-user-config[] @Test public void defaultServiceBacksOff() { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/DockerTestContainer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/DockerTestContainer.java index 25e8d3d7817..da5b096a523 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/DockerTestContainer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/DockerTestContainer.java @@ -26,12 +26,13 @@ import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.GenericContainer; /** - * {@link TestRule} for working with an optional Docker environment. Spins up a {@link GenericContainer} - * if a valid docker environment is found. + * {@link TestRule} for working with an optional Docker environment. Spins up a + * {@link GenericContainer} if a valid docker environment is found. * + * @param the type of the container * @author Madhura Bhave */ -public class DockerTestContainer implements TestRule { +public class DockerTestContainer> implements TestRule { private Supplier containerSupplier; @@ -60,4 +61,3 @@ public class DockerTestContainer implements TestRule } } - diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java index 5ded2a84e8c..79c17aeaba0 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.boot.test.autoconfigure.data.neo4j; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; import org.junit.ClassRule; import org.junit.Rule; @@ -31,7 +30,6 @@ import org.neo4j.ogm.session.SessionFactory; import org.rnorth.ducttape.TimeoutException; import org.rnorth.ducttape.unreliables.Unreliables; import org.testcontainers.containers.FixedHostPortGenericContainer; -import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.HostPortWaitStrategy; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -53,10 +51,11 @@ import static org.assertj.core.api.Assertions.assertThat; public class DataNeo4jTestIntegrationTests { @ClassRule - public static DockerTestContainer genericContainer = new DockerTestContainer<>((Supplier) () -> new FixedHostPortGenericContainer("neo4j:latest") - .withFixedExposedPort(7687, 7687) - .waitingFor(new ConnectionVerifyingWaitStrategy()).withEnv("NEO4J_AUTH", "none")); - + public static DockerTestContainer> neo4j = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("neo4j:latest") + .withFixedExposedPort(7687, 7687) + .waitingFor(new ConnectionVerifyingWaitStrategy()) + .withEnv("NEO4J_AUTH", "none")); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -96,8 +95,8 @@ public class DataNeo4jTestIntegrationTests { SessionFactory sessionFactory = new SessionFactory(configuration, "org.springframework.boot.test.autoconfigure.data.neo4j"); try { - Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, - checkConnection(sessionFactory)); + Unreliables.retryUntilTrue((int) this.startupTimeout.getSeconds(), + TimeUnit.SECONDS, checkConnection(sessionFactory)); } catch (TimeoutException e) { throw new IllegalStateException(); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java index 0e18c46b1c6..30a4e82ceac 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,10 @@ package org.springframework.boot.test.autoconfigure.data.neo4j; -import java.util.function.Supplier; - import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; import org.testcontainers.containers.FixedHostPortGenericContainer; -import org.testcontainers.containers.GenericContainer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.DockerTestContainer; @@ -42,9 +39,12 @@ import static org.assertj.core.api.Assertions.assertThat; public class DataNeo4jTestWithIncludeFilterIntegrationTests { @ClassRule - public static DockerTestContainer genericContainer = new DockerTestContainer<>((Supplier) () -> new FixedHostPortGenericContainer("neo4j:latest") - .withFixedExposedPort(7687, 7687) - .waitingFor(new DataNeo4jTestIntegrationTests.ConnectionVerifyingWaitStrategy()).withEnv("NEO4J_AUTH", "none")); + public static DockerTestContainer> neo4j = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("neo4j:latest") + .withFixedExposedPort(7687, 7687) + .waitingFor( + new DataNeo4jTestIntegrationTests.ConnectionVerifyingWaitStrategy()) + .withEnv("NEO4J_AUTH", "none")); @Autowired private ExampleService service; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java index 567019cabc1..0b0bbef90d0 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class DataRedisTestIntegrationTests { @ClassRule - public static DockerTestContainer redis = new DockerTestContainer<>(() -> - new FixedHostPortGenericContainer("redis:latest") + public static DockerTestContainer> redis = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("redis:latest") .withFixedExposedPort(6379, 6379)); @Rule diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java index a787577fc9f..98ea0079892 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class DataRedisTestWithIncludeFilterIntegrationTests { @ClassRule - public static DockerTestContainer redis = new DockerTestContainer<>(() -> - new FixedHostPortGenericContainer("redis:latest") + public static DockerTestContainer> redis = new DockerTestContainer<>( + () -> new FixedHostPortGenericContainer<>("redis:latest") .withFixedExposedPort(6379, 6379)); @Autowired diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index a1084bdf2e4..f09298c129d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -422,8 +422,9 @@ public class ConfigFileApplicationListener } private boolean canLoadFileExtension(PropertySourceLoader loader, String name) { - return Arrays.stream(loader.getFileExtensions()).anyMatch( - fileExtension -> StringUtils.endsWithIgnoreCase(name, fileExtension)); + return Arrays.stream(loader.getFileExtensions()) + .anyMatch((fileExtension) -> StringUtils.endsWithIgnoreCase(name, + fileExtension)); } private void loadForFileExtension(PropertySourceLoader loader, Profile profile,