feat(cassandra): modernize test infrastructure with Spring Boot Testcontainers#32658
Open
CharlesWong wants to merge 1 commit intojhipster:mainfrom
Open
feat(cassandra): modernize test infrastructure with Spring Boot Testcontainers#32658CharlesWong wants to merge 1 commit intojhipster:mainfrom
CharlesWong wants to merge 1 commit intojhipster:mainfrom
Conversation
…Boot Testcontainers (jhipster#21466) The old Cassandra test infrastructure used: - CassandraTestContainersSpringContextCustomizerFactory (ContextCustomizerFactory pattern) - EmbeddedCassandra annotation - Registered via spring.factories - Old Cassandra driver 3.x API (getCluster().getMetadata().getAllHosts()) Replace with the modern Spring Boot Testcontainers approach (consistent with how MongoDB, Couchbase, and Neo4j are handled): - CassandraTestContainer is now an interface with @container + @DynamicPropertySource - IntegrationTest uses @ImportTestcontainers(CassandraTestContainer.class) - spring-boot-testcontainers module added for Spring Boot auto-configuration - Testcontainers cassandra artifact corrected (org.testcontainers:cassandra) - CassandraTestContainersSpringContextCustomizerFactory removed - EmbeddedCassandra annotation removed - cleanup.ts updated to remove old files when upgrading Benefits: - Consistent with JHipster's existing Testcontainers pattern for other databases - Works with reactive Spring Data Cassandra - Uses modern DataStax OSS driver 4.x API (getLocalDatacenter() directly) - No more spring.factories registration needed Closes jhipster#21466
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The existing Cassandra test infrastructure used a custom
ContextCustomizerFactorypattern (CassandraTestContainersSpringContextCustomizerFactory) that:getCluster().getMetadata().getAllHosts())spring.factories(old approach)This was the original issue behind #21466 (CassandraUnit was unmaintained; Testcontainers was introduced but used the old integration pattern).
Solution
Modernize to use Spring Boot's native Testcontainers support, consistent with MongoDB/Couchbase/Neo4j:
CassandraTestContaineris now aninterfacewith@Container+@DynamicPropertySource(same pattern asMongoDbTestContainer)IntegrationTestuses@ImportTestcontainers(CassandraTestContainer.class)instead of@EmbeddedCassandraspring-boot-testcontainersmodule added for Spring Boot auto-configurationCassandraTestContainersSpringContextCustomizerFactoryremovedEmbeddedCassandraannotation removedorg.testcontainers:cassandracleanup.tsupdated to remove old files on upgradeChanges
generator.ts: Addspring-boot-testcontainersmodule; fix Testcontainers artifact tocassandra; use@ImportTestcontainersinstead of old@EmbeddedCassandra; removeaddTestSpringFactorycallfiles.ts: RemoveCassandraTestContainersSpringContextCustomizerFactory.javaandEmbeddedCassandra.javafrom generated filescleanup.ts: Add cleanup for removed files when upgrading from < 9.1.0CassandraTestContainer.java.ejs: Rewritten as interface with@Container+@DynamicPropertySource; uses modern driver 4.x APICassandraTestContainersSpringContextCustomizerFactory.java.ejs: DeletedEmbeddedCassandra.java.ejs: DeletedBefore / After
Before (IntegrationTest.java)
After (IntegrationTest.java)
Benefits
spring.factoriesregistration neededCloses #21466