spring-boot-maven-failsafe-integration-test
1- Purpose : Create a new maven profile named "integration-test" to execute integration tests separately from standard maven build process.
2- Reason : Integration tests are slow and it takes longer time to complete when compared to unit tests.
3- To run integration tests from the console run the following maven command :
NOT : Execute maven command from where the pom.xml is located in the project directory.
$ mvn clean install -X -P integration-test "-Dspring.profiles.active=test"
4- failsafe-reports can be accessed from the application directory : "target/failsafe-reports"
Tech Stack
Java 11
H2 Database Engine
spring boot
spring data jpa
spring web
hibernate
logback
maven
maven-failsafe-plugin
junit
springfox-swagger-ui
datasource-proxy
Docker
Docker build run steps
NOT : Execute docker commands from where the DockerFile is located.
$ docker system prune
$ docker build . --tag demo
$ docker run -p 8080:8080 -e "SPRING_PROFILES_ACTIVE=dev" demo:latest
API OPERATIONS
Save store with products successfully to database
Method : HTTP.POST
URL : http://localhost:8080/customer-info/store/save
Request :
curl --location --request POST 'http://localhost:8080/customer-info/store/save' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "jeans_store", "products": [ { "name": "prod1" }, { "name": "prod2" }, { "name": "prod3" } ] }'
Response :
HTTP response code 200
{ "id": 1, "name": "jeans_store", "products": [ { "id": 1, "name": "prod3" }, { "id": 2, "name": "prod1" }, { "id": 3, "name": "prod2" } ] }
List Store saved to database
Method : HTTP.GET
URL : http://localhost:8080/customer-info/store/list
Request :
curl --location --request GET 'http://localhost:8080/customer-info/store/list'
Response :
HTTP response code 200
[ { "id": 1, "name": "jeans_store", "products": [ { "id": 1, "name": "prod3" }, { "id": 2, "name": "prod1" }, { "id": 3, "name": "prod2" } ] } ]