use of org.springframework.util.LinkedMultiValueMap in project spring-boot by spring-projects.
the class SampleWebSecureCustomApplicationTests method testLogin.
@Test
public void testLogin() throws Exception {
HttpHeaders headers = getHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.set("username", "user");
form.set("password", "user");
ResponseEntity<String> entity = this.restTemplate.exchange("/login", HttpMethod.POST, new HttpEntity<>(form, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
assertThat(entity.getHeaders().getLocation().toString()).endsWith(this.port + "/");
assertThat(entity.getHeaders().get("Set-Cookie")).isNotNull();
}
use of org.springframework.util.LinkedMultiValueMap in project spring-boot by spring-projects.
the class SampleWebSecureJdbcApplicationTests method testLogin.
@Test
public void testLogin() throws Exception {
HttpHeaders headers = getHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.set("username", "user");
form.set("password", "user");
ResponseEntity<String> entity = this.restTemplate.exchange("/login", HttpMethod.POST, new HttpEntity<>(form, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
assertThat(entity.getHeaders().getLocation().toString()).endsWith(this.port + "/");
assertThat(entity.getHeaders().get("Set-Cookie")).isNotNull();
}
use of org.springframework.util.LinkedMultiValueMap in project spring-boot by spring-projects.
the class SampleSecureApplicationTests method testLogin.
@Test
public void testLogin() throws Exception {
HttpHeaders headers = getHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.set("username", "user");
form.set("password", "user");
ResponseEntity<String> entity = this.restTemplate.exchange("/login", HttpMethod.POST, new HttpEntity<>(form, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
assertThat(entity.getHeaders().getLocation().toString()).endsWith(this.port + "/");
assertThat(entity.getHeaders().get("Set-Cookie")).isNotNull();
}
use of org.springframework.util.LinkedMultiValueMap in project spring-boot by spring-projects.
the class SampleWebUiApplicationTests method testCreate.
@Test
public void testCreate() throws Exception {
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.set("text", "FOO text");
map.set("summary", "FOO");
URI location = this.restTemplate.postForLocation("/", map);
assertThat(location.toString()).contains("localhost:" + this.port);
}
use of org.springframework.util.LinkedMultiValueMap in project spring-boot by spring-projects.
the class LinksEnhancer method addEndpointLinks.
public void addEndpointLinks(ResourceSupport resource, String self) {
if (!resource.hasLink("self")) {
resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self).withSelfRel());
}
MultiValueMap<String, String> added = new LinkedMultiValueMap<>();
for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
if (!endpoint.getPath().equals(self)) {
String rel = getRel(endpoint);
List<String> paths = added.get(rel);
if (paths == null || !paths.contains(endpoint.getPath())) {
addEndpointLink(resource, endpoint, rel);
added.add(rel, endpoint.getPath());
}
}
}
}
Aggregations