Spring 전환 최소 실행 골격 재검증 #4
1 changed files with 38 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
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.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
class HealthControllerTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
void healthEndpointReturnsUp() throws Exception {
|
||||
mockMvc.perform(get("/health"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.status", is("UP")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthEndpointReturnsJson() throws Exception {
|
||||
MvcResult result = mockMvc.perform(get("/health"))
|
||||
.andExpect(status().isOk())
|
||||
.andReturn();
|
||||
|
||||
String content = result.getResponse().getContentAsString();
|
||||
org.assertj.core.api.Assertions.assertThat(content)
|
||||
.contains("{\"status\":\"UP\"}");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue