From 6f2e63db992e1d6e3e13c354aaa801a5da34c1c1 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Wed, 14 Oct 2015 19:27:20 +0000 Subject: Update test to not depend on an existing build-directory git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1708682 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/usermodel/TestHSSFWorkbook.java | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'src/testcases/org/apache/poi') 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()); } } -- cgit v1.2.3