Make TestRestTemplate not extend RestTemplate
Update TestRestTemplate so that it no longer directly extends RestTemplate. Prior to this commit it was possible that TestRestTemplate could interfere with user defined RestTemplate beans. TestRestTemplate offers the same methods as RestTemplate so should be a drop-in replacement. If access is needed to the actual underlying template the `getRestTemplate()` method should be used. Fixes gh-5915
This commit is contained in:
@@ -26,7 +26,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class SampleJerseyApplicationTests {
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
private RestTemplate restTemplate = new TestRestTemplate();
|
||||
private TestRestTemplate restTemplate = new TestRestTemplate();
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
|
||||
Reference in New Issue
Block a user