初始化

This commit is contained in:
马宝龙
2026-07-27 23:20:12 +08:00
commit 5e07c24dd4
35 changed files with 2966 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
package com.example.training;
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.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import com.example.training.controller.HealthController;
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)
@ActiveProfiles("test")
class TrainingApplicationTests {
@Autowired
private MockMvc mockMvc;
@Test
void healthEndpointReturnsUp() throws Exception {
mockMvc.perform(get("/api/health"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status").value("UP"))
.andExpect(jsonPath("$.service").value("training-backend"));
}
}

View File

@@ -0,0 +1,20 @@
spring:
config:
activate:
on-profile: test
datasource:
url: jdbc:h2:mem:training-test;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: sa
password:
driver-class-name: org.h2.Driver
sql:
init:
mode: never
server:
port: 0
logging:
level:
com.example.training: INFO
org.springframework: WARN