This basic rest service app is used to test the Diffblue Cover plugin.
This is a Spring Boot 2.1.6 tiny app that includes webapp, actuator, spring-data-jpa starts and exposes four (4) endpoints as listed below
- List Students
localhost:8080/students/list-GET - Get Student by Id
localhost:8080/students/{sid}-GET - Delete Student by Id
localhost:8080/students/{sid}-DELETE - Create Student
localhost:8080/students-POST
This service is backed by an in-memory database called h2 that is pretty straight-forward to setup. All that is needed to do is
- Drop a
data.sqlfile in the/src/main/resourcesand upon start up those SQLs will be executed - Add a few configuration to the
application.propertiesin order to enable theh2database as well as to enable theh2-consolethat is accessible depending on server urllocalhost:8080/h2-console(when the application is running).
Note: The in-memory version of h2 means the content of the database will only live during the life-cycle of the application.
Upon start-up of the application we have PopulateDatabase class that basically uses Spring Data repository to create 20K Student object and Bulk Save it in the db. So once your application is started, you have nearly 20K records. You can increase/decrease this as you wish.
Note: When navigating to h2-console don't forget to update the JDBC url to point to the same that is in src/main/resources/application.properties
Glad you asked! All you have to do is ensure that you have maven and do the following steps
- Clone the
repolocally - Run
mvn spring-boot:runcommand and the application will run in the command line
Hit the endpoints above curl localhost:8080/students/42 or curl localhost:8080/students/list to interact with the endpoints.
Congratulations! You are all done!
Your service is up and running. It exposes create, read, list, and delete endpoints.