Use Testcontainers’ CassandraContainer rather than our own
Closes gh-15901
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -22,12 +22,12 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.testcontainers.containers.CassandraContainer;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
|
||||
import org.springframework.data.cassandra.config.SchemaAction;
|
||||
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class CassandraDataAutoConfigurationIntegrationTests {
|
||||
|
||||
@ClassRule
|
||||
public static CassandraContainer cassandra = new CassandraContainer();
|
||||
public static CassandraContainer<?> cassandra = new CassandraContainer<>();
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CassandraDataAutoConfigurationIntegrationTests {
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues
|
||||
.of("spring.data.cassandra.port=" + cassandra.getMappedPort(),
|
||||
.of("spring.data.cassandra.port=" + cassandra.getFirstMappedPort(),
|
||||
"spring.data.cassandra.read-timeout=24000",
|
||||
"spring.data.cassandra.connect-timeout=10000")
|
||||
.applyTo(this.context.getEnvironment());
|
||||
@@ -96,7 +96,8 @@ public class CassandraDataAutoConfigurationIntegrationTests {
|
||||
|
||||
private void createTestKeyspaceIfNotExists() {
|
||||
Cluster cluster = Cluster.builder().withoutJMXReporting()
|
||||
.withPort(cassandra.getMappedPort()).addContactPoint("localhost").build();
|
||||
.withPort(cassandra.getFirstMappedPort()).addContactPoint("localhost")
|
||||
.build();
|
||||
try (Session session = cluster.connect()) {
|
||||
session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
|
||||
+ " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||
|
||||
Reference in New Issue
Block a user