A sample User-Manager app to test Keploy integration capabilities using SpringBoot and MongoDB.
Note :- Issue Creation is disabled on this Repository, please visit here to submit Issue.
Based on your OS and preference(Docker/Native), you setup Keploy using One-click installation method:-
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
Clone the repository and install the dependencies
git clone https://github.com/keploy/samples-java && cd user-manager
mvn clean install -Dmaven.test.skip=true
Once we have our jar file ready,this command will start the recording of API calls using ebpf:-
sudo -E env PATH=$PATH keploy record -c "java -jar target/user-manager-1.0-SNAPSHOT.jar"
Now let's run a few tests to capture some more scenarios:
To generate testcases we just need to make some API calls. You can use Postman, Hoppscotch, or simply curl
- Make a user entry
curl --location --request POST 'http://localhost:8081/api/user' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 1,
"name": "Dan",
"age": "23",
"birthday": "2000-1-1"
}'
this will return the response or an entry.
{"id":1,"name":"Dan","age":23,"birthday":"2000-1-1"}
- Fetch recorded info about users
curl --location --request GET 'http://localhost:8081/api/user/1'
or by querying through the browser http://localhost:8081/api/user/1
- Update user record
curl -X PUT -H "Content-Type: application/json" \
-d '{
"id": 1,
"name": "Update DAN",
"age": "22",
"birthday": "2001-2-2"
}' \
'http://localhost:8081/api/user/1'
this will return the response or an entry.
{"id":1,"name":"Update DAN","age":22,"birthday":"2001-2-2"}
- Delete user record
curl -X DELETE 'http://localhost:8081/api/user/1'
Now both these API calls were captured as editable testcases and written to keploy/test
folder. The keploy directory would also have mock.yml
file.
Now, let's see the magic! 🪄💫
Now, let's run the keploy in test mode: -
sudo -E env PATH=$PATH keploy test -c "java -jar target/user-manager-1.0-SNAPSHOT.jar" --delay 10
This will run the testcases and generate the report in keploy/testReports
folder.