Skip to content

feat: Add Spring Boot + Keploy integration sample #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions springboot-keploy-demo/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Spring Boot + Keploy Integration Sample

A simple CRUD API demonstrating Keploy integration for automated testing.

## How to Run
1. Build the project:
```bash
mvn clean install
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Entry point for the Spring Boot + Keploy integration demo application.
* This starts the embedded Tomcat server and initializes the Spring context.
*/
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
System.out.println("\n--- Spring Boot + Keploy Demo Running ---");
System.out.println("Try these endpoints:");
System.out.println("POST http://localhost:8080/users");
System.out.println("GET http://localhost:8080/users/{id}\n");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.demo.controller;

import com.example.demo.model.User;
import com.example.demo.service.UserService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UserController {
private final UserService userService;

public UserController(UserService userService) {
this.userService = userService;
}

@PostMapping
public User createUser(@RequestBody User user) {
return userService.createUser(user);
}

@GetMapping("/{id}")
public User getUser(@PathVariable Long id) {
return userService.getUserById(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.demo.model;

public class User {
private Long id;
private String name;
private String email;

// Getters and Setters
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.demo.service;

import com.example.demo.model.User;
import org.springframework.stereotype.Service;
import java.util.*;

@Service
public class UserService {
private final Map<Long, User> users = new HashMap<>();

public User createUser(User user) {
users.put(user.getId(), user);
return user;
}

public User getUserById(Long id) {
return users.get(id);
}
}
37 changes: 37 additions & 0 deletions springboot-keploy-demo/src/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-keploy-demo</name>
<description>Spring Boot + Keploy Integration Sample</description>

<properties>
<java.version>17</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Add Keploy Java SDK here (if available) -->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Empty file.