use of org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException in project poi by apache.
the class XSSFFileHandler method handleAdditional.
@SuppressWarnings("resource")
@Override
public void handleAdditional(File file) throws Exception {
// redirect stdout as the examples often write lots of text
PrintStream oldOut = System.out;
try {
System.setOut(new NullPrintStream());
FromHowTo.main(new String[] { file.getAbsolutePath() });
XLSX2CSV.main(new String[] { file.getAbsolutePath() });
assertFalse("Expected Extraction to fail for file " + file + " and handler " + this + ", but did not fail!", EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName()));
} catch (OLE2NotOfficeXmlFileException e) {
// we have some files that are not actually OOXML and thus cannot be tested here
} catch (IllegalArgumentException e) {
if (!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) {
throw e;
}
} catch (InvalidFormatException e) {
if (!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) {
throw e;
}
} catch (IOException e) {
if (!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) {
throw e;
}
} catch (POIXMLException e) {
if (!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) {
throw e;
}
} finally {
System.setOut(oldOut);
}
}
Aggregations