use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class DevToolsIntegrationTests method addARequestMappingToAnExistingController.
@Test
public void addARequestMappingToAnExistingController() throws Exception {
TestRestTemplate template = new TestRestTemplate();
String urlBase = "http://localhost:" + awaitServerPort();
assertThat(template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
controller("com.example.ControllerOne").withRequestMapping("one").withRequestMapping("two").build();
assertThat(template.getForObject(urlBase + "/one", String.class)).isEqualTo("one");
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/two", String.class)).isEqualTo("two");
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class DevToolsIntegrationTests method removeARequestMappingFromAnExistingController.
@Test
public void removeARequestMappingFromAnExistingController() throws Exception {
TestRestTemplate template = new TestRestTemplate();
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/one", String.class)).isEqualTo("one");
controller("com.example.ControllerOne").build();
assertThat(template.getForEntity("http://localhost:" + awaitServerPort() + "/one", String.class).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class EndpointMvcIntegrationTests method envEndpointNotHidden.
@Test
public void envEndpointNotHidden() throws InterruptedException {
String body = new TestRestTemplate().getForObject("http://localhost:" + this.port + "/env/user.dir", String.class);
assertThat(body).isNotNull().contains("spring-boot-actuator");
assertThat(this.interceptor.invoked()).isTrue();
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class HalBrowserMvcEndpointServerServletPathIntegrationTests method linksAddedToHomePage.
@Test
public void linksAddedToHomePage() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/spring/", HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"_links\":");
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class HalBrowserMvcEndpointServerServletPathIntegrationTests method actuatorLinks.
@Test
public void actuatorLinks() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/spring/actuator", HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"_links\":");
}
Aggregations