ContentRequestMatchers supports HttpEntity multipart

Closes gh-36154
This commit is contained in:
rstoyanchev
2026-01-19 17:05:16 +00:00
parent a029dfc6a8
commit 9b95482557
2 changed files with 46 additions and 5 deletions
@@ -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();