diff --git a/springboot-keploy-demo/src/README.md b/springboot-keploy-demo/src/README.md new file mode 100644 index 00000000..dc35c983 --- /dev/null +++ b/springboot-keploy-demo/src/README.md @@ -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 \ No newline at end of file diff --git a/springboot-keploy-demo/src/main/java/com/example/demo/DemoApplication.java b/springboot-keploy-demo/src/main/java/com/example/demo/DemoApplication.java new file mode 100644 index 00000000..7fd9cf44 --- /dev/null +++ b/springboot-keploy-demo/src/main/java/com/example/demo/DemoApplication.java @@ -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"); + } +} \ No newline at end of file diff --git a/springboot-keploy-demo/src/main/java/com/example/demo/controller/UserController.java b/springboot-keploy-demo/src/main/java/com/example/demo/controller/UserController.java new file mode 100644 index 00000000..e8bf425c --- /dev/null +++ b/springboot-keploy-demo/src/main/java/com/example/demo/controller/UserController.java @@ -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); + } +} \ No newline at end of file diff --git a/springboot-keploy-demo/src/main/java/com/example/demo/model/User.java b/springboot-keploy-demo/src/main/java/com/example/demo/model/User.java new file mode 100644 index 00000000..336308c7 --- /dev/null +++ b/springboot-keploy-demo/src/main/java/com/example/demo/model/User.java @@ -0,0 +1,9 @@ +package com.example.demo.model; + +public class User { + private Long id; + private String name; + private String email; + + // Getters and Setters +} \ No newline at end of file diff --git a/springboot-keploy-demo/src/main/java/com/example/demo/service/UserService.java b/springboot-keploy-demo/src/main/java/com/example/demo/service/UserService.java new file mode 100644 index 00000000..1afdd4a7 --- /dev/null +++ b/springboot-keploy-demo/src/main/java/com/example/demo/service/UserService.java @@ -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 users = new HashMap<>(); + + public User createUser(User user) { + users.put(user.getId(), user); + return user; + } + + public User getUserById(Long id) { + return users.get(id); + } +} \ No newline at end of file diff --git a/springboot-keploy-demo/src/pom.xml b/springboot-keploy-demo/src/pom.xml new file mode 100644 index 00000000..98bc2caf --- /dev/null +++ b/springboot-keploy-demo/src/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.0 + + + com.example + demo + 0.0.1-SNAPSHOT + springboot-keploy-demo + Spring Boot + Keploy Integration Sample + + + 17 + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/springboot-keploy-demo/src/resources/application.properties b/springboot-keploy-demo/src/resources/application.properties new file mode 100644 index 00000000..e69de29b