Skip to content

Commit c00769c

Browse files
Sonichigoactions-user
authored andcommitted
Merge branch 'main' into main
Signed-off-by: Animesh Pathak <[email protected]>
2 parents e5ba77d + 5d3789f commit c00769c

File tree

9 files changed

+516
-414
lines changed

9 files changed

+516
-414
lines changed

Diff for: versioned_docs/version-2.0.0/concepts/reference/glossary/behaviour-driven-development.md

+100-124
Large diffs are not rendered by default.

Diff for: versioned_docs/version-2.0.0/concepts/reference/glossary/idempotency.md

+60-91
Large diffs are not rendered by default.

Diff for: versioned_docs/version-2.0.0/concepts/reference/glossary/test-driven-development.md

+109-103
Large diffs are not rendered by default.

Diff for: versioned_docs/version-2.0.0/keploy-cloud/time-freezing.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,23 @@ uname -a
5555

5656
### For Golang(Go) Applications -
5757

58+
> Note: Time freezing is only supported till go **1.22.x** version.
59+
5860
#### amd64/x86_64 🖥️
5961

6062
```Dockerfile
6163
# Download the time freeze agent
6264
ADD https://keploy-enterprise.s3.us-west-2.amazonaws.com/releases/latest/assets/go_freeze_time_amd64 /lib/keploy/go_freeze_time_amd64
6365

64-
#set suitable permissions
66+
# set suitable permissions
6567
RUN chmod +x /lib/keploy/go_freeze_time_amd64
6668

6769
# run the binary
6870
RUN /lib/keploy/go_freeze_time_amd64
71+
72+
# build your binary with fake time (during test mode)
73+
RUN go build -tags=faketime <your_main_file>
74+
6975
```
7076

7177
OR
@@ -77,19 +83,18 @@ OR
7783

7884
ADD https://keploy-enterprise.s3.us-west-2.amazonaws.com/releases/latest/assets/go_freeze_time_arm64 /lib/keploy/go_freeze_time_arm64
7985

80-
#set suitable permissions
86+
# set suitable permissions
8187
RUN chmod +x /lib/keploy/go_freeze_time_arm64
8288

8389
# run the binary
8490
RUN /lib/keploy/go_freeze_time_arm64
85-
```
86-
87-
3. Add a `faketime` tag to your build script
8891

89-
```bash
90-
go build -tags=faketime <your_main_file>
92+
# build your binary with fake time (during test mode)
93+
RUN go build -tags=faketime <your_main_file>
9194
```
9295

96+
3. Only Add `faketime` tag to your build script during <u>**Test MODE**</u>
97+
9398
4. Re-Build your Docker image.
9499
5. Now **add the `--freeze-time` flag** when running your tests with Keploy, like so:
95100

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
id: java-spring-boot-xml
3+
title: Sample REST API with Spring-Boot and XML
4+
sidebar_label: XML API App
5+
description: This CRUD Application demonstrates REST API endpoints that serve XML responses using Spring Boot.
6+
tags:
7+
- java
8+
- spring-boot
9+
- xml
10+
- quickstart
11+
- samples
12+
- examples
13+
- tutorial
14+
- restful-api
15+
keyword:
16+
- XML
17+
- Maven
18+
- Springboot Framework
19+
- REST API
20+
- Java
21+
- API Test generator
22+
- Auto Testcase generation
23+
- JAXB
24+
---
25+
26+
## Introduction
27+
28+
🌟 Explore creating REST APIs with XML responses using [Spring-Boot](https://github.com/spring-projects/spring-boot). Discover the ease of integrating XML serialization through JAXB. Let's dive right in! 🚀
29+
30+
## Pre-Requisite 🛠️
31+
32+
- Install [Java 17](https://www.oracle.com/java/technologies/downloads/) and set JAVA_HOME environment variable.
33+
- Install [Maven](https://maven.apache.org/install.html)
34+
- Install [Docker](https://docs.docker.com/engine/install/) (optional)
35+
36+
## Get Started! 🎬
37+
38+
### Clone and Build the Application
39+
40+
```bash
41+
git clone https://github.com/keploy/samples-java.git
42+
cd spring-boot-xml/naive-spring-boot
43+
mvn clean install
44+
```
45+
46+
### Run the Application
47+
48+
Start the Spring Boot application with:
49+
50+
```bash
51+
mvn spring-boot:run
52+
```
53+
54+
> **Note**: For Windows users, commands remain the same.
55+
56+
## API Endpoints 📡
57+
58+
### Get User Data (XML)
59+
60+
- **Endpoint**: `GET /api/user`
61+
62+
Make a request using `curl`:
63+
64+
```bash
65+
curl -X GET -H \"Accept: application/xml\" http://localhost:8080/api/user
66+
```
67+
68+
- **Endpoint**: `GET /api/users`
69+
70+
Make a request using `curl`:
71+
72+
```bash
73+
curl -X GET http://localhost:8080/api/users -H "Accept: application/xml"
74+
```
75+
76+
- **Endpoint**: `GET /api/people`
77+
78+
Make a request using `curl`:
79+
80+
```bash
81+
curl -X GET http://localhost:8080/api/people -H "Accept: application/xml"
82+
```
83+
84+
### Example XML Response
85+
86+
```xml
87+
<User>
88+
<name>John Doe</name>
89+
<age>30</age>
90+
<phone>0101233333</phone>
91+
</User>
92+
```
93+
94+
## Integrating with Keploy 📥
95+
96+
Harness Keploy's test generation capabilities easily:
97+
98+
### Install Keploy
99+
100+
```bash
101+
curl --silent -O -L https://keploy.io/install.sh && source install.sh
102+
```
103+
104+
or
105+
106+
### Install the cloud version -
107+
108+
```bash
109+
curl --silent -O -L https://keploy.io/ent/install.sh && source install.sh
110+
```
111+
112+
### Record Test Cases
113+
114+
```bash
115+
keploy record -c "java -jar target/XML-0.0.1-SNAPSHOT.jar"
116+
```
117+
118+
Start recording interactions by running:
119+
120+
```bash
121+
keploy record -c "java -jar target/XML-0.0.1-SNAPSHOT.jar"
122+
```
123+
124+
Then, invoke the API using `curl` or your favorite API testing tool.
125+
126+
### Run Generated Tests
127+
128+
Execute recorded tests:
129+
130+
```bash
131+
keploy test -c "java -jar target/XML-0.0.1-SNAPSHOT.jar" --delay 10
132+
```
133+
134+
Review generated test reports in `Keploy/reports`.
135+
136+
## Handling Failing Tests ⚠️
137+
138+
If you encounter failing tests due to variable or irrelevant data, like timestamps or dynamically generated fields, you can add them to the global noise configuration in your `keploy.yml`:
139+
140+
**Example:**
141+
142+
<img width="694" alt="Screenshot 2025-03-11 at 12 07 04 AM" src="https://github.com/user-attachments/assets/92dc6480-73f9-435c-a3b8-c918b2acc7a1" />
143+
144+
```yaml
145+
globalNoise:
146+
global:
147+
header.Date: []
148+
body:
149+
# To ignore some values for a field, pass regex patterns to the corresponding array value
150+
UserList: []
151+
```
152+
153+
After updating `keploy.yml` with the above configuration, rerun your tests, and the issue should be resolved.
154+
155+
<img width="711" alt="Screenshot 2025-03-11 at 12 07 19 AM" src="https://github.com/user-attachments/assets/bed57c1e-e7a9-4cbd-80d6-f69a2024ba60" />
156+
157+
## Dependencies 📚
158+
159+
- Spring Boot
160+
- Spring Web
161+
- JAXB (XML serialization)
162+
163+
## Wrapping Up 🎉
164+
165+
Fantastic! You've successfully navigated creating and testing XML APIs with Spring Boot and Keploy. Keep exploring, experimenting, and innovating! If you have any queries, we're here to help!
166+
167+
import GetSupport from '../concepts/support.md'
168+
169+
<GetSupport/>

Diff for: versioned_docs/version-2.0.0/running-keploy/configuration-file.md

+9
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ Earlier the only way to add the [noisy fields](http://keploy.io/docs/concepts/ge
275275

276276
The `global subsection` of `globalNoise` is used to define parameters that are globally ignored for all API calls during testing. It enables you to filter out consistent noise, ensuring a cleaner evaluation of responses.
277277

278+
**Note** - The examples below support both the xml as well as the json type responses.
279+
278280
```yml
279281
globalNoise:
280282
global: {body: {
@@ -286,6 +288,13 @@ globalNoise:
286288
}}
287289
```
288290

291+
**Note:** For marking entire response body as global noise use -
292+
293+
```yml
294+
globalNoise:
295+
global: {body: {"*": "*"}}
296+
```
297+
289298
1. **`global`**:
290299

291300
- **`body`**: Defines patterns to ignore for the response body, such as filtering out URLs. Example: `{"url": ['https?://\S+', 'http://\S+']}`

Diff for: versioned_docs/version-2.0.0/running-keploy/docker-tls.md

-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Before proceeding, ensure the following prerequisites are met:
5454
CMD ["/bin/bash", "-c", "source ./setup_ca.sh && <your app running command>"]
5555
```
5656

57-
> Note: Also add **curl** installation command if **curl** is not installed on your image
58-
5957
To capture test cases, **Execute** the following command within your application's **root directory**.
6058

6159
```shell

0 commit comments

Comments
 (0)