Skip to content

Commit

Permalink
test: 添加RestClient测试
Browse files Browse the repository at this point in the history
  • Loading branch information
livk-cloud committed Dec 5, 2023
1 parent 392d48e commit cb91e67
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;

Expand All @@ -33,7 +34,7 @@
* @author livk
*/
@SpringBootTest("spring.main.web-application-type=servlet")
@EnableHttpClient({ HttpClientType.REST_TEMPLATE, HttpClientType.WEB_CLIENT })
@EnableHttpClient({ HttpClientType.REST_TEMPLATE, HttpClientType.WEB_CLIENT, HttpClientType.REST_CLIENT })
public class SpringHttpTest {

@Autowired
Expand All @@ -42,12 +43,17 @@ public class SpringHttpTest {
@Autowired
WebClient webClient;

@Autowired
RestClient restClient;

@Test
public void test() {
assertNotNull(restTemplate);
assertNotNull(webClient);
assertNotNull(restClient);
assertEquals(SpringContextHolder.getBean(RestTemplate.class), restTemplate);
assertEquals(SpringContextHolder.getBean(WebClient.class), webClient);
assertEquals(SpringContextHolder.getBean(RestClient.class), restClient);
}

}

0 comments on commit cb91e67

Please sign in to comment.