Spring 전환 최소 실행 골격 구현 #4
6 changed files with 130 additions and 0 deletions
3
.forge/role-developer-001-attempt-1-run-13e76c4f33b3.md
Normal file
3
.forge/role-developer-001-attempt-1-run-13e76c4f33b3.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# role-developer-001-attempt-1-run-13e76c4f33b3
|
||||
|
||||
Forge 이슈 작업 브랜치 `forge/role-developer-001-attempt-1-run-13e76c4f33b3`.
|
||||
44
pom.xml
Normal file
44
pom.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?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.2.5</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>demo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>demo</name>
|
||||
<description>Minimal Spring Boot Application</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
12
src/main/java/com/example/demo/DemoApplication.java
Normal file
12
src/main/java/com/example/demo/DemoApplication.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.example.demo.controller;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class HelloController {
|
||||
|
||||
@GetMapping("/hello")
|
||||
public ResponseEntity<String> hello(@RequestParam(required = false) String name) {
|
||||
String message = (name != null && !name.isBlank())
|
||||
? "Hello, " + name + "!"
|
||||
: "Hello, World!";
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
}
|
||||
15
src/test/java/com/example/demo/DemoApplicationTests.java
Normal file
15
src/test/java/com/example/demo/DemoApplicationTests.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package com.example.demo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestPropertySource(properties = {"spring.main.allow-bean-definition-overriding=true"})
|
||||
class DemoApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
// Verify Spring context loads successfully
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.example.demo.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(HelloController.class)
|
||||
class HelloControllerTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
void hello_withoutName_returnsDefaultMessage() throws Exception {
|
||||
mockMvc.perform(get("/hello"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("Hello, World!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hello_withName_returnsPersonalizedMessage() throws Exception {
|
||||
mockMvc.perform(get("/hello").param("name", "Spring"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("Hello, Spring!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hello_withBlankName_returnsDefaultMessage() throws Exception {
|
||||
mockMvc.perform(get("/hello").param("name", " "))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("Hello, World!"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue