mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-20 20:59:07 +00:00
ContentRequestMatchers supports HttpEntity multipart
Closes gh-36154
This commit is contained in:
+15
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -160,6 +161,20 @@ public class MultipartRequestMatchersTests {
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(this::writeAndAssert);
|
||||
}
|
||||
|
||||
@Test // gh-36154
|
||||
public void testHttpEntityMatch() throws Exception {
|
||||
String contentType = "text/plain";
|
||||
MultipartFile file = new MockMultipartFile("file", "foo.txt", contentType, "Foo Lorem ipsum".getBytes());
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(HttpHeaders.CONTENT_TYPE, contentType);
|
||||
this.input.add("foo.txt", new HttpEntity<>(file.getResource(), headers));
|
||||
|
||||
this.expected.addAll(this.input);
|
||||
|
||||
writeAndAssert();
|
||||
}
|
||||
|
||||
|
||||
private void writeAndAssert() throws IOException {
|
||||
writeForm();
|
||||
|
||||
Reference in New Issue
Block a user