diff options
Diffstat (limited to 'src/testcases/org')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index fec2a230a4..f40ce344f2 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -1200,32 +1200,36 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { @Test public void testRewriteFileBug58480() throws Exception { - final File file = new File( - "build/HSSFWorkbookTest-testWriteScenario.xls"); - - // create new workbook - { - final Workbook workbook = new HSSFWorkbook(); - final Sheet sheet = workbook.createSheet("foo"); - final Row row = sheet.createRow(1); - row.createCell(1).setCellValue("bar"); - - writeAndCloseWorkbook(workbook, file); - } + final File file = TempFile.createTempFile("TestHSSFWorkbook", ".xls"); - // edit the workbook - { - NPOIFSFileSystem fs = new NPOIFSFileSystem(file, false); - try { - DirectoryNode root = fs.getRoot(); - final Workbook workbook = new HSSFWorkbook(root, true); - final Sheet sheet = workbook.getSheet("foo"); - sheet.getRow(1).createCell(2).setCellValue("baz"); + try { + // create new workbook + { + final Workbook workbook = new HSSFWorkbook(); + final Sheet sheet = workbook.createSheet("foo"); + final Row row = sheet.createRow(1); + row.createCell(1).setCellValue("bar"); writeAndCloseWorkbook(workbook, file); - } finally { - fs.close(); } + + // edit the workbook + { + NPOIFSFileSystem fs = new NPOIFSFileSystem(file, false); + try { + DirectoryNode root = fs.getRoot(); + final Workbook workbook = new HSSFWorkbook(root, true); + final Sheet sheet = workbook.getSheet("foo"); + sheet.getRow(1).createCell(2).setCellValue("baz"); + + writeAndCloseWorkbook(workbook, file); + } finally { + fs.close(); + } + } + } finally { + assertTrue(file.exists()); + assertTrue(file.delete()); } } |