Skip to content
Snippets Groups Projects
Commit 7fe70125 authored by Chen Liang's avatar Chen Liang
Browse files

Delete HttpTest.java

parent d16a3a48
No related branches found
No related tags found
No related merge requests found
package com.cardiff.lcTest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class HttpTest {
@Value("${local.server.port}")
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void testGetAllHospitalsHttp() {
String url = "http://localhost:" + port + "/commonAdmin/hospital/all";
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
// 输出调试信息
System.out.println("Response Status: " + response.getStatusCode());
System.out.println("Response Body: " + response.getBody());
// 断言 HTTP 状态码
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment