Skip to content

Commit

Permalink
FILEUPLOAD-348 - Add tests (already pass in 2.0). (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
doublep committed Feb 8, 2023
1 parent 04f20fc commit a00263b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,25 @@ public void testInMemoryObject(final byte[] testFieldValueBytes, final File repo
} catch (UncheckedIOException e) {
fail("Unexpected IOException", e);
}
testWritingToFile(item, testFieldValueBytes);
item.delete();
}

/**
* Helper method to test writing item contents to a file.
*/
public void testWritingToFile(final FileItem item, final byte[] testFieldValueBytes) {
try {
final File temp = File.createTempFile("fileupload", null);
// Note that the file exists and is initially empty;
// write() must be able to handle that.
item.write(temp);
compareBytes("Initial", FileUtils.readFileToByteArray(temp), testFieldValueBytes);
} catch (Exception e) {
fail("Unexpected Exception", e);
}
}

/**
* Helper method to test creation of a field.
*/
Expand Down Expand Up @@ -138,6 +154,7 @@ public void testAboveThreshold() {
fail("Unexpected IOException", e);
}

testWritingToFile(item, testFieldValueBytes);
item.delete();
}

Expand Down

0 comments on commit a00263b

Please sign in to comment.