Rework SpringApplicationTest to support web modes
Rework the new testing support so that @SpringApplicationTest can be used for standard integration tests, web integration tests with a mock Servlet environment and web integration tests with an embedded servlet container. This means that it a replacement for 1.3's @IntegrationTest and @WebIntegrationTest and allows all SpringApplication testing to be configured using a common annotation. The old @IntegrationTest and @WebIntegrationTest along with their supporting classes have been reinstated to their previous form (while remaining deprecated). This should ensure that they continue to work in 1.4 exactly as they did in 1.3 giving users a smooth path to @SpringApplicationTest. See gh-5477
This commit is contained in:
committed by
Phillip Webb
parent
893a6c32f3
commit
33f0ea3480
@@ -24,7 +24,8 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||
import org.springframework.boot.test.context.SpringApplicationTest;
|
||||
import org.springframework.boot.test.context.SpringApplicationTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -45,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebIntegrationTest(randomPort = true)
|
||||
@SpringApplicationTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SampleMethodSecurityApplicationTests {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user