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
This commit is contained in:
parent
05c161b6cf
commit
e9d0e9cc12
@ -1200,32 +1200,36 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRewriteFileBug58480() throws Exception {
|
public void testRewriteFileBug58480() throws Exception {
|
||||||
final File file = new File(
|
final File file = TempFile.createTempFile("TestHSSFWorkbook", ".xls");
|
||||||
"build/HSSFWorkbookTest-testWriteScenario.xls");
|
|
||||||
|
|
||||||
// create new workbook
|
try {
|
||||||
{
|
// create new workbook
|
||||||
final Workbook workbook = new HSSFWorkbook();
|
{
|
||||||
final Sheet sheet = workbook.createSheet("foo");
|
final Workbook workbook = new HSSFWorkbook();
|
||||||
final Row row = sheet.createRow(1);
|
final Sheet sheet = workbook.createSheet("foo");
|
||||||
row.createCell(1).setCellValue("bar");
|
final Row row = sheet.createRow(1);
|
||||||
|
row.createCell(1).setCellValue("bar");
|
||||||
writeAndCloseWorkbook(workbook, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user