fix: boot run failed

This commit is contained in:
ReaJason
2024-12-30 23:20:16 +08:00
parent 74a919c6ec
commit c9a536d2fd
3 changed files with 41 additions and 23 deletions
+4 -2
View File
@@ -51,8 +51,10 @@ dependencies {
}
implementation 'org.apache.bcel:bcel:5.2'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
implementation('org.springframework.boot:spring-boot-starter-web') {
exclude group:'org.springframework.boot', module:'spring-boot-starter-tomcat'
}
implementation 'org.springframework.boot:spring-boot-starter-undertow'
implementation 'com.google.code.gson:gson:2.11.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
@@ -0,0 +1,37 @@
package com.reajason.javaweb.boot.controller;
import com.reajason.javaweb.boot.entity.Config;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author ReaJason
* @since 2024/12/13
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ConfigControllerIntegrationTest {
@Autowired
private TestRestTemplate restTemplate;
@Test
public void testConfigEndpoint() {
ResponseEntity<Config> response = restTemplate.getForEntity("/config", Config.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
Config config = response.getBody();
assertNotNull(config);
assertNotNull(config.getServers());
assertNotNull(config.getCore());
assertNotNull(config.getPackers());
}
}
@@ -1,21 +0,0 @@
package com.reajason.javaweb.boot.controller;
import org.junit.jupiter.api.Test;
import org.springframework.http.ResponseEntity;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author ReaJason
* @since 2024/12/13
*/
class ConfigControllerTest {
@Test
void getConfig() {
ConfigController configController = new ConfigController();
ResponseEntity<?> config = configController.config();
Object body = config.getBody();
assertNotNull(body);
System.out.println(body);
}
}