Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper annotation since @SpringApplicationConfiguration, @WebIntegration, is deprecated in Spring Boot Framework?

What is the proper annotation since @SpringApplicationConfiguration and @WebIntegration are deprecated as of Spring Boot Framework 1.4? I'm trying to play around with unit testing.

like image 576
Person Avatar asked Sep 09 '16 18:09

Person


People also ask

What is @SpringBootTest?

The @SpringBootTest annotation is useful when we need to bootstrap the entire container. The annotation works by creating the ApplicationContext that will be utilized in our tests. We can use the webEnvironment attribute of @SpringBootTest to configure our runtime environment; we're using WebEnvironment.


1 Answers

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}.  */ ... @Deprecated public @interface WebIntegrationTest { 

* @deprecated as of 1.4 in favor of {@link SpringBootTest} or direct use of * {@link SpringBootContextLoader}. */ ... @Deprecated public @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}  */ @Deprecated public class TestRestTemplate extends RestTemplate { 
like image 124
Artem Bilan Avatar answered Oct 21 '22 15:10

Artem Bilan