mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.3.x'
Closes gh-24108
This commit is contained in:
commit
515b18e142
@ -37,6 +37,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -83,6 +84,10 @@ class CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests {
|
||||
static final class PasswordAuthenticatorCassandraContainer
|
||||
extends CassandraContainer<PasswordAuthenticatorCassandraContainer> {
|
||||
|
||||
PasswordAuthenticatorCassandraContainer() {
|
||||
super(DockerImageNames.cassandra().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void containerIsCreated(String containerId) {
|
||||
String config = this.copyFileFromContainer("/etc/cassandra/cassandra.yaml",
|
||||
|
@ -31,6 +31,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -46,8 +47,8 @@ class CouchbaseAutoConfigurationIntegrationTests {
|
||||
private static final String BUCKET_NAME = "cbbucket";
|
||||
|
||||
@Container
|
||||
static final CouchbaseContainer couchbase = new CouchbaseContainer().withCredentials("spring", "password")
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10))
|
||||
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase().toString())
|
||||
.withCredentials("spring", "password").withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10))
|
||||
.withBucket(new BucketDefinition(BUCKET_NAME).withPrimaryIndex(false));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.cassandra.config.SchemaAction;
|
||||
@ -48,8 +49,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class CassandraDataAutoConfigurationIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final CassandraContainer<?> cassandra = new CassandraContainer<>().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final CassandraContainer<?> cassandra = new CassandraContainer<>(DockerImageNames.cassandra().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityReposi
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
@ -48,8 +49,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Container
|
||||
static final ElasticsearchContainer elasticsearch = new VersionOverridingElasticsearchContainer()
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(
|
||||
DockerImageNames.elasticsearch().toString()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(ElasticsearchRestClientAutoConfiguration.class,
|
||||
|
@ -30,6 +30,7 @@ import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.ReactiveCityRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;
|
||||
@ -47,8 +48,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class ReactiveElasticsearchRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Container
|
||||
static ElasticsearchContainer elasticsearch = new VersionOverridingElasticsearchContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer(
|
||||
DockerImageNames.elasticsearch().toString()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(ReactiveElasticsearchRestClientAutoConfiguration.class,
|
||||
|
@ -30,6 +30,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
||||
@ -47,8 +48,9 @@ import static org.mockito.Mockito.mock;
|
||||
public class ReactiveElasticsearchRestClientAutoConfigurationTests {
|
||||
|
||||
@Container
|
||||
static ElasticsearchContainer elasticsearch = new VersionOverridingElasticsearchContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer(
|
||||
DockerImageNames.elasticsearch().toString()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(ReactiveElasticsearchRestClientAutoConfiguration.class));
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.data.elasticsearch;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.testcontainers.elasticsearch.ElasticsearchContainer;
|
||||
|
||||
/**
|
||||
* Extension of {@link ElasticsearchContainer} to override default version.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class VersionOverridingElasticsearchContainer extends ElasticsearchContainer {
|
||||
|
||||
/**
|
||||
* Elasticsearch Docker base URL
|
||||
*/
|
||||
private static final String ELASTICSEARCH_IMAGE = "docker.elastic.co/elasticsearch/elasticsearch";
|
||||
|
||||
/**
|
||||
* Elasticsearch version
|
||||
*/
|
||||
protected static final String ELASTICSEARCH_VERSION = Version.CURRENT.toString();
|
||||
|
||||
public VersionOverridingElasticsearchContainer() {
|
||||
super(ELASTICSEARCH_IMAGE + ":" + ELASTICSEARCH_VERSION);
|
||||
}
|
||||
|
||||
}
|
@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.neo4j.country.CountryRepository;
|
||||
import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
@ -43,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class Neo4jRepositoriesAutoConfigurationIntegrationTests {
|
||||
|
||||
@Container
|
||||
private static final Neo4jContainer<?> neo4jServer = new Neo4jContainer<>("neo4j:4.0");
|
||||
private static final Neo4jContainer<?> neo4jServer = new Neo4jContainer<>(DockerImageNames.neo4j().toString());
|
||||
|
||||
@DynamicPropertySource
|
||||
static void neo4jProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -41,6 +41,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -58,8 +59,9 @@ import static org.mockito.Mockito.mock;
|
||||
class ElasticsearchRestClientAutoConfigurationTests {
|
||||
|
||||
@Container
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(
|
||||
DockerImageNames.elasticsearch().toString()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(ElasticsearchRestClientAutoConfiguration.class));
|
||||
|
@ -28,6 +28,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
@ -45,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class Neo4jAutoConfigurationIntegrationTests {
|
||||
|
||||
@Container
|
||||
private static final Neo4jContainer<?> neo4jServer = new Neo4jContainer<>("neo4j:4.0");
|
||||
private static final Neo4jContainer<?> neo4jServer = new Neo4jContainer<>(DockerImageNames.neo4j().toString());
|
||||
|
||||
@DynamicPropertySource
|
||||
static void neo4jProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.ContextConsumer;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
|
||||
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
|
||||
import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository;
|
||||
@ -47,8 +48,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class SessionAutoConfigurationMongoTests extends AbstractSessionAutoConfigurationTests {
|
||||
|
||||
@Container
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class, MongoDataAutoConfiguration.class,
|
||||
|
@ -30,6 +30,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.redis.ExampleService;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||
@ -52,8 +53,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataCassandraTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final CassandraContainer<?> cassandra = new CassandraContainer<>().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final CassandraContainer<?> cassandra = new CassandraContainer<>(DockerImageNames.cassandra().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@DynamicPropertySource
|
||||
static void cassandraProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -28,6 +28,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -51,8 +52,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataCassandraTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final CassandraContainer<?> cassandra = new CassandraContainer<>().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final CassandraContainer<?> cassandra = new CassandraContainer<>(DockerImageNames.cassandra().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@DynamicPropertySource
|
||||
static void cassandraProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -25,6 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
@ -43,8 +44,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataMongoTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
@ -24,6 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
@ -40,8 +41,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataMongoTestReactiveIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
@Autowired
|
||||
private ReactiveMongoTemplate mongoTemplate;
|
||||
|
@ -24,6 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
@ -41,8 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataMongoTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
@Autowired
|
||||
private ExampleService service;
|
||||
|
@ -26,6 +26,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoTransactionManager;
|
||||
@ -47,8 +48,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class TransactionalDataMongoTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo().toString())
|
||||
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
@Autowired
|
||||
private ExampleRepository exampleRepository;
|
||||
|
@ -25,6 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.neo4j.core.Neo4jTemplate;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
@ -45,8 +46,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataNeo4jTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>().withoutAuthentication()
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j().toString())
|
||||
.withoutAuthentication().withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@DynamicPropertySource
|
||||
static void neo4jProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -24,6 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
@ -41,8 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataNeo4jTestPropertiesIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>().withoutAuthentication()
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j().toString())
|
||||
.withoutAuthentication().withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@DynamicPropertySource
|
||||
static void neo4jProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -29,6 +29,7 @@ import reactor.test.StepVerifier;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider;
|
||||
@ -54,8 +55,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataNeo4jTestReactiveIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>("neo4j:4.0").withoutAuthentication()
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j().toString())
|
||||
.withoutAuthentication().withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@DynamicPropertySource
|
||||
static void neo4jProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -24,6 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
@ -42,8 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataNeo4jTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>().withoutAuthentication()
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j().toString())
|
||||
.withoutAuthentication().withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@DynamicPropertySource
|
||||
static void neo4jProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -37,6 +37,7 @@ import org.springframework.boot.buildpack.platform.docker.type.Image;
|
||||
import org.springframework.boot.buildpack.platform.docker.type.ImageReference;
|
||||
import org.springframework.boot.gradle.junit.GradleCompatibility;
|
||||
import org.springframework.boot.gradle.testkit.GradleBuild;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -104,7 +105,7 @@ public class BootBuildImageRegistryIntegrationTests {
|
||||
private static class RegistryContainer extends GenericContainer<RegistryContainer> {
|
||||
|
||||
RegistryContainer() {
|
||||
super("registry:2.7.1");
|
||||
super(DockerImageNames.registry().toString());
|
||||
addExposedPorts(5000);
|
||||
addEnv("SERVER_NAME", "localhost");
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.buildpack.platform.docker.DockerApi;
|
||||
import org.springframework.boot.buildpack.platform.docker.UpdateListener;
|
||||
import org.springframework.boot.buildpack.platform.docker.type.Image;
|
||||
import org.springframework.boot.buildpack.platform.docker.type.ImageReference;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -79,7 +80,7 @@ public class BuildImageRegistryIntegrationTests extends AbstractArchiveIntegrati
|
||||
private static class RegistryContainer extends GenericContainer<RegistryContainer> {
|
||||
|
||||
RegistryContainer() {
|
||||
super("registry:2.7.1");
|
||||
super(DockerImageNames.registry().toString());
|
||||
addExposedPorts(5000);
|
||||
addEnv("SERVER_NAME", "localhost");
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ dependencies {
|
||||
compileOnly("com.datastax.oss:java-driver-core")
|
||||
compileOnly("javax.servlet:javax.servlet-api")
|
||||
compileOnly("junit:junit")
|
||||
compileOnly("org.elasticsearch:elasticsearch")
|
||||
compileOnly("org.junit.jupiter:junit-jupiter")
|
||||
compileOnly("org.junit.platform:junit-platform-engine")
|
||||
compileOnly("org.mockito:mockito-core")
|
||||
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.testsupport.testcontainers;
|
||||
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
|
||||
/**
|
||||
* Create {@link DockerImageName} instances for services used in integration tests.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.3.6
|
||||
*/
|
||||
public final class DockerImageNames {
|
||||
|
||||
private static final String CASSANDRA_VERSION = "3.11.2";
|
||||
|
||||
private static final String COUCHBASE_VERSION = "6.5.1";
|
||||
|
||||
private static final String MONGO_VERSION = "4.0.10";
|
||||
|
||||
private static final String NEO4J_VERSION = "4.0";
|
||||
|
||||
private static final String POSTGRESQL_VERSION = "9.6.12";
|
||||
|
||||
private static final String REDIS_VERSION = "4.0.6";
|
||||
|
||||
private static final String REGISTRY_VERSION = "2.7.1";
|
||||
|
||||
private DockerImageNames() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running Cassandra.
|
||||
* @return a docker image name for running cassandra
|
||||
*/
|
||||
public static DockerImageName cassandra() {
|
||||
return new DockerImageName("cassandra", CASSANDRA_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running Cassandra.
|
||||
* @return a docker image name for running cassandra
|
||||
*/
|
||||
public static DockerImageName couchbase() {
|
||||
return new DockerImageName("couchbase/server", COUCHBASE_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running Elasticsearch according to
|
||||
* the version available on the classpath.
|
||||
* @return a docker image name for running elasticsearch
|
||||
*/
|
||||
public static DockerImageName elasticsearch() {
|
||||
String version = org.elasticsearch.Version.CURRENT.toString();
|
||||
return new DockerImageName("docker.elastic.co/elasticsearch/elasticsearch", version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running Mongo.
|
||||
* @return a docker image name for running mongo
|
||||
*/
|
||||
public static DockerImageName mongo() {
|
||||
return new DockerImageName("mongo", MONGO_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running Neo4j.
|
||||
* @return a docker image name for running neo4j
|
||||
*/
|
||||
public static DockerImageName neo4j() {
|
||||
return new DockerImageName("neo4j", NEO4J_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running PostgreSQL.
|
||||
* @return a docker image name for running postgresql
|
||||
*/
|
||||
public static DockerImageName postgresql() {
|
||||
return new DockerImageName("postgres", POSTGRESQL_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running Redis.
|
||||
* @return a docker image name for running redis
|
||||
*/
|
||||
public static DockerImageName redis() {
|
||||
return new DockerImageName("redis", REDIS_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link DockerImageName} suitable for running a Docker registry.
|
||||
* @return a docker image name for running a registry
|
||||
*/
|
||||
public static DockerImageName registry() {
|
||||
return new DockerImageName("registry", REGISTRY_VERSION);
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@ import org.testcontainers.containers.GenericContainer;
|
||||
public class RedisContainer extends GenericContainer<RedisContainer> {
|
||||
|
||||
public RedisContainer() {
|
||||
super("redis:4.0.6");
|
||||
super(DockerImageNames.redis().toString());
|
||||
addExposedPorts(6379);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ dependencies {
|
||||
runtimeOnly("org.springframework:spring-jdbc")
|
||||
|
||||
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("org.testcontainers:junit-jupiter")
|
||||
testImplementation("org.testcontainers:postgresql")
|
||||
|
@ -24,6 +24,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
@ -37,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class CityRepositoryTests {
|
||||
|
||||
@Container
|
||||
static PostgreSQLContainer<?> postgresql = new PostgreSQLContainer<>().withDatabaseName("test_flyway");
|
||||
static PostgreSQLContainer<?> postgresql = new PostgreSQLContainer<>(DockerImageNames.postgresql().toString())
|
||||
.withDatabaseName("test_flyway");
|
||||
|
||||
@DynamicPropertySource
|
||||
static void postgresqlProperties(DynamicPropertyRegistry registry) {
|
||||
|
@ -14,6 +14,7 @@ dependencies {
|
||||
runtimeOnly("org.springframework:spring-jdbc")
|
||||
|
||||
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("org.testcontainers:junit-jupiter")
|
||||
testImplementation("org.testcontainers:postgresql")
|
||||
|
@ -24,6 +24,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
@ -37,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class CityRepositoryTests {
|
||||
|
||||
@Container
|
||||
static PostgreSQLContainer<?> postgresql = new PostgreSQLContainer<>().withDatabaseName("test_liquibase");
|
||||
static PostgreSQLContainer<?> postgresql = new PostgreSQLContainer<>(DockerImageNames.postgresql().toString())
|
||||
.withDatabaseName("test_liquibase");
|
||||
|
||||
@DynamicPropertySource
|
||||
static void postgresqlProperties(DynamicPropertyRegistry registry) {
|
||||
|
Loading…
Reference in New Issue
Block a user