Search in sources :

Example 66 with HttpHeaders

use of org.springframework.http.HttpHeaders 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\":");
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 67 with HttpHeaders

use of org.springframework.http.HttpHeaders 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\":");
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 68 with HttpHeaders

use of org.springframework.http.HttpHeaders in project spring-boot by spring-projects.

the class HalBrowserMvcEndpointServerContextPathIntegrationTests method actuatorBrowserEntryPoint.

@Test
public void actuatorBrowserEntryPoint() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/spring/actuator/browser.html", HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(entity.getBody()).contains("entryPoint: '/spring/actuator'");
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 69 with HttpHeaders

use of org.springframework.http.HttpHeaders in project spring-boot by spring-projects.

the class HalBrowserMvcEndpointServerContextPathIntegrationTests method actuatorBrowserRedirect.

@Test
public void actuatorBrowserRedirect() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    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.FOUND);
    assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create("http://localhost:" + this.port + "/spring/actuator/browser.html"));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 70 with HttpHeaders

use of org.springframework.http.HttpHeaders in project spring-boot by spring-projects.

the class HalBrowserMvcEndpointServerPortIntegrationTests method links.

@Test
public void links() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/actuator", HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(entity.getBody()).contains("\"_links\":");
    assertThat(entity.getBody()).contains(":" + this.port);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

HttpHeaders (org.springframework.http.HttpHeaders)1676 Test (org.junit.Test)426 ResponseEntity (org.springframework.http.ResponseEntity)383 HttpEntity (org.springframework.http.HttpEntity)345 Test (org.junit.jupiter.api.Test)273 HashMap (java.util.HashMap)184 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)154 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)127 MediaType (org.springframework.http.MediaType)121 URI (java.net.URI)111 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)102 Map (java.util.Map)97 IOException (java.io.IOException)83 RestTemplate (org.springframework.web.client.RestTemplate)78 ArrayList (java.util.ArrayList)75 MessageHeaders (org.springframework.messaging.MessageHeaders)74 MultiValueMap (org.springframework.util.MultiValueMap)74 HttpStatus (org.springframework.http.HttpStatus)71 List (java.util.List)65 Timed (com.codahale.metrics.annotation.Timed)54