We have developed an Microservice Application Using Dropwizard Framework . Then we have included the Unit Tests related to the Application. It also have Consumer driven test by using Pact.
-
Microservice 1- Application : currency-conversion-dropwizard-demo.
-
The Pact folder which contains the pact files generate by the Consumer Side Test Project
-
The Docker Compose file to start the Pact Broker
If you ask it the value of 1 USD in INR, or 1 Australian Dollar in INR, the Currency Exchange Service answers
- 1 USD is 60 INR
- 1 Australian Dollars is 50 INR.
http://localhost:8080/currency-exchange/from/EUR/to/INR
{
"id": 10002,
"from": "EUR",
"to": "INR",
"conversionMultiple": 75.00,
"exchangeEnvironmentInfo": "37f1ad927c6e v1 27c6e"
}
-
Build Application Jar File :
mvn clean package
This will first perform mvn clean test on the currency-conversion-dropwizard-demoapplication which will run all unit test
And then create a DropWizardDemo-1.0-SNAPSHOT.jar inside the target folder -
Start application in jetty server(Default DropWizard Server) :
java -jar target/DropWizardDemo-1.0-SNAPSHOT.jar server example.yml
Now, the application is up and running and it will be accessable in the port.
http://localhost:8080/currency-exchange/from/EUR/to/INR
- Run the docker compose file
docker-compose up
The Broker will be up and running http://localhost:8113/
-
Run the Consumer Side Test and Generate the Pact Files
We will navigate to the consumer-side-test Project.
Then run the command, mvn clean test
It will run all the Consumer side test, and also generate the pact files -
Push the Generate Pact Files into the Pact Broker
mvn pact:publish
You will be able to see the Contract Details from the Broker UI.
- Run the Producer Test
We will navigate to the producer-side-test Project.
Then run the command, mvn pact:verify
It will verify the Customer Contract in the Producer End by taking the contract from the Broker
You will be able to see the Verification Details from the Broker UI.