diff options
Diffstat (limited to 'src/integrationtest/org/apache/poi')
19 files changed, 53 insertions, 46 deletions
diff --git a/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java b/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java index a9d5f8e6db..bff0cb1ba8 100644 --- a/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java +++ b/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java @@ -29,6 +29,7 @@ import java.util.zip.ZipException; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.OldFileFormatException; import org.apache.poi.poifs.filesystem.OfficeXmlFileException; +import org.junit.jupiter.api.Test; /** * This class is used for mass-regression testing via a @@ -37,7 +38,7 @@ import org.apache.poi.poifs.filesystem.OfficeXmlFileException; * types of files/exceptions, e.g. old file formats. * */ -public class BaseIntegrationTest { +class BaseIntegrationTest { private final File rootDir; private final String file; private FileHandler handler; @@ -48,7 +49,8 @@ public class BaseIntegrationTest { this.handler = handler; } - public void test() throws Exception { + @Test + void test() throws Exception { assertNotNull( handler, "Unknown file extension for file: " + file + ": " + TestAllFiles.getExtension(file) ); testOneFile(new File(rootDir, file)); } diff --git a/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java index 8fb6c65827..1d2ca65d4c 100644 --- a/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java @@ -31,7 +31,7 @@ import org.apache.poi.hdgf.streams.TrailerStream; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.junit.jupiter.api.Test; -public class HDGFFileHandler extends POIFSFileHandler { +class HDGFFileHandler extends POIFSFileHandler { @Override public void handleFile(InputStream stream, String path) throws IOException { POIFSFileSystem poifs = new POIFSFileSystem(stream); @@ -54,7 +54,7 @@ public class HDGFFileHandler extends POIFSFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Override @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/diagram/44501.vsd"); InputStream stream = new FileInputStream(file); diff --git a/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java index 91071adc23..34cf9ee5b9 100644 --- a/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java @@ -32,7 +32,7 @@ import org.apache.poi.poifs.filesystem.FileMagic; import org.apache.poi.util.LittleEndian; import org.junit.jupiter.api.Test; -public class HMEFFileHandler extends AbstractFileHandler { +class HMEFFileHandler extends AbstractFileHandler { @Override public void handleExtracting(File file) throws Exception { @@ -64,7 +64,7 @@ public class HMEFFileHandler extends AbstractFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Test - public void test() throws Exception { + void test() throws Exception { String path = "test-data/hmef/quick-winmail.dat"; try (InputStream stream = new FileInputStream(path)) { handleFile(stream, path); diff --git a/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java index a1152d58d4..419840d696 100644 --- a/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java @@ -27,7 +27,7 @@ import org.apache.poi.hpbf.extractor.PublisherTextExtractor; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.junit.jupiter.api.Test; -public class HPBFFileHandler extends POIFSFileHandler { +class HPBFFileHandler extends POIFSFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { HPBFDocument pub = new HPBFDocument(new POIFSFileSystem(stream)); @@ -42,7 +42,7 @@ public class HPBFFileHandler extends POIFSFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Override @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/publisher/SampleBrochure.pub"); InputStream stream = new FileInputStream(file); diff --git a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java index aafb700982..65ee09b428 100644 --- a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java @@ -43,7 +43,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.TempFile; import org.junit.jupiter.api.Test; -public class HPSFFileHandler extends POIFSFileHandler { +class HPSFFileHandler extends POIFSFileHandler { private static final String NL = System.getProperty("line.separator"); private static File copyOutput; @@ -120,7 +120,7 @@ public class HPSFFileHandler extends POIFSFileHandler { @Override @Test @SuppressWarnings("java:S2699") - public void test() throws Exception { + void test() throws Exception { String path = "test-data/diagram/44501.vsd"; try (InputStream stream = new FileInputStream(path)) { handleFile(stream, path); @@ -129,7 +129,7 @@ public class HPSFFileHandler extends POIFSFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Test - public void testExtractor() { + void testExtractor() { File file = new File("test-data/hpsf/TestBug44375.xls"); assertDoesNotThrow(() -> handleExtracting(file)); } diff --git a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java index a4ae15b090..3ea92dd078 100644 --- a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java @@ -29,7 +29,7 @@ import org.apache.poi.util.POILogger; import org.apache.poi.util.SystemOutLogger; import org.junit.jupiter.api.Test; -public class HSLFFileHandler extends SlideShowHandler { +class HSLFFileHandler extends SlideShowHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { HSLFSlideShowImpl slide = new HSLFSlideShowImpl(stream); @@ -51,14 +51,14 @@ public class HSLFFileHandler extends SlideShowHandler { } @Test - public void testOne() throws Exception { + void testOne() throws Exception { testOneFile(new File("test-data/slideshow/54880_chinese.ppt")); } // a test-case to test all .ppt files without executing the full TestAllFiles @Override @Test - public void test() throws Exception { + void test() throws Exception { File[] files = new File("test-data/slideshow/").listFiles((dir, name) -> name.endsWith(".ppt")); assertNotNull(files); diff --git a/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java index 9fa3160cda..8a21781bc4 100644 --- a/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java @@ -27,7 +27,7 @@ import org.apache.poi.hsmf.datatypes.AttachmentChunks; import org.apache.poi.hsmf.datatypes.DirectoryChunk; import org.junit.jupiter.api.Test; -public class HSMFFileHandler extends POIFSFileHandler { +class HSMFFileHandler extends POIFSFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { MAPIMessage mapi = new MAPIMessage(stream); @@ -77,7 +77,7 @@ public class HSMFFileHandler extends POIFSFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Override @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/hsmf/logsat.com_signatures_valid.msg"); try (InputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); diff --git a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java index 1069f23c25..9ee54b4790 100644 --- a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java @@ -36,7 +36,7 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.util.NullPrintStream; import org.junit.jupiter.api.Test; -public class HSSFFileHandler extends SpreadsheetHandler { +class HSSFFileHandler extends SpreadsheetHandler { private final POIFSFileHandler delegate = new POIFSFileHandler(); @Override public void handleFile(InputStream stream, String path) throws Exception { @@ -106,7 +106,7 @@ public class HSSFFileHandler extends SpreadsheetHandler { // a test-case to test this locally without executing the full TestAllFiles @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/spreadsheet/49219.xls"); try (InputStream stream = new FileInputStream(file)) { @@ -121,7 +121,7 @@ public class HSSFFileHandler extends SpreadsheetHandler { // a test-case to test this locally without executing the full TestAllFiles @Test @SuppressWarnings("java:S2699") - public void testExtractor() throws Exception { + void testExtractor() throws Exception { handleExtracting(new File("test-data/spreadsheet/BOOK_in_capitals.xls")); } }
\ No newline at end of file diff --git a/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java b/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java index 24b30e8abd..e4bada54d4 100644 --- a/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java +++ b/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; * Needs to be implemented in this package to have access to * HSSFWorkbook.getWorkbook() */ -public class HSSFRecordsStresser { +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) { @@ -65,7 +65,7 @@ public class HSSFRecordsStresser { // a test-case to test this locally without executing the full TestAllFiles @Test - public void test() throws Exception { + void test() throws Exception { try (InputStream stream = new FileInputStream(HSSFTestDataSamples.getSampleFile("15556.xls"))) { HSSFWorkbook wb = new HSSFWorkbook(stream); handleWorkbook(wb); diff --git a/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java index 260489c73e..da07a9b87b 100644 --- a/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java @@ -30,7 +30,7 @@ import org.apache.poi.hwpf.model.PicturesTable; import org.apache.poi.hwpf.usermodel.Picture; import org.junit.jupiter.api.Test; -public class HWPFFileHandler extends POIFSFileHandler { +class HWPFFileHandler extends POIFSFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { HWPFDocument doc = new HWPFDocument(stream); @@ -49,7 +49,7 @@ public class HWPFFileHandler extends POIFSFileHandler { @Override @Test @SuppressWarnings("java:S2699") - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/document/52117.doc"); try (InputStream stream = new FileInputStream(file)) { @@ -65,7 +65,7 @@ public class HWPFFileHandler extends POIFSFileHandler { } @Test - public void testExtractingOld() { + void testExtractingOld() { File file = new File("test-data/document/52117.doc"); assertDoesNotThrow(() -> handleExtracting(file)); } diff --git a/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java b/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java index 7746a37f49..c4f5485806 100644 --- a/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java @@ -30,7 +30,7 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.xwpf.usermodel.XWPFRelation; import org.junit.jupiter.api.Test; -public class OPCFileHandler extends AbstractFileHandler { +class OPCFileHandler extends AbstractFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { // ignore password protected files @@ -61,7 +61,7 @@ public class OPCFileHandler extends AbstractFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/diagram/test.vsdx"); try (InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000)) { diff --git a/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java b/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java index 99843096cd..b92f91f5f9 100644 --- a/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java @@ -30,7 +30,7 @@ import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.junit.jupiter.api.Test; -public class POIFSFileHandler extends AbstractFileHandler { +class POIFSFileHandler extends AbstractFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { @@ -69,7 +69,7 @@ public class POIFSFileHandler extends AbstractFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/poifs/Notes.ole2"); try (InputStream stream = new FileInputStream(file)) { diff --git a/src/integrationtest/org/apache/poi/stress/POIFileScanner.java b/src/integrationtest/org/apache/poi/stress/POIFileScanner.java index 6d235f1566..b0703d3dc4 100644 --- a/src/integrationtest/org/apache/poi/stress/POIFileScanner.java +++ b/src/integrationtest/org/apache/poi/stress/POIFileScanner.java @@ -49,7 +49,7 @@ import org.junit.jupiter.api.Test; * * Can also be used to get the appropriate FileHandler for a single file. */ -public class POIFileScanner { +class POIFileScanner { private final static File ROOT_DIR; static { // when running in Gradle, current directory might be "build/integrationtest" @@ -195,7 +195,7 @@ public class POIFileScanner { @Disabled @Test @SuppressForbidden("Just an ignored test") - public void testInvalidFile() throws IOException, InterruptedException { + void testInvalidFile() throws IOException, InterruptedException { FileHandler fileHandler = POIFileScanner.getFileHandler(new File("/usbc/CommonCrawl"), "www.bgs.ac.uk_downloads_directdownload.cfm_id=2362&noexcl=true&t=west_20sussex_20-_20building_20stone_20quarries"); @@ -210,13 +210,13 @@ public class POIFileScanner { } @Test - public void testDetectUnnamedFile() throws IOException { + void testDetectUnnamedFile() throws IOException { File root = new File(ROOT_DIR, "spreadsheet"); assertDoesNotThrow(() -> POIFileScanner.detectUnnamedFile(root, "49156.xlsx")); } @Test - public void test() throws IOException { + void test() throws IOException { assertDoesNotThrow(() -> POIFileScanner.scan(ROOT_DIR)); } } diff --git a/src/integrationtest/org/apache/poi/stress/TestAllFiles.java b/src/integrationtest/org/apache/poi/stress/TestAllFiles.java index bd52eddef5..bc5d7abf61 100644 --- a/src/integrationtest/org/apache/poi/stress/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/stress/TestAllFiles.java @@ -68,7 +68,7 @@ import org.opentest4j.TestAbortedException; * here as well! This is to ensure that files that should not work really do not work, e.g. * that we do not remove expected sanity checks. */ -public class TestAllFiles { +class TestAllFiles { private static final File ROOT_DIR = new File("test-data"); private static final boolean IGNORE_SCRATCHPAD = Boolean.getBoolean("scratchpad.ignore"); @@ -384,7 +384,7 @@ public class TestAllFiles { // ... even when using a custom display name generator @ParameterizedTest(name = "#{index} {0}" ) @MethodSource("files") - public void testAllFiles(String file, FileHandler handler) throws Exception { + void testAllFiles(String file, FileHandler handler) throws Exception { assertNotNull(handler, "Did not find a handler for file " + file); // this also removes the password for non encrypted files diff --git a/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java index b48a8bafef..d588e4b496 100644 --- a/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java @@ -23,7 +23,7 @@ import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.xdgf.usermodel.XmlVisioDocument; import org.junit.jupiter.api.Test; -public class XDGFFileHandler extends AbstractFileHandler { +class XDGFFileHandler extends AbstractFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { // ignore password protected files @@ -36,7 +36,7 @@ public class XDGFFileHandler extends AbstractFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Test @SuppressWarnings("java:S2699") - public void test() throws Exception { + void test() throws Exception { try (OPCPackage pkg = OPCPackage.open("test-data/diagram/test.vsdx", PackageAccess.READ)) { XmlVisioDocument doc = new XmlVisioDocument(pkg); new POIXMLDocumentHandler().handlePOIXMLDocument(doc); diff --git a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java index 6c54be4f7e..da83b55823 100644 --- a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java @@ -29,7 +29,7 @@ import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlideShow; import org.junit.jupiter.api.Test; -public class XSLFFileHandler extends SlideShowHandler { +class XSLFFileHandler extends SlideShowHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { XMLSlideShow slide = new XMLSlideShow(stream); @@ -71,7 +71,7 @@ public class XSLFFileHandler extends SlideShowHandler { // a test-case to test this locally without executing the full TestAllFiles @Override @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx"); try (InputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); diff --git a/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java index d2e4df1191..1bc23c49ed 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java @@ -16,7 +16,12 @@ ==================================================================== */ package org.apache.poi.stress; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; @@ -26,7 +31,7 @@ import org.apache.poi.xssf.extractor.XSSFBEventBasedExcelExtractor; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.junit.jupiter.api.Test; -public class XSSFBFileHandler extends AbstractFileHandler { +class XSSFBFileHandler extends AbstractFileHandler { static { //add expected failures here: @@ -81,7 +86,7 @@ public class XSSFBFileHandler extends AbstractFileHandler { } @Test - public void testLocal() throws Exception { + void testLocal() throws Exception { File file = new File("test-data/spreadsheet/Simple.xlsb"); try (FileInputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index ec060dee05..68f07b55be 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -57,7 +57,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; -public class XSSFFileHandler extends SpreadsheetHandler { +class XSSFFileHandler extends SpreadsheetHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { // ignore password protected files if password is unknown @@ -205,7 +205,7 @@ public class XSSFFileHandler extends SpreadsheetHandler { // a test-case to test this locally without executing the full TestAllFiles @Test - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/spreadsheet/ref-56737.xlsx"); try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) { @@ -216,7 +216,7 @@ public class XSSFFileHandler extends SpreadsheetHandler { } @Test - public void testAdditional() throws Exception { + void testAdditional() throws Exception { handleAdditional(new File("test-data/spreadsheet/poc-xmlbomb.xlsx")); } } diff --git a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java index 92bfabbc49..c688c54758 100644 --- a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java @@ -24,7 +24,7 @@ import java.io.InputStream; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.junit.jupiter.api.Test; -public class XWPFFileHandler extends AbstractFileHandler { +class XWPFFileHandler extends AbstractFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { // ignore password protected files @@ -38,7 +38,7 @@ public class XWPFFileHandler extends AbstractFileHandler { // a test-case to test this locally without executing the full TestAllFiles @Test @SuppressWarnings("java:S2699") - public void test() throws Exception { + void test() throws Exception { File file = new File("test-data/document/51921-Word-Crash067.docx"); try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) { |