diff options
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel')
3 files changed, 27 insertions, 5 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java index 3281b5115a..98ccbf0394 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java @@ -860,7 +860,7 @@ public final class TestFormulas extends TestCase { HSSFWorkbook wb = openSample("27272_1.xls"); wb.getSheetAt(0); assertEquals("Reference for named range ", "Compliance!#REF!",wb.getNameAt(0).getRefersToFormula()); - File outF = File.createTempFile("bug27272_1",".xls"); + File outF = TempFile.createTempFile("bug27272_1",".xls"); wb.write(new FileOutputStream(outF)); System.out.println("Open "+outF.getAbsolutePath()+" in Excel"); } @@ -868,7 +868,7 @@ public final class TestFormulas extends TestCase { public void test27272_2() throws Exception { HSSFWorkbook wb = openSample("27272_2.xls"); assertEquals("Reference for named range ", "LOAD.POD_HISTORIES!#REF!",wb.getNameAt(0).getRefersToFormula()); - File outF = File.createTempFile("bug27272_2",".xls"); + File outF = TempFile.createTempFile("bug27272_2",".xls"); wb.write(new FileOutputStream(outF)); System.out.println("Open "+outF.getAbsolutePath()+" in Excel"); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java index 2d56482173..454a297105 100755 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java @@ -166,6 +166,28 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("http://poi.apache.org/hssf/", link.getAddress()); } + public void testCreate() throws Exception { + HSSFWorkbook wb = getTestDataProvider().createWorkbook(); + + HSSFHyperlink link; + HSSFCell cell; + HSSFSheet sheet = wb.createSheet("Hyperlinks"); + + cell = sheet.createRow(1).createCell(0); + cell.setCellValue("File Link"); + link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE); + link.setAddress("testfolder\\test.PDF"); + cell.setHyperlink(link); + + wb = getTestDataProvider().writeOutAndReadBack(wb); + sheet = wb.getSheet("Hyperlinks"); + + cell = sheet.getRow(1).getCell(0); + link = cell.getHyperlink(); + assertNotNull(link); + assertEquals("testfolder\\test.PDF", link.getAddress()); + } + /** * Test that HSSFSheet#shiftRows moves hyperlinks, * see bugs #46445 and #29957 diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 2f944c5fd7..ee8e0e8245 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -34,6 +34,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ddf.EscherDgRecord; +import org.apache.poi.util.TempFile; /** * Tests HSSFSheet. This test case is very incomplete at the moment. @@ -572,8 +573,7 @@ public final class TestHSSFSheet extends BaseTestSheet { assertFalse(sheet2.getForceFormulaRecalculation()); // Save and manually verify that on column C we have 0, value in template - File tempFile = new File(System.getProperty("java.io.tmpdir")+"/uncalced_err.xls" ); - tempFile.delete(); + File tempFile = TempFile.createTempFile("uncalced_err", ".xls" ); FileOutputStream fout = new FileOutputStream( tempFile ); workbook.write( fout ); fout.close(); @@ -581,7 +581,7 @@ public final class TestHSSFSheet extends BaseTestSheet { assertTrue(sheet.getForceFormulaRecalculation()); // Save and manually verify that on column C we have now 13, calculated value - tempFile = new File(System.getProperty("java.io.tmpdir")+"/uncalced_succ.xls" ); + tempFile = TempFile.createTempFile("uncalced_succ", ".xls"); tempFile.delete(); fout = new FileOutputStream( tempFile ); workbook.write( fout ); |