From d28720afd08d1998a7784f09e6cfd5ed9bec2dc9 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 25 Nov 2018 21:56:43 +0000 Subject: [PATCH] Add test for FileMagic JavaDoc warning fixes Remove some IDE warnings Reformat code of sample application git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1847437 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/stress/XSSFFileHandler.java | 9 +-- .../org/apache/poi/hpsf/VariantSupport.java | 2 +- .../poi/hpsf/wellknown/PropertyIDMap.java | 7 +- .../poi/hssf/model/InternalWorkbook.java | 2 + .../poi/hssf/record/RecordInputStream.java | 16 ++-- .../org/apache/poi/hssf/record/SSTRecord.java | 8 +- .../poi/hssf/record/SharedFormulaRecord.java | 6 +- .../hssf/record/SharedValueRecordBase.java | 12 +-- .../poi/util/RecordFormatException.java | 4 +- .../extractor/CommandLineTextExtractor.java | 66 +++++++-------- .../poi/openxml4j/opc/internal/ZipHelper.java | 2 - .../poi/ooxml/TestPOIXMLProperties.java | 5 +- .../extractor/TestXDGFVisioExtractor.java | 2 +- .../apache/poi/xssf/XSSFTestDataSamples.java | 51 +++++------- .../poi/poifs/filesystem/TestFileMagic.java | 80 +++++++++++++++++++ 15 files changed, 174 insertions(+), 98 deletions(-) create mode 100644 src/testcases/org/apache/poi/poifs/filesystem/TestFileMagic.java diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index 5c47d9af7e..48a30a2569 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -35,7 +35,6 @@ import java.util.Iterator; import java.util.Locale; import java.util.Set; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.apache.poi.EncryptedDocumentException; @@ -148,7 +147,7 @@ public class XSSFFileHandler extends SpreadsheetHandler { } private void exportToXML(XSSFWorkbook wb) throws SAXException, - ParserConfigurationException, TransformerException { + TransformerException { for (XSSFMap map : wb.getCustomXMLMappings()) { XSSFExportToXml exporter = new XSSFExportToXml(map); @@ -165,7 +164,6 @@ public class XSSFFileHandler extends SpreadsheetHandler { // zip-bomb EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764-2.xlsx"); - EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/54764.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/poc-xmlbomb.xlsx"); EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/poc-xmlbomb-empty.xlsx"); // strict OOXML @@ -185,18 +183,19 @@ public class XSSFFileHandler extends SpreadsheetHandler { public void handleAdditional(File file) throws Exception { // redirect stdout as the examples often write lots of text PrintStream oldOut = System.out; + String testFile = file.getParentFile().getName() + "/" + file.getName(); 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())); + EXPECTED_ADDITIONAL_FAILURES.contains(testFile)); } catch (OLE2NotOfficeXmlFileException e) { // we have some files that are not actually OOXML and thus cannot be tested here } catch (IllegalArgumentException | InvalidFormatException | POIXMLException | IOException e) { - if(!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) { + if(!EXPECTED_ADDITIONAL_FAILURES.contains(testFile)) { throw e; } } finally { diff --git a/src/java/org/apache/poi/hpsf/VariantSupport.java b/src/java/org/apache/poi/hpsf/VariantSupport.java index e60679027d..0e8dc08c6e 100644 --- a/src/java/org/apache/poi/hpsf/VariantSupport.java +++ b/src/java/org/apache/poi/hpsf/VariantSupport.java @@ -36,7 +36,7 @@ import org.apache.poi.util.POILogger; * Supports reading and writing of variant data.

* * FIXME (3): Reading and writing should be made more - * uniform than it is now. The following items should be resolved:

+ * uniform than it is now. The following items should be resolved: * *