This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
commit 53919470ebf9ba59f91b527953ee046fcaad2f71 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Fri Jun 13 10:59:11 2025 -0400 Fix formatting --- .../fileupload2/core/MultipartStreamTest.java | 67 +++++++++------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java index fc0cb4ba..06aa733e 100644 --- a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java +++ b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.commons.fileupload2.core; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,54 +37,42 @@ class MultipartStreamTest { static private final String BOUNDARY_TEXT = "myboundary"; - /** Checks, whether the maxSize works. + /** + * Checks, whether the maxSize works. */ @Test - public void testPartHeaderSizeMaxLimit() - throws Exception { - final String request = - "-----1234\r\n" + - "Content-Disposition: form-data; name=\"file1\"; filename=\"foo1.tab\"\r\n" + - "Content-Type: text/whatever\r\n" + - "Content-Length: 10\r\n" + - "\r\n" + - "This is the content of the file\n" + - "\r\n" + - "-----1234\r\n" + - "Content-Disposition: form-data; name=\"file2\"; filename=\"foo2.tab\"\r\n" + - "Content-Type: text/whatever\r\n" + - "\r\n" + - "This is the content of the file\n" + - "\r\n" + - "-----1234--\r\n"; - + public void testPartHeaderSizeMaxLimit() throws Exception { + final String request = "-----1234\r\n" + "Content-Disposition: form-data; name=\"file1\"; filename=\"foo1.tab\"\r\n" + "Content-Type: text/whatever\r\n" + + "Content-Length: 10\r\n" + "\r\n" + "This is the content of the file\n" + "\r\n" + "-----1234\r\n" + + "Content-Disposition: form-data; name=\"file2\"; filename=\"foo2.tab\"\r\n" + "Content-Type: text/whatever\r\n" + "\r\n" + + "This is the content of the file\n" + "\r\n" + "-----1234--\r\n"; final String strContents = request; final byte[] byteContents = request.getBytes(StandardCharsets.UTF_8); final InputStream input = new ByteArrayInputStream(byteContents); final byte[] boundary = "---1234".getBytes(); - final MultipartInput mi = MultipartInput.builder().setInputStream(input).setBoundary(boundary) - .setPartHeaderSizeMax(100).get(); + final MultipartInput mi = MultipartInput.builder().setInputStream(input).setBoundary(boundary).setPartHeaderSizeMax(100).get(); assertNotNull(mi); try { - boolean nextPart = mi.skipPreamble(); - final OutputStream nullOutput = new OutputStream() { - @Override - public void write(final int pB) throws IOException { - // Do nothing. (Null output) - } - }; - while (nextPart) { - final String headers = mi.readHeaders(); - System.out.print("Headers=" + headers.length() + ", " + headers); - assertNotNull(headers); - // process headers - // create some output stream - mi.readBodyData(nullOutput); - nextPart = mi.readBoundary(); - } - fail("Expected Exception"); + boolean nextPart = mi.skipPreamble(); + final OutputStream nullOutput = new OutputStream() { + + @Override + public void write(final int pB) throws IOException { + // Do nothing. (Null output) + } + }; + while (nextPart) { + final String headers = mi.readHeaders(); + System.out.print("Headers=" + headers.length() + ", " + headers); + assertNotNull(headers); + // process headers + // create some output stream + mi.readBodyData(nullOutput); + nextPart = mi.readBoundary(); + } + fail("Expected Exception"); } catch (final FileUploadSizeException fuse) { - assertEquals(100, fuse.getPermitted()); + assertEquals(100, fuse.getPermitted()); } }