使用Rest Template的黄瓜Spring Boot应用程序

时间:2020-02-20 03:11:26

标签: spring-boot

**Exception** 
I/O error on GET request for "http://localhost:8090/hello": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect

**Feature file**
Given Checking for the page "http://localhost:8090/hello"

**Stepdefinition**
@Autowired
    RestTemplate restTemplate;

@Given("^Checking for the page \"([^\"]*)\"$")
    public void checking_for_the_page_http_localhost_customer(String url) {
            this.url = url;
            restTemplate = new RestTemplate();
        ResponseEntity<String> response = restTemplate.getForEntity(this.url, String.class);
        Assert.assertEquals(200, response.getStatusCode());
    }

说明 我正在使用RestTemplate从功能文件中提到的URL获取响应。这将传递到stepdefinition类文件中的功能。

0 个答案:

没有答案