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-framework by spring-projects.
the class RequestParamMapMethodArgumentResolverTests method resolveMultiValueMapArgument.
@Test
public void resolveMultiValueMapArgument() throws Exception {
String name = "foo";
String value1 = "bar";
String value2 = "baz";
request.addParameter(name, value1, value2);
MultiValueMap<String, String> expected = new LinkedMultiValueMap<>(1);
expected.add(name, value1);
expected.add(name, value2);
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(MultiValueMap.class);
Object result = resolver.resolveArgument(param, null, webRequest, null);
assertTrue(result instanceof MultiValueMap);
assertEquals("Invalid result", expected, result);
}
Aggregations