@Test public void shouldDeleteFileDestory() throws IOException { File file = new File(tempPath + "uploadfile.pdf"); try { if (!file.createNewFile()) { fail("Unable to create new file."); } assertThat(file.exists(), is(true)); UploadedFile uploadedFile = new UploadedFile("myfile", "myfile.pdf", file); if (!uploadedFile.destroy()) { fail("Unable to destroy uploaded file."); } assertThat(uploadedFile.getFile().exists(), is(false)); assertThat(uploadedFile.getFileName(), is("myfile.pdf")); assertThat(uploadedFile.getPostFieldName(), is("myfile")); } finally { cleanupFile(file); } }