Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

springtainer-example

Release Nightly build Quality Gate Coverage

A runnable Spring Boot application that demonstrates all springtainer embedded test containers working together in one coherent example, and serves as an internal testing ground for the springtainer maintainers when verifying larger changes (so they don't have to reach for an unrelated downstream application).

What it demonstrates

A minimal "Product" flow ties every container together in one realistic path:

  1. POST /products — persists the product in MySQL (springtainer-mysql), indexes it into Elasticsearch (springtainer-elasticsearch), caches it in Redis (springtainer-redis), and publishes a ProductCreatedEvent via RabbitMQ (springtainer-rabbitmq).
  2. A @RabbitListener receives that event (demonstrating RabbitMQ consumption), writes an audit-log entry to MongoDB (springtainer-mongodb), calls an external enrichment endpoint mocked via MockServer (springtainer-mockserver), and uploads the result as a report to AWS S3 Mock (springtainer-awss3mock).
  3. GET /products/{id} — reads through the Redis cache, falling back to MySQL on a miss.
  4. GET /products/search?q=... — full-text search via Elasticsearch.
  5. GET /products/{id}/audit-log — reads the audit trail from MongoDB.
  6. GET /products/{id}/report — downloads the generated report from AWS S3 Mock.

All seven containers start automatically as soon as the application context comes up - no external infrastructure or Docker Compose file needed.

Running it

mvn spring-boot:run

Or, after mvn clean install, run the packaged executable jar directly (note the -exec classifier - the plain springtainer-example.jar is the non-executable artifact used internally by the IT tests):

java -jar target/springtainer-example-exec.jar

Then, once the containers have started (watch the log for ...-container started lines):

curl -X POST localhost:8080/products \
  -H "Content-Type: application/json" \
  -d '{"name":"Demo Chair","description":"A comfortable chair","price":49.99}'

curl localhost:8080/products/1
curl "localhost:8080/products/search?q=Demo"
curl localhost:8080/products/1/audit-log
curl localhost:8080/products/1/report

The audit-log and report endpoints are populated asynchronously by the RabbitMQ listener - if they return nothing immediately after creating a product, wait a moment and retry.

Testing it

mvn clean install

Runs the full ProductFlowIT end-to-end test, which exercises every container in a single flow and is the reference point for verifying that changes to any springtainer-* module still work correctly together.

Module-to-endpoint map

springtainer module Used by
springtainer-mysql ProductRepository
springtainer-elasticsearch ProductSearchService
springtainer-redis ProductCacheService
springtainer-rabbitmq ProductEventPublisher / ProductEventListener
springtainer-mongodb AuditLogRepository / AuditLogService
springtainer-mockserver EnrichmentClient / EnrichmentMockSetup
springtainer-awss3mock ReportStorageService

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages