aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-07-24 18:58:27 +0000
committerNick Burch <nick@apache.org>2014-07-24 18:58:27 +0000
commit7db6e8557e69b40bb4c8896aa380af8fe8732f46 (patch)
treebb07f15441a85e76bd17ab9c7b3815a70d09bec3 /src/ooxml/testcases
parente2f26b630c10fd34197c0d7f82f815f0417f18e0 (diff)
downloadpoi-7db6e8557e69b40bb4c8896aa380af8fe8732f46.tar.gz
poi-7db6e8557e69b40bb4c8896aa380af8fe8732f46.zip
Patch from Raúl Wegmann from bug #56735 / GitHub Pull #10 - Rationalise POI temp file creation to the TempFile util class, and allow a system wide setting of where Temp files (eg for SXSSF) go, via TempFile / TempFileCreationStrategy
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613246 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases')
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java5
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java3
3 files changed, 7 insertions, 7 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java b/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java
index bf93681a4b..1c6b942a58 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java
@@ -22,11 +22,10 @@ import org.apache.poi.util.TempFile;
import java.io.File;
import java.io.InputStream;
+import java.io.IOException;
/**
* Centralises logic for finding/opening sample files for ooxml4j unit tests
- *
- * @author jmicich
*/
public final class OpenXML4JTestDataSamples {
private static final POIDataSamples _samples = POIDataSamples.getOpenXML4JInstance();
@@ -46,7 +45,7 @@ public final class OpenXML4JTestDataSamples {
return _samples.getFile(sampleFileName);
}
- public static File getOutputFile(String outputFileName) {
+ public static File getOutputFile(String outputFileName) throws IOException {
String suffix = outputFileName.substring(outputFileName.lastIndexOf('.'));
return TempFile.createTempFile(outputFileName, suffix);
}
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
index 01116abcf9..fe5bb21d46 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
@@ -454,7 +454,7 @@ public final class TestPackage extends TestCase {
* write changes to it.
*/
public void testOpenFileThenOverwrite() throws Exception {
- File tempFile = File.createTempFile("poiTesting","tmp");
+ File tempFile = TempFile.createTempFile("poiTesting","tmp");
File origFile = OpenXML4JTestDataSamples.getSampleFile("TestPackageCommon.docx");
FileHelper.copyFile(origFile, tempFile);
@@ -491,8 +491,8 @@ public final class TestPackage extends TestCase {
* to another file, then delete both
*/
public void testOpenFileThenSaveDelete() throws Exception {
- File tempFile = File.createTempFile("poiTesting","tmp");
- File tempFile2 = File.createTempFile("poiTesting","tmp");
+ File tempFile = TempFile.createTempFile("poiTesting","tmp");
+ File tempFile2 = TempFile.createTempFile("poiTesting","tmp");
File origFile = OpenXML4JTestDataSamples.getSampleFile("TestPackageCommon.docx");
FileHelper.copyFile(origFile, tempFile);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
index 78e5d80a0f..de7eff6be7 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
@@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.util.TempFile;
import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
@@ -52,7 +53,7 @@ public final class TestXSSFTable {
}
// save the worksheet as-is using SXSSF
- File outputFile = File.createTempFile("poi-56274", ".xlsx");
+ File outputFile = TempFile.createTempFile("poi-56274", ".xlsx");
SXSSFWorkbook outputWorkbook = new org.apache.poi.xssf.streaming.SXSSFWorkbook(inputWorkbook);
outputWorkbook.write(new FileOutputStream(outputFile));