From 92ae9ce5e0d3f99ca8c3dbbcda1ff7182d1c3224 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sat, 16 Sep 2017 08:20:50 +0000 Subject: [PATCH] Allow to produce a jar for the integration-test-code so we can use it directly in the mass-regression tests without having to copy it for every run. Enable some forbidden-api-checks for integration-test code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808506 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 9 +- .../apache/poi/stress/HSLFFileHandler.java | 129 +++++++++--------- 2 files changed, 74 insertions(+), 64 deletions(-) diff --git a/build.xml b/build.xml index ccd88d7e6..f46c3ebdd 100644 --- a/build.xml +++ b/build.xml @@ -445,6 +445,8 @@ under the License. + + @@ -1978,6 +1980,9 @@ under the License. + + + @@ -2228,7 +2233,7 @@ under the License. - + @@ -2262,6 +2267,7 @@ under the License. @@ -2277,6 +2283,7 @@ under the License. + diff --git a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java index fcf0324fe..1d075df89 100644 --- a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java @@ -24,78 +24,81 @@ import java.io.*; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; +import org.apache.poi.util.POILogger; +import org.apache.poi.util.SystemOutLogger; import org.junit.Test; public class HSLFFileHandler extends SlideShowHandler { - @Override - public void handleFile(InputStream stream, String path) throws Exception { - HSLFSlideShowImpl slide = new HSLFSlideShowImpl(stream); - assertNotNull(slide.getCurrentUserAtom()); - assertNotNull(slide.getEmbeddedObjects()); - assertNotNull(slide.getUnderlyingBytes()); - assertNotNull(slide.getPictureData()); - Record[] records = slide.getRecords(); - assertNotNull(records); - for(Record record : records) { - assertNotNull("Found a record which was null", record); - assertTrue(record.getRecordType() >= 0); - } - - handlePOIDocument(slide); - - HSLFSlideShow ss = new HSLFSlideShow(slide); - handleSlideShow(ss); - } - - @Test - public void testOne() throws Exception { - testOneFile(new File("test-data/slideshow/54880_chinese.ppt")); - } - - // a test-case to test this locally without executing the full TestAllFiles - @Override + @Override + public void handleFile(InputStream stream, String path) throws Exception { + HSLFSlideShowImpl slide = new HSLFSlideShowImpl(stream); + assertNotNull(slide.getCurrentUserAtom()); + assertNotNull(slide.getEmbeddedObjects()); + assertNotNull(slide.getUnderlyingBytes()); + assertNotNull(slide.getPictureData()); + Record[] records = slide.getRecords(); + assertNotNull(records); + for(Record record : records) { + assertNotNull("Found a record which was null", record); + assertTrue(record.getRecordType() >= 0); + } + + handlePOIDocument(slide); + + HSLFSlideShow ss = new HSLFSlideShow(slide); + handleSlideShow(ss); + } + @Test - public void test() throws Exception { - File[] files = new File("test-data/slideshow/").listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".ppt"); - } - }); - assertNotNull(files); + public void testOne() throws Exception { + testOneFile(new File("test-data/slideshow/54880_chinese.ppt")); + } - System.out.println("Testing " + files.length + " files"); + // a test-case to test all .ppt files without executing the full TestAllFiles + @Override + @Test + public void test() throws Exception { + File[] files = new File("test-data/slideshow/").listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".ppt"); + } + }); + assertNotNull(files); - for(File file : files) { - try { - testOneFile(file); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } + System.out.println("Testing " + files.length + " files"); - private void testOneFile(File file) throws Exception { - System.out.println(file); + POILogger logger = new SystemOutLogger(); + for(File file : files) { + try { + testOneFile(file); + } catch (Throwable e) { + logger.log(POILogger.WARN, "Failed to handle file " + file, e); + } + } + } - //System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger"); - InputStream stream = new FileInputStream(file); - try { + private void testOneFile(File file) throws Exception { + System.out.println(file); + + //System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger"); + InputStream stream = new FileInputStream(file); + try { handleFile(stream, file.getPath()); - } finally { - stream.close(); - } + } finally { + stream.close(); + } - handleExtracting(file); - } + handleExtracting(file); + } - public static void main(String[] args) throws Exception { - System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger"); - InputStream stream = new FileInputStream(args[0]); - try { - new HSLFFileHandler().handleFile(stream, args[0]); - } finally { - stream.close(); - } - } + public static void main(String[] args) throws Exception { + System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger"); + InputStream stream = new FileInputStream(args[0]); + try { + new HSLFFileHandler().handleFile(stream, args[0]); + } finally { + stream.close(); + } + } }