This is an automated email from the ASF dual-hosted git repository. jochen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/master by this push: new 97f0092 PR: FILEUPLOAD-293 Attempt to reproduce the issue. 97f0092 is described below commit 97f0092b16e8a17bc016f21a8aafab74de9a89bb Author: Jochen Wiedmann (jwi) <jochen.wiedm...@softwareag.com> AuthorDate: Sat Feb 23 17:23:59 2019 +0100 PR: FILEUPLOAD-293 Attempt to reproduce the issue. --- .../commons/fileupload2/DiskFileUploadTest.java | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java b/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java index 0435d9c..a9fcdec 100644 --- a/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java +++ b/src/test/java/org/apache/commons/fileupload2/DiskFileUploadTest.java @@ -16,12 +16,16 @@ */ package org.apache.commons.fileupload2; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; + +import java.io.File; +import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.commons.fileupload2.DiskFileUpload; import org.apache.commons.fileupload2.FileUploadException; +import org.apache.commons.fileupload2.disk.DiskFileItem; import org.junit.Before; import org.junit.Test; @@ -66,4 +70,35 @@ public class DiskFileUploadTest { } } + /** Proposed test for FILEUPLOAD-293. As of yet, doesn't reproduce the problem. + */ + @Test + public void testMoveFile() throws Exception { + DiskFileUpload myUpload = new DiskFileUpload(); + myUpload.setSizeThreshold(0); + final String content = + "-----1234\r\n" + + "Content-Disposition: form-data; name=\"file\";" + + "filename=\"foo.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 byte[] contentBytes = content.getBytes("US-ASCII"); + final HttpServletRequest request = new MockHttpServletRequest(contentBytes, Constants.CONTENT_TYPE); + final List<FileItem> items = myUpload.parseRequest(request); + assertNotNull(items); + assertFalse(items.isEmpty()); + final DiskFileItem dfi = (DiskFileItem) items.get(0); + final File out = new File("target/unit-tests/DiskFileUpload/out.file"); + if (out.isFile()) { + out.delete(); + } + final File outDir = out.getParentFile(); + if (!outDir.isDirectory()) { + outDir.mkdirs(); + } + dfi.write(out); + } }