Update the samples to make use of auto-configured TestRestTemplate
Closes gh-6730
This commit is contained in:
@@ -19,7 +19,7 @@ package sample.jersey1;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
@@ -31,14 +31,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class SampleJersey1ApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
assertThat(new TestRestTemplate()
|
||||
.getForObject("http://localhost:" + this.port + "/", String.class))
|
||||
.isEqualTo("Hello World");
|
||||
public void rootReturnsHelloWorld() {
|
||||
assertThat(this.restTemplate.getForObject("/", String.class))
|
||||
.isEqualTo("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user