diff --git a/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java b/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java index d7d5b6a3f..eeccc0510 100644 --- a/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; @@ -32,7 +31,6 @@ import org.apache.poi.POIOLE2TextExtractor; import org.apache.poi.POITextExtractor; import org.apache.poi.extractor.ExtractorFactory; import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.xmlbeans.XmlException; @@ -52,9 +50,7 @@ public abstract class AbstractFileHandler implements FileHandler { EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug52400-winmail-simple.dat"); EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug52400-winmail-with-attachments.dat"); EXPECTED_EXTRACTOR_FAILURES.add("hpsf/Test0313rur.adm"); - EXPECTED_EXTRACTOR_FAILURES.add("hsmf/attachment_msg_pdf.msg"); EXPECTED_EXTRACTOR_FAILURES.add("poifs/Notes.ole2"); - EXPECTED_EXTRACTOR_FAILURES.add("slideshow/testPPT.thmx"); } public void handleExtracting(File file) throws Exception { @@ -94,7 +90,7 @@ public abstract class AbstractFileHandler implements FileHandler { assertNotNull(metadataExtractor.getText()); assertFalse("Expected Extraction to fail for file " + file + " and handler " + this + ", but did not fail!", - EXPECTED_EXTRACTOR_FAILURES.contains(file)); + EXPECTED_EXTRACTOR_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())); assertEquals("File should not be modified by extractor", length, file.length()); assertEquals("File should not be modified by extractor", modified, file.lastModified()); @@ -114,7 +110,7 @@ public abstract class AbstractFileHandler implements FileHandler { } } } catch (IllegalArgumentException e) { - if(!EXPECTED_EXTRACTOR_FAILURES.contains(file)) { + if(!EXPECTED_EXTRACTOR_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) { throw e; } } finally { @@ -122,9 +118,7 @@ public abstract class AbstractFileHandler implements FileHandler { } } - private void handleExtractingAsStream(File file) throws FileNotFoundException, - IOException, InvalidFormatException, OpenXML4JException, - XmlException { + private void handleExtractingAsStream(File file) throws IOException, OpenXML4JException, XmlException { InputStream stream = new FileInputStream(file); try { POITextExtractor streamExtractor = ExtractorFactory.createExtractor(stream); diff --git a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java index dd579c4db..005dd1ade 100644 --- a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java @@ -28,7 +28,7 @@ public class HSSFFileHandler extends SpreadsheetHandler { @Override public void handleFile(InputStream stream) throws Exception { HSSFWorkbook wb = new HSSFWorkbook(stream); - handleWorkbook(wb, ".xls"); + handleWorkbook(wb); // TODO: some documents fail currently... //HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); diff --git a/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java b/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java index 49a74d06d..adf8f16e7 100644 --- a/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java +++ b/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertNotNull; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; import java.io.IOException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; @@ -32,18 +31,18 @@ import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.util.RecordFormatException; public abstract class SpreadsheetHandler extends AbstractFileHandler { - public void handleWorkbook(Workbook wb, String extension) throws IOException { + public void handleWorkbook(Workbook wb) throws IOException { // try to access some of the content readContent(wb); // write out the file - ByteArrayOutputStream out = writeToArray(wb); + writeToArray(wb); // access some more content (we had cases where writing corrupts the data in memory) readContent(wb); // write once more - out = writeToArray(wb); + ByteArrayOutputStream out = writeToArray(wb); // read in the writen file Workbook read; @@ -61,8 +60,7 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler { read.close(); } - private ByteArrayOutputStream writeToArray(Workbook wb) - throws FileNotFoundException, IOException { + private ByteArrayOutputStream writeToArray(Workbook wb) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { wb.write(stream); @@ -88,7 +86,7 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler { for(Row row : sheet) { for(Cell cell : row) { - cell.toString(); + assertNotNull(cell.toString()); } } } diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index cf893949f..8dfa65fb2 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -30,7 +30,6 @@ import java.util.Iterator; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.util.IOUtils; @@ -55,7 +54,7 @@ public class XSSFFileHandler extends SpreadsheetHandler { wb = new XSSFWorkbook(new ByteArrayInputStream(bytes)); // use the combined handler for HSSF/XSSF - handleWorkbook(wb, ".xlsx"); + handleWorkbook(wb); // TODO: some documents fail currently... //XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); @@ -73,8 +72,7 @@ public class XSSFFileHandler extends SpreadsheetHandler { } - private void checkXSSFReader(OPCPackage p) - throws IOException, OpenXML4JException, InvalidFormatException { + private void checkXSSFReader(OPCPackage p) throws IOException, OpenXML4JException { XSSFReader reader = new XSSFReader(p); // these can be null...