poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1808506 - in /poi/trunk: build.xml src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java
Date Sat, 16 Sep 2017 08:20:50 GMT
Author: centic
Date: Sat Sep 16 08:20:50 2017
New Revision: 1808506

URL: http://svn.apache.org/viewvc?rev=1808506&view=rev
Log:
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

Modified:
    poi/trunk/build.xml
    poi/trunk/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java

Modified: poi/trunk/build.xml
URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=1808506&r1=1808505&r2=1808506&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Sat Sep 16 08:20:50 2017
@@ -445,6 +445,8 @@ under the License.
         <path refid="ooxml.classpath"/>
         <path refid="ooxml.xmlsec.classpath"/>
         <path refid="excelant.classpath"/>
+        <path refid="examples.classpath"/>
+        <pathelement location="${examples.output.dir}"/>
         <path path="${env.CLASSPATH}"/>
     </path>
 
@@ -1978,6 +1980,9 @@ under the License.
         <maven-jar dir="${excelant.src}"/>
     </target>
 
+    <target name="integration-test-jar" depends="compile-integration,-manifest" description="target
for packaging the integration-test code for mass regression test runs">
+        <maven-jar dir="${integration.output.test.dir}"/>
+    </target>
 
     <target name="-do-jar-check-javadocs-package-list">
         <condition property="javadocs.package-list.present">
@@ -2228,7 +2233,7 @@ under the License.
     <!--  spot any cases where we've accidently used methods we shouldn't -->
     <!-- See https://github.com/policeman-tools/forbidden-apis for details -->
     <!--  of the checks that this can do -->
-    <target name="forbidden-apis-check" depends="init, compile">
+    <target name="forbidden-apis-check" depends="init, compile, compile-integration">
         <taskdef name="forbiddenapis"
                  classname="de.thetaphi.forbiddenapis.ant.AntTask"
                  classpath="${forbidden.jar}"/>
@@ -2262,6 +2267,7 @@ under the License.
             <!--
             <fileset dir="${scratchpad.output.test.dir}"/>
             <fileset dir="${excelant.output.test.dir}"/>
+            <fileset dir="${integration.output.test.dir}"/>
             -->
         </forbiddenapis>
 
@@ -2277,6 +2283,7 @@ under the License.
             <fileset dir="${ooxml.output.dir}"/>
             <fileset dir="${scratchpad.output.dir}"/>
             <fileset dir="${excelant.output.dir}"/>
+            <fileset dir="${integration.output.test.dir}"/>
         </forbiddenapis>
     </target>
 

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java?rev=1808506&r1=1808505&r2=1808506&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java Sat Sep 16 08:20:50
2017
@@ -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"));
-	}
+    @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
+    // 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);
-
-		System.out.println("Testing " + files.length + " files");
-
-		for(File file : files) {
-			try {
-				testOneFile(file);
-			} catch (Throwable e) {
-				e.printStackTrace();
-			}
-		}
-   }
-
-	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 {
+    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);
+
+        System.out.println("Testing " + files.length + " files");
+
+        POILogger logger = new SystemOutLogger();
+        for(File file : files) {
+            try {
+                testOneFile(file);
+            } catch (Throwable e) {
+                logger.log(POILogger.WARN, "Failed to handle file " + file, e);
+            }
+        }
+    }
+
+    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();
-		}
-
-		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();
-	   }
-   }
+        } finally {
+            stream.close();
+        }
+
+        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();
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message