fix: boot run failed

This commit is contained in:
ReaJason
2024-12-30 23:20:16 +08:00
parent 8e8b344bdd
commit fb421e48ee
3 changed files with 41 additions and 23 deletions
@@ -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);
}
}