Skip to content

Commit 5123eb0

Browse files
committed
Fix deprecation in Testcontainers 1.15.0
See gh-24103
1 parent c1a1b5f commit 5123eb0

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.junit.jupiter.api.Test;
2929
import org.rnorth.ducttape.TimeoutException;
3030
import org.rnorth.ducttape.unreliables.Unreliables;
31-
import org.testcontainers.containers.CassandraContainer;
3231
import org.testcontainers.containers.ContainerLaunchException;
3332
import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
3433
import org.testcontainers.images.builder.Transferable;
@@ -37,6 +36,7 @@
3736

3837
import org.springframework.boot.autoconfigure.AutoConfigurations;
3938
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
39+
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
4040
import org.springframework.util.StreamUtils;
4141

4242
import static org.assertj.core.api.Assertions.assertThat;
@@ -51,7 +51,7 @@
5151
class CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests {
5252

5353
@Container
54-
static final CassandraContainer<?> cassandra = new PasswordAuthenticatorCassandraContainer().withStartupAttempts(5)
54+
static final CassandraContainer cassandra = new PasswordAuthenticatorCassandraContainer().withStartupAttempts(5)
5555
.withStartupTimeout(Duration.ofMinutes(10)).waitingFor(new CassandraWaitStrategy());
5656

5757
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
@@ -80,8 +80,7 @@ void authenticationWithInvalidCredentials() {
8080
.hasMessageContaining("Authentication error"));
8181
}
8282

83-
static final class PasswordAuthenticatorCassandraContainer
84-
extends CassandraContainer<PasswordAuthenticatorCassandraContainer> {
83+
static final class PasswordAuthenticatorCassandraContainer extends CassandraContainer {
8584

8685
@Override
8786
protected void containerIsCreated(String containerId) {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.datastax.oss.driver.api.core.CqlSession;
2222
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
2323
import org.junit.jupiter.api.Test;
24-
import org.testcontainers.containers.CassandraContainer;
2524
import org.testcontainers.junit.jupiter.Container;
2625
import org.testcontainers.junit.jupiter.Testcontainers;
2726

@@ -31,6 +30,7 @@
3130
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
3231
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
3332
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
33+
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
3434
import org.springframework.context.annotation.Bean;
3535
import org.springframework.context.annotation.Configuration;
3636
import org.springframework.data.cassandra.config.SchemaAction;
@@ -48,7 +48,7 @@
4848
class CassandraDataAutoConfigurationIntegrationTests {
4949

5050
@Container
51-
static final CassandraContainer<?> cassandra = new CassandraContainer<>().withStartupAttempts(5)
51+
static final CassandraContainer cassandra = new CassandraContainer().withStartupAttempts(5)
5252
.withStartupTimeout(Duration.ofMinutes(10));
5353

5454
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies {
1818
compileOnly("org.neo4j:neo4j-ogm-core")
1919
compileOnly("org.springframework:spring-context")
2020
compileOnly("org.springframework.data:spring-data-redis")
21+
compileOnly("org.testcontainers:cassandra")
2122
compileOnly("org.testcontainers:elasticsearch")
2223
compileOnly("org.testcontainers:testcontainers")
2324

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2012-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.testsupport.testcontainers;
18+
19+
import org.testcontainers.utility.DockerImageName;
20+
21+
/**
22+
* Extension of {@link org.testcontainers.containers.CassandraContainer} that provides a
23+
* default version.
24+
*
25+
* @author Stephane Nicoll
26+
* @since 2.3.6
27+
*/
28+
public class CassandraContainer extends org.testcontainers.containers.CassandraContainer<CassandraContainer> {
29+
30+
public CassandraContainer() {
31+
super(DockerImageName.parse("cassandra").withTag("3.11.2"));
32+
}
33+
34+
}

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/VersionOverridingElasticsearchContainer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
* Extension of {@link ElasticsearchContainer} to override default version.
2323
*
2424
* @author Scott Frederick
25+
* @since 2.3.6
2526
*/
2627
public class VersionOverridingElasticsearchContainer extends ElasticsearchContainer {
2728

2829
/**
29-
* Elasticsearch Docker base URL
30+
* Elasticsearch Docker base URL.
3031
*/
3132
private static final String ELASTICSEARCH_IMAGE = "docker.elastic.co/elasticsearch/elasticsearch";
3233

3334
/**
34-
* Elasticsearch version
35+
* Elasticsearch version.
3536
*/
3637
protected static final String ELASTICSEARCH_VERSION = Version.CURRENT.toString();
3738

0 commit comments

Comments
 (0)