Skip to content

Commit a975c0a

Browse files
committed
Use Testcontainers’ CassandraContainer rather than our own
Closes spring-projectsgh-15901
1 parent 8426d88 commit a975c0a

File tree

3 files changed

+11
-89
lines changed

3 files changed

+11
-89
lines changed

spring-boot-project/spring-boot-autoconfigure/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,11 @@
810810
<artifactId>spring-security-test</artifactId>
811811
<scope>test</scope>
812812
</dependency>
813+
<dependency>
814+
<groupId>org.testcontainers</groupId>
815+
<artifactId>cassandra</artifactId>
816+
<scope>test</scope>
817+
</dependency>
813818
<dependency>
814819
<groupId>org.testcontainers</groupId>
815820
<artifactId>testcontainers</artifactId>

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,12 +22,12 @@
2222
import org.junit.Before;
2323
import org.junit.ClassRule;
2424
import org.junit.Test;
25+
import org.testcontainers.containers.CassandraContainer;
2526

2627
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
2728
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
2829
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
2930
import org.springframework.boot.test.util.TestPropertyValues;
30-
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
3131
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3232
import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
3333
import org.springframework.data.cassandra.config.SchemaAction;
@@ -43,15 +43,15 @@
4343
public class CassandraDataAutoConfigurationIntegrationTests {
4444

4545
@ClassRule
46-
public static CassandraContainer cassandra = new CassandraContainer();
46+
public static CassandraContainer<?> cassandra = new CassandraContainer<>();
4747

4848
private AnnotationConfigApplicationContext context;
4949

5050
@Before
5151
public void setUp() {
5252
this.context = new AnnotationConfigApplicationContext();
5353
TestPropertyValues
54-
.of("spring.data.cassandra.port=" + cassandra.getMappedPort(),
54+
.of("spring.data.cassandra.port=" + cassandra.getFirstMappedPort(),
5555
"spring.data.cassandra.read-timeout=24000",
5656
"spring.data.cassandra.connect-timeout=10000")
5757
.applyTo(this.context.getEnvironment());
@@ -96,7 +96,8 @@ public void hasRecreateSchemaActionSet() {
9696

9797
private void createTestKeyspaceIfNotExists() {
9898
Cluster cluster = Cluster.builder().withoutJMXReporting()
99-
.withPort(cassandra.getMappedPort()).addContactPoint("localhost").build();
99+
.withPort(cassandra.getFirstMappedPort()).addContactPoint("localhost")
100+
.build();
100101
try (Session session = cluster.connect()) {
101102
session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
102103
+ " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");

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

-84
This file was deleted.

0 commit comments

Comments
 (0)