Fix tests failures in the Apache Geode, Inline Caching support Integration Tests involving Apache Cassandra due to the DataStax 4.x Driver upgrade in Spring Data Neumann/2.3.

This commit is contained in:
John Blum
2020-01-22 12:38:23 -08:00
parent 465ea7081b
commit ddafaafe56
3 changed files with 33 additions and 13 deletions

View File

@@ -48,19 +48,34 @@ public abstract class TestCassandraConfiguration extends AbstractCassandraConfig
private static final String CASSANDRA_DATA_CQL = "cassandra-data.cql";
private static final String CASSANDRA_SCHEMA_CQL = "cassandra-schema.cql";
private static final String CLUSTER_NAME = "CustomerServiceCluster";
private static final String LOCAL_DATA_CENTER = "datacenter1";
private static final String KEYSPACE_NAME = "CustomerService";
@Nullable @Override
protected String getClusterName() {
return CLUSTER_NAME;
}
private static final String SESSION_NAME = "CustomerServiceCluster";
@NonNull @Override
protected String getKeyspaceName() {
return KEYSPACE_NAME;
}
@Override
@SuppressWarnings("all")
protected String getLocalDataCenter() {
return LOCAL_DATA_CENTER;
}
@Nullable @Override
protected String getSessionName() {
return SESSION_NAME;
}
/*
@Nullable @Override
protected KeyspacePopulator keyspacePopulator() {
return cqlSession -> loadCassandraCqlScripts().forEach(cqlSession::execute);
}
*/
// TODO: Remove use of deprecation after Spring Data for Apache Cassandra issues are resolved!
@Override
protected List<String> getStartupScripts() {

View File

@@ -22,7 +22,7 @@ import org.springframework.context.annotation.Profile;
import org.testcontainers.containers.GenericContainer;
/**
* Spring {@link @Configuration} for Apache Cassandra.
* Spring {@link @Configuration} for Apache Cassandra using Testcontainers.
*
* @author John Blum
* @see org.springframework.context.annotation.Bean
@@ -34,11 +34,12 @@ import org.testcontainers.containers.GenericContainer;
@Configuration
@Profile("inline-caching-cassandra")
@SuppressWarnings("unused")
public class CassandraConfiguration extends TestCassandraConfiguration {
public class TestcontainersCassandraConfiguration extends TestCassandraConfiguration {
private static final String CASSANDRA_DOCKER_IMAGE_NAME = "cassandra:latest";
@Bean
@SuppressWarnings("rawtypes")
GenericContainer cassandraContainer() {
GenericContainer cassandraContainer = newCassandraContainer()
@@ -49,11 +50,13 @@ public class CassandraConfiguration extends TestCassandraConfiguration {
return cassandraContainer;
}
@SuppressWarnings("rawtypes")
private GenericContainer newCassandraContainer() {
return new GenericContainer(CASSANDRA_DOCKER_IMAGE_NAME);
}
@Override
@SuppressWarnings("all")
protected String getContactPoints() {
return cassandraContainer().getContainerIpAddress();
}

View File

@@ -23,6 +23,7 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
@@ -37,12 +38,12 @@ import org.springframework.geode.cache.inline.AbstractInlineCachingWithExternalD
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import example.app.crm.config.CassandraConfiguration;
import example.app.crm.config.TestcontainersCassandraConfiguration;
import example.app.crm.model.Customer;
import example.app.crm.repo.CustomerRepository;
/**
* Spring Boot Integration Tests testing the Inline Caching support using Apache Cassandra.
* Spring Boot Integration Tests testing Inline Caching support using Apache Cassandra with Apache Geode.
*
* @author John Blum
* @see org.junit.Test
@@ -57,6 +58,7 @@ import example.app.crm.repo.CustomerRepository;
* @see org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions
* @see org.springframework.geode.cache.InlineCachingRegionConfigurer
* @see org.springframework.geode.cache.inline.AbstractInlineCachingWithExternalDataSourceIntegrationTests
* @see org.springframework.test.context.ActiveProfiles
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.1.0
*/
@@ -67,11 +69,11 @@ import example.app.crm.repo.CustomerRepository;
public class InlineCachingWithCassandraIntegrationTests
extends AbstractInlineCachingWithExternalDataSourceIntegrationTests {
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, CassandraDataAutoConfiguration.class })
@ClientCacheApplication(logLevel = GEMFIRE_LOG_LEVEL)
@EnableEntityDefinedRegions(basePackageClasses = Customer.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableCassandraRepositories(basePackageClasses = CustomerRepository.class)
@Import(CassandraConfiguration.class)
@EnableEntityDefinedRegions(basePackageClasses = Customer.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@Import(TestcontainersCassandraConfiguration.class)
static class TestGeodeClientConfiguration {
@Bean