Merge pull request #9606 from alimate/BAEL-4271

BAEL-4271: Added the Rest Assured Example
This commit is contained in:
Eric Martin 2020-07-02 12:00:07 -05:00 committed by GitHub
commit 2e95961d1b
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package com.baeldung.web.controller;
import io.restassured.RestAssured;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import static io.restassured.RestAssured.given;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@TestPropertySource(properties = {"spring.main.allow-bean-definition-overriding=true", "server.servlet.context-path=/"})
public class GreetControllerRealIntegrationTest {
@LocalServerPort
private int port;
@Before
public void setUp() {
RestAssured.port = port;
}
@Test
public void givenGreetURI_whenSendingReq_thenVerifyResponse() {
given().get("/greet")
.then()
.statusCode(200);
}
}