Spring 전환 최소 실행 골격 재검증 #1

Open
forge-bot wants to merge 6 commits from forge/role-developer-reverify-001-attempt-1-run-91dbb119003d into main
6 changed files with 129 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# role-developer-reverify-001-attempt-1-run-91dbb119003d
Forge 이슈 작업 브랜치 `forge/role-developer-reverify-001-attempt-1-run-91dbb119003d`.

45
pom.xml Normal file
View file

@ -0,0 +1,45 @@
<?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 http://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.3.0</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>spring-minimal</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Spring Minimal Application</name>
<description>Minimum compilable Spring Boot application skeleton</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>

View file

@ -0,0 +1,12 @@
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringMinimalApplication {
public static void main(String[] args) {
SpringApplication.run(SpringMinimalApplication.class, args);
}
}

View file

@ -0,0 +1,23 @@
package com.example.controller;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/api")
public class HealthController {
@GetMapping("/health")
public ResponseEntity<Map<String, String>> health() {
return ResponseEntity.ok(Map.of("status", "UP"));
}
@GetMapping("/ping")
public ResponseEntity<String> ping() {
return ResponseEntity.ok("pong");
}
}

View file

@ -0,0 +1,15 @@
package com.example;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
@SpringBootTest
@TestPropertySource(properties = {"spring.main.allow-bean-definition-overriding=true"})
class SpringMinimalApplicationTests {
@Test
void contextLoads() {
// Verifies that the Spring context loads successfully
}
}

View file

@ -0,0 +1,31 @@
package com.example.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.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(HealthController.class)
class HealthControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
void health_returnsUpStatus() throws Exception {
mockMvc.perform(get("/api/health"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status").value("UP"));
}
@Test
void ping_returnsPong() throws Exception {
mockMvc.perform(get("/api/ping"))
.andExpect(status().isOk())
.andExpect(org.hamcrest.Matchers.content().string("pong"));
}
}