What is the proper annotation since @SpringApplicationConfiguration, @WebIntegration, is deprecated in Spring Boot Framework?
Take a look into JavaDocs of deprecated classes:
* @deprecated as of 1.4 in favor of * {@link org.springframework.boot.test.context.SpringBootTest} with * {@code webEnvironment=RANDOM_PORT} or {@code webEnvironment=DEFINED_PORT}. */...@Deprecatedpublic @interface WebIntegrationTest {
* @deprecated as of 1.4 in favor of {@link SpringBootTest} or direct use of* {@link SpringBootContextLoader}.*/...@Deprecatedpublic @interface SpringApplicationConfiguration {
Is there also a replacement for TestRestTemplate()?
Yes, here it is:
* @deprecated as of 1.4 in favor of * {@link org.springframework.boot.test.web.client.TestRestTemplate} */@Deprecatedpublic class TestRestTemplate extends RestTemplate {
A good place to start is now probably:Testing improvements in Spring Boot 1.4.
They describe a basic sample like the following:
@RunWith(SpringRunner.class)@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)public class MyTest {}
as a replacement to, one of many:
@RunWith(SpringJUnit4ClassRunner.class)@SpringApplicationConfiguration(MyApp.class)@WebIntegrationTestpublic class MyTest {}
you can use @EnableAutoConfiguration or @SpringBootApplication.
for testing purpose you can use @SpringBootTest(webEnvironment='your value') or simply @SpringBootTest
please refer :
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html
for testing the REST, you can use @RestClientTest and configure a RestTemplateBuilder.