Set UTF-8 as default multipart charset to ContentRequestMatchers

See gh-31924
This commit is contained in:
Anton Ždanov
2023-12-29 20:25:44 +02:00
committed by rstoyanchev
parent f9883d8bd6
commit 667e30f580
2 changed files with 72 additions and 1 deletions

View File

@@ -60,6 +60,8 @@ import static org.springframework.test.util.AssertionErrors.assertTrue;
*/
public class ContentRequestMatchers {
private static final String DEFAULT_ENCODING = "UTF-8";
private final XmlExpectationsHelper xmlHelper;
private final JsonExpectationsHelper jsonHelper;
@@ -367,7 +369,9 @@ public class ContentRequestMatchers {
public static MultiValueMap<String, ?> parse(MockClientHttpRequest request) {
try {
FileUpload fileUpload = new FileUpload();
fileUpload.setFileItemFactory(new DiskFileItemFactory());
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setDefaultCharset(DEFAULT_ENCODING);
fileUpload.setFileItemFactory(factory);
List<FileItem> fileItems = fileUpload.parseRequest(new UploadContext() {
private final byte[] body = request.getBodyAsBytes();