pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1729866 - /pdfbox/branches/1.8/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java
Date Thu, 11 Feb 2016 17:16:55 GMT
Author: tilman
Date: Thu Feb 11 17:16:55 2016
New Revision: 1729866

URL: http://svn.apache.org/viewvc?rev=1729866&view=rev
Log:
PDFBOX-1840: enable Isartor checks, use rev 1557331 from Guillaume Bailleul

Modified:
    pdfbox/branches/1.8/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java

Modified: pdfbox/branches/1.8/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java?rev=1729866&r1=1729865&r2=1729866&view=diff
==============================================================================
--- pdfbox/branches/1.8/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java
(original)
+++ pdfbox/branches/1.8/preflight/src/test/java/org/apache/pdfbox/preflight/TestIsartorValidationFromClasspath.java
Thu Feb 11 17:16:55 2016
@@ -21,26 +21,24 @@
 
 package org.apache.pdfbox.preflight;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
 import java.util.StringTokenizer;
 
-import junit.framework.Assert;
-
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
 import org.apache.pdfbox.preflight.exception.ValidationException;
 import org.apache.pdfbox.preflight.parser.PreflightParser;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -55,9 +53,9 @@ public class TestIsartorValidationFromCl
 
     protected String expectedError;
 
-    protected String path;
+    protected File path;
 
-    public TestIsartorValidationFromClasspath(String path, String error)
+    public TestIsartorValidationFromClasspath(File path, String error)
     {
         this.path = path;
         this.expectedError = error;
@@ -102,8 +100,8 @@ public class TestIsartorValidationFromCl
         PreflightDocument document = null;
         try
         {
-            System.out.println(path);
-            InputStream input = this.getClass().getResourceAsStream(path);
+            System.out.println(path.getName());
+            InputStream input = new FileInputStream(path);
 
             ValidationResult result = null;
             try
@@ -137,7 +135,7 @@ public class TestIsartorValidationFromCl
                 }
                 if (isartorResultFile != null)
                 {
-                    String log = path.replace(".pdf", "") + "#" + error.getErrorCode() +
"#" + error.getDetails()
+                    String log = path.getName().replace(".pdf", "") + "#" + error.getErrorCode()
+ "#" + error.getDetails()
                             + "\n";
                     isartorResultFile.write(log.getBytes());
                 }
@@ -170,34 +168,34 @@ public class TestIsartorValidationFromCl
         finally
         {
             if (document != null)
+            {
                 document.close();
+            }
         }
     }
 
-    @Parameters
+    @Parameters(name = "{0}")
     public static Collection<Object[]> initializeParameters() throws Exception
     {
         // load expected errors
         File f = new File("src/test/resources/expected_errors.txt");
-        System.out.println(f.exists());
         InputStream expected = new FileInputStream(f);
         Properties props = new Properties();
         props.load(expected);
         IOUtils.closeQuietly(expected);
         // prepare config
         List<Object[]> data = new ArrayList<Object[]>();
-        InputStream is = Class.class.getResourceAsStream("/Isartor testsuite.list");
-        if (is != null)
+        
+        File isartor = new File("target/pdfs/Isartor testsuite/PDFA-1b");
+        if (isartor.isDirectory())
         {
-            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"));
-            String line = reader.readLine();
-            while (line != null)
+            Collection<?> pdfFiles = FileUtils.listFiles(isartor,new String[] {"pdf","PDF"},true);
+            for (Object pdfFile : pdfFiles)
             {
-                String fn = new File(line).getName();
+                String fn = ((File) pdfFile).getName();
                 String error = new StringTokenizer(props.getProperty(fn), "//").nextToken().trim();
-                Object[] tmp = new Object[] { "/" + line, error };
+                Object [] tmp = new Object [] {(File)pdfFile,error};
                 data.add(tmp);
-                line = reader.readLine();
             }
         }
         else



Mime
View raw message