diff --git a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java index 39b520fd0..c6bb03c1e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java @@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.List; import org.apache.poi.POIDataSamples; import org.apache.poi.ss.ITestDataProvider; @@ -40,7 +41,9 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; public final class SXSSFITestDataProvider implements ITestDataProvider { public static final SXSSFITestDataProvider instance = new SXSSFITestDataProvider(); - private ArrayList instances = new ArrayList(); + // an instance of all SXSSFWorkbooks opened by this TestDataProvider, + // so that the temporary files created can be disposed up by cleanup() + private final List instances = new ArrayList(); private SXSSFITestDataProvider() { // enforce singleton diff --git a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java index 953b6a180..3ceac02a5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java @@ -35,10 +35,12 @@ public final class XSSFITestDataProvider implements ITestDataProvider { // enforce singleton } + @Override public XSSFWorkbook openSampleWorkbook(String sampleFileName) { return XSSFTestDataSamples.openSampleWorkbook(sampleFileName); } + @Override public XSSFWorkbook writeOutAndReadBack(Workbook original) { if(!(original instanceof XSSFWorkbook)) { throw new IllegalArgumentException("Expected an instance of XSSFWorkbook, but had " + original.getClass()); @@ -46,22 +48,27 @@ public final class XSSFITestDataProvider implements ITestDataProvider { return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original); } - public XSSFWorkbook createWorkbook(){ + @Override + public XSSFWorkbook createWorkbook() { return new XSSFWorkbook(); } + @Override public FormulaEvaluator createFormulaEvaluator(Workbook wb) { return new XSSFFormulaEvaluator((XSSFWorkbook) wb); } + @Override public byte[] getTestDataFileContent(String fileName) { return POIDataSamples.getSpreadSheetInstance().readFile(fileName); } + @Override public SpreadsheetVersion getSpreadsheetVersion(){ return SpreadsheetVersion.EXCEL2007; } + @Override public String getStandardFileNameExtension() { return "xlsx"; } diff --git a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java index d544b0b79..20ec0965b 100644 --- a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java +++ b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java @@ -37,13 +37,16 @@ public final class HSSFITestDataProvider implements ITestDataProvider { // enforce singleton } + @Override public HSSFWorkbook openSampleWorkbook(String sampleFileName) { return HSSFTestDataSamples.openSampleWorkbook(sampleFileName); } + public InputStream openWorkbookStream(String sampleFileName) { return HSSFTestDataSamples.openSampleFileStream(sampleFileName); } + @Override public HSSFWorkbook writeOutAndReadBack(Workbook original) { if(!(original instanceof HSSFWorkbook)) { throw new IllegalArgumentException("Expected an instance of HSSFWorkbook"); @@ -51,22 +54,27 @@ public final class HSSFITestDataProvider implements ITestDataProvider { return HSSFTestDataSamples.writeOutAndReadBack((HSSFWorkbook)original); } + @Override public HSSFWorkbook createWorkbook(){ return new HSSFWorkbook(); } + @Override public FormulaEvaluator createFormulaEvaluator(Workbook wb) { return new HSSFFormulaEvaluator((HSSFWorkbook) wb); } + @Override public byte[] getTestDataFileContent(String fileName) { return POIDataSamples.getSpreadSheetInstance().readFile(fileName); } + @Override public SpreadsheetVersion getSpreadsheetVersion(){ return SpreadsheetVersion.EXCEL97; } + @Override public String getStandardFileNameExtension() { return "xls"; }