diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-07-22 22:08:33 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-07-22 22:08:33 +0000 |
commit | c0f99416047be7c3b7e5413d7a0187a21022a02b (patch) | |
tree | 4c0861aa3dc9634684a8048b855426276eebb96b /src/integrationtest | |
parent | 800da8b29095a06283380f9adb2c1202a23ee57e (diff) | |
download | poi-c0f99416047be7c3b7e5413d7a0187a21022a02b.tar.gz poi-c0f99416047be7c3b7e5413d7a0187a21022a02b.zip |
#64411 - Provide JigSaw modules
- use classpath-build for Java 8, otherwise use modulepath
- save module-info classes to source, when using Java 9+ environment
- rename example packages - otherwise package clashes occured in the tests
- move agile encryption from ooxml to main.
remove EncryptionInfo XmlBeans and schema and use custom xml marshalling
- move ooxml test classes which reside in the same package as their tested main class
- rename base test classes to "BaseTest..." - temporarily I've used a light version of the main test classes to test scratchpad / ooxml
- build.xml - fixed the Rhino javascript errors of the dependency-macros
- DrawTextParagraph - fixed StringIndexOutOfBounds when logging set to debug level
- use JigSaw provider interface (= Java ServiceLoader), i.e. it wasn't possible (without openening everything), to access ooxml factory classes from main factory stub
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1880164 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/integrationtest')
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java (renamed from src/integrationtest/org/apache/poi/BaseIntegrationTest.java) | 17 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java | 2 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java (renamed from src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java) | 5 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HeapDump.java (renamed from src/integrationtest/org/apache/poi/HeapDump.java) | 6 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/POIFileScanner.java (renamed from src/integrationtest/org/apache/poi/POIFileScanner.java) | 30 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/TestAllFiles.java (renamed from src/integrationtest/org/apache/poi/TestAllFiles.java) | 20 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java | 26 |
7 files changed, 42 insertions, 64 deletions
diff --git a/src/integrationtest/org/apache/poi/BaseIntegrationTest.java b/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java index 10c534eacc..8abe9fcff0 100644 --- a/src/integrationtest/org/apache/poi/BaseIntegrationTest.java +++ b/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java @@ -14,17 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; +package org.apache.poi.stress; -import org.apache.poi.poifs.filesystem.OfficeXmlFileException; -import org.apache.poi.stress.FileHandler; -import org.apache.poi.stress.HSLFFileHandler; -import org.apache.poi.stress.HSSFFileHandler; -import org.apache.poi.stress.HWPFFileHandler; -import org.apache.poi.stress.XSLFFileHandler; -import org.apache.poi.stress.XSSFFileHandler; -import org.apache.poi.stress.XWPFFileHandler; -import org.junit.Assume; +import static org.junit.Assert.assertNotNull; import java.io.BufferedInputStream; import java.io.File; @@ -33,7 +25,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipException; -import static org.junit.Assert.assertNotNull; +import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.OldFileFormatException; +import org.apache.poi.poifs.filesystem.OfficeXmlFileException; +import org.junit.Assume; /** * This class is used for mass-regression testing via a diff --git a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java index ba2e1bc617..2c125db1c0 100644 --- a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java @@ -30,12 +30,12 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; +import org.apache.poi.examples.hpsf.CopyCompare; import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument; import org.apache.poi.hpsf.MarkUnsupportedException; import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.SummaryInformation; -import org.apache.poi.hpsf.examples.CopyCompare; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentInputStream; import org.apache.poi.poifs.filesystem.POIFSFileSystem; diff --git a/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java b/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java index d277d40e8a..932fd396b1 100644 --- a/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java +++ b/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel; +package org.apache.poi.stress; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -25,13 +25,14 @@ import java.io.InputStream; import java.util.List; import org.apache.poi.hssf.record.Record; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.junit.Test; /** * Needs to be implemented in this package to have access to * HSSFWorkbook.getWorkbook() */ -public class RecordsStresser { +public class HSSFRecordsStresser { public static void handleWorkbook(HSSFWorkbook wb) { List<org.apache.poi.hssf.record.Record> records = wb.getWorkbook().getRecords(); for(org.apache.poi.hssf.record.Record record : records) { diff --git a/src/integrationtest/org/apache/poi/HeapDump.java b/src/integrationtest/org/apache/poi/stress/HeapDump.java index 625527d84e..59a3832b59 100644 --- a/src/integrationtest/org/apache/poi/HeapDump.java +++ b/src/integrationtest/org/apache/poi/stress/HeapDump.java @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; - -import com.sun.management.HotSpotDiagnosticMXBean; +package org.apache.poi.stress; import java.io.IOException; import java.lang.management.ManagementFactory; +import com.sun.management.HotSpotDiagnosticMXBean; + public class HeapDump { // This is the name of the HotSpot Diagnostic MBean private static final String HOTSPOT_BEAN_NAME = diff --git a/src/integrationtest/org/apache/poi/POIFileScanner.java b/src/integrationtest/org/apache/poi/stress/POIFileScanner.java index 4e8c002c9d..947e709dd2 100644 --- a/src/integrationtest/org/apache/poi/POIFileScanner.java +++ b/src/integrationtest/org/apache/poi/stress/POIFileScanner.java @@ -17,7 +17,18 @@ * ==================================================================== */ -package org.apache.poi; +package org.apache.poi.stress; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hwpf.HWPFDocument; @@ -25,25 +36,12 @@ import org.apache.poi.poifs.filesystem.FileMagic; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.stress.FileHandler; -import org.apache.poi.stress.XSSFFileHandler; import org.apache.poi.util.SuppressForbidden; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.tools.ant.DirectoryScanner; import org.junit.Ignore; import org.junit.Test; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - /** * Helper class to scan a folder for files and return a collection of * found files together with the matching {@link FileHandler}. @@ -65,7 +63,7 @@ public class POIFileScanner { * Scan a folder for files and return a collection of * found files together with the matching {@link FileHandler}. * - * Note: unknown files will be assigned to {@link org.apache.poi.TestAllFiles.NullFileHandler} + * Note: unknown files will be assigned to {@link TestAllFiles.NullFileHandler} * * @param rootDir The directory to scan * @return A collection with file-FileHandler pairs which can be used for running tests on that file @@ -110,7 +108,7 @@ public class POIFileScanner { * * @param rootDir The directory where the file resides * @param file The name of the file without directory - * @return The matching {@link FileHandler}, A {@link org.apache.poi.TestAllFiles.NullFileHandler} + * @return The matching {@link FileHandler}, A {@link TestAllFiles.NullFileHandler} * is returned if no match is found * @throws IOException If determining the file-type fails */ diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/stress/TestAllFiles.java index 6a54ba2d45..d95b156ccc 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/stress/TestAllFiles.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; +package org.apache.poi.stress; import static org.junit.Assert.assertFalse; @@ -35,25 +35,9 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import org.apache.poi.OldFileFormatException; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.poifs.crypt.Decryptor; -import org.apache.poi.stress.AbstractFileHandler; -import org.apache.poi.stress.FileHandler; -import org.apache.poi.stress.HDGFFileHandler; -import org.apache.poi.stress.HMEFFileHandler; -import org.apache.poi.stress.HPBFFileHandler; -import org.apache.poi.stress.HPSFFileHandler; -import org.apache.poi.stress.HSLFFileHandler; -import org.apache.poi.stress.HSMFFileHandler; -import org.apache.poi.stress.HSSFFileHandler; -import org.apache.poi.stress.HWPFFileHandler; -import org.apache.poi.stress.OPCFileHandler; -import org.apache.poi.stress.POIFSFileHandler; -import org.apache.poi.stress.XDGFFileHandler; -import org.apache.poi.stress.XSLFFileHandler; -import org.apache.poi.stress.XSSFBFileHandler; -import org.apache.poi.stress.XSSFFileHandler; -import org.apache.poi.stress.XWPFFileHandler; import org.apache.tools.ant.DirectoryScanner; import org.junit.AssumptionViolatedException; import org.junit.Before; diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index 0505d72df9..c0f88768b8 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -38,8 +38,11 @@ import java.util.Set; import javax.xml.transform.TransformerException; import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.ooxml.POIXMLException; +import org.apache.poi.examples.ss.ExcelComparator; +import org.apache.poi.examples.xssf.eventusermodel.FromHowTo; +import org.apache.poi.examples.xssf.eventusermodel.XLSX2CSV; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; +import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; @@ -47,11 +50,8 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.ss.examples.ExcelComparator; import org.apache.poi.util.IOUtils; -import org.apache.poi.xssf.eventusermodel.XLSX2CSV; import org.apache.poi.xssf.eventusermodel.XSSFReader; -import org.apache.poi.xssf.eventusermodel.examples.FromHowTo; import org.apache.poi.xssf.extractor.XSSFExportToXml; import org.apache.poi.xssf.usermodel.XSSFMap; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -99,27 +99,27 @@ public class XSSFFileHandler extends SpreadsheetHandler { // use the combined handler for HSSF/XSSF handleWorkbook(wb); - + // TODO: some documents fail currently... //XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); //evaluator.evaluateAll(); // also verify general POIFS-stuff new POIXMLDocumentHandler().handlePOIXMLDocument(wb); - + // and finally ensure that exporting to XML works exportToXML(wb); // this allows to trigger a heap-dump at this point to see which memory is still allocated //HeapDump.dumpHeap("/tmp/poi.hprof", false); - + wb.close(); } private void checkXSSFReader(OPCPackage p) throws IOException, OpenXML4JException { XSSFReader reader = new XSSFReader(p); - + // these can be null... InputStream sharedStringsData = reader.getSharedStringsData(); if(sharedStringsData != null) { @@ -132,21 +132,21 @@ public class XSSFFileHandler extends SpreadsheetHandler { stylesData.close(); } reader.getStylesTable(); - + InputStream themesData = reader.getThemesData(); if(themesData != null) { themesData.close(); } assertNotNull(reader.getWorkbookData()); - + Iterator<InputStream> sheetsData = reader.getSheetsData(); while(sheetsData.hasNext()) { InputStream str = sheetsData.next(); str.close(); } } - + private void exportToXML(XSSFWorkbook wb) throws SAXException, TransformerException { for (XSSFMap map : wb.getCustomXMLMappings()) { @@ -221,8 +221,8 @@ public class XSSFFileHandler extends SpreadsheetHandler { public void testAdditional() throws Exception { handleAdditional(new File("test-data/spreadsheet/poc-xmlbomb.xlsx")); } - - // need to override all methods to omit calls to UTF-handling methods + + // need to override all methods to omit calls to UTF-handling methods static class NullPrintStream extends PrintStream { @SuppressWarnings("resource") NullPrintStream() { |