use of org.springframework.util.LinkedMultiValueMap in project spring-cloud-netflix by spring-cloud.
the class FormRibbonClientConfiguration method postWithMultipartFileAndForm.
@Test
public void postWithMultipartFileAndForm() {
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
HttpHeaders part = new HttpHeaders();
part.setContentType(MediaType.TEXT_PLAIN);
part.setContentDispositionFormData("file", "foo.txt");
form.set("foo", new HttpEntity<>("bar".getBytes(), part));
form.set("field", "data");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
ResponseEntity result = sendPost("/simplefzpat/fileandform", form, headers);
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("Posted! bar!field!data", result.getBody());
}
use of org.springframework.util.LinkedMultiValueMap in project spring-cloud-netflix by spring-cloud.
the class FormRibbonClientConfiguration method postWithMultipartFile.
@Test
public void postWithMultipartFile() {
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
HttpHeaders part = new HttpHeaders();
part.setContentType(MediaType.TEXT_PLAIN);
part.setContentDispositionFormData("file", "foo.txt");
form.set("foo", new HttpEntity<>("bar".getBytes(), part));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
ResponseEntity result = sendPost("/simplefzpat/file", form, headers);
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("Posted! bar", result.getBody());
}
use of org.springframework.util.LinkedMultiValueMap in project spring-cloud-netflix by spring-cloud.
the class FormRibbonClientConfiguration method postWithMultipartForm.
@Test
public void postWithMultipartForm() {
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.set("foo", "bar");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
ResponseEntity result = sendPost("/simplefzpat/form", form, headers);
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("Posted! {foo=[bar]}", result.getBody());
}
use of org.springframework.util.LinkedMultiValueMap in project spring-cloud-netflix by spring-cloud.
the class ServletFormRibbonClientConfiguration method postWithMultipartForm.
@Test
public void postWithMultipartForm() {
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.set("foo", "bar");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
ResponseEntity<String> result = testRestTemplate.exchange("/zuul/simplefzspat/form", HttpMethod.POST, new HttpEntity<>(form, headers), String.class);
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("Posted! {foo=[bar]}", result.getBody());
}
use of org.springframework.util.LinkedMultiValueMap in project spring-cloud-netflix by spring-cloud.
the class ServletFormRibbonClientConfiguration method postWithUTF8Form.
@Test
public void postWithUTF8Form() {
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.set("foo", "bar");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED_VALUE + "; charset=UTF-8"));
ResponseEntity<String> result = testRestTemplate.exchange("/zuul/simplefzspat/form", HttpMethod.POST, new HttpEntity<>(form, headers), String.class);
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("Posted! {foo=[bar]}", result.getBody());
}
Aggregations