Testcontainers Java sample: fix test assertions and wait loop, modernize JDBC/JUnit, and clean up POM
Test stability and correctness
-
Add a small sleep and a timeout in the “wait until DB is available” loop to avoid busy-waiting forever on a failing setup.
-
Fix assertEquals argument order (expected first, then actual) in TestRDS.
Code hygiene
-
Use try-with-resources for Statement and ResultSet in RDS.test_connection to ensure they are reliably closed.
Dependency updates and cleanups (in pom.xml)
-
Remove duplicate software.amazon.awssdk:s3 entry.
-
Remove unused AWS SDK v1 test dependency (com.amazonaws:aws-java-sdk-s3). Project already uses AWS SDK v2.
-
Update JUnit 4 to 4.13.2 (latest 4.x) to address old CVEs.
-
Update PostgreSQL JDBC driver to a modern version (e.g., 42.7.4).
-
Optionally update Testcontainers LocalStack module and AWS SDK v2 BOM to recent stable versions.
README
-
Add direct CLI instructions to run the test without an IDE (mvn -q -Dtest=TestRDS test).
-
Explicitly document prerequisites (Docker running, LocalStack Pro token) and how credentials are provided in the test.