RESTful web service which handles POST and GET methods.
- POST: Stores the received JSON data to a file
- GET: Sends the requested data, if available, to the user in JSON format.
- Error scenarios are handled by sending appropriate HTTP error codes.
- Java 8
- Maven
- Spark Java http://sparkjava.com/
- Gson
- Lombok https://projectlombok.org/
- log4j http://logging.apache.org/log4j/1.2/
- slf4j 1.7.25 https://www.slf4j.org/
- Clone the project.
- In command line, navigate to REST-Web-Service/ and execute the following to start the service
java -jar RestWebService.jar
- Send the POST or GET requests (use url http://localhost:5000/) - I used Postman for this.
- The projects will be stored in the file "projects.txt" in the same location as the jar
- The server logs will be stored in the file "web_service_logs.txt" in the same location as the jar
- Import the file "TestRESTWebService.postman_collection.json" to Postman (https://www.getpostman.com/). This will create a "TestRESTWebService" folder in Postman.
- Keep the server running.
- Click on Runner and choose the collection TestRESTWebService -> POST - Many successful request
- Set Iterations as 1000
- Start Run
- Click on Runner and choose the collection TestRESTWebService
- Start Run
If you want to run individual folders:
- Run the "PUT request" testcase.
- Click on Runner and choose the collection TestRESTWebService -> Post - Json Array
- Start Run
- Click on Runner and choose the collection TestRESTWebService -> POST - Invalid Requests
- Start Run
- Click on Runner and choose the collection TestRESTWebService -> GET - Invalid Requests
- Start Run
- Click on Runner and choose the collection TestRESTWebService -> GET - Valid Requests
- Start Run
Import the file "TestRESTWebService.postman_test_run.json" to Postman (Runner -> Import Test Run)