diff options
author | Dominik Stadler <centic@apache.org> | 2015-10-14 19:27:20 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2015-10-14 19:27:20 +0000 |
commit | 6f2e63db992e1d6e3e13c354aaa801a5da34c1c1 (patch) | |
tree | 1a264f143ae58f8a313ccf0d50fbe159b94ed44c /src/testcases/org/apache/poi | |
parent | 76d99f9583954355c4c36c2ed61225f2539190c6 (diff) | |
download | poi-6f2e63db992e1d6e3e13c354aaa801a5da34c1c1.tar.gz poi-6f2e63db992e1d6e3e13c354aaa801a5da34c1c1.zip |
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
Diffstat (limited to 'src/testcases/org/apache/poi')
-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()); } } |