Skip to content

Commit

Permalink
chore: fixed test and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tltv committed Nov 19, 2024
1 parent 0173714 commit 9908a6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ protected FileItemInputIterator getItemIterator(VaadinRequest request)
}

// protected for testing purposes only
protected JakartaServletFileUpload createServletFileUpload(VaadinRequest request) {
protected JakartaServletFileUpload createServletFileUpload(
VaadinRequest request) {
JakartaServletFileUpload upload = new JakartaServletFileUpload();
upload.setSizeMax(requestSizeMax);
upload.setFileSizeMax(fileSizeMax);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload2.jakarta.JakartaServletFileUpload;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -300,23 +301,23 @@ public void doHandleMultipartFileUpload_noPart_uploadFailed_responseStatusIs500_

@Test
public void createServletFileUpload_useUTF8HeaderCharacterEncodingWhenRequestCharEncodingIsNotSet() {
ServletFileUpload servletFileUpload = handler
JakartaServletFileUpload servletFileUpload = handler
.createServletFileUpload(request);
Assert.assertNotNull(servletFileUpload);
Assert.assertEquals(
"Header encoding should be UTF-8 when request character encoding is null",
"UTF-8", servletFileUpload.getHeaderEncoding());
StandardCharsets.UTF_8, servletFileUpload.getHeaderCharset());
}

@Test
public void createServletFileUpload_dontSetHeaderCharEncodingWhenRequestCharEncodingIsSet() {
requestCharacterEncoding = "ASCII";
ServletFileUpload servletFileUpload = handler
JakartaServletFileUpload servletFileUpload = handler
.createServletFileUpload(request);
Assert.assertNotNull(servletFileUpload);
Assert.assertNull(
"Header encoding should not be set by Flow when request character encoding is set",
servletFileUpload.getHeaderEncoding());
servletFileUpload.getHeaderCharset());
}

@Test
Expand Down

0 comments on commit 9908a6a

Please sign in to comment.