pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r907530 - in /pdfbox/trunk: build.xml logging.properties pom.xml src/test/java/org/apache/pdfbox/util/TestPDFToImage.java src/test/java/org/apache/pdfbox/util/TestTextStripper.java src/test/resources/logging.properties
Date Mon, 08 Feb 2010 00:42:24 GMT
Author: jukka
Date: Mon Feb  8 00:42:24 2010
New Revision: 907530

URL: http://svn.apache.org/viewvc?rev=907530&view=rev
Log:
PDFBOX-545: Switch PDFBox build to Maven

Make all tests use Commons Logging and sync the Maven and Ant use of the logging.properties
file.

Added:
    pdfbox/trunk/src/test/resources/logging.properties
      - copied, changed from r907513, pdfbox/trunk/logging.properties
Removed:
    pdfbox/trunk/logging.properties
Modified:
    pdfbox/trunk/build.xml
    pdfbox/trunk/pom.xml
    pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
    pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java

Modified: pdfbox/trunk/build.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/build.xml?rev=907530&r1=907529&r2=907530&view=diff
==============================================================================
--- pdfbox/trunk/build.xml (original)
+++ pdfbox/trunk/build.xml Mon Feb  8 00:42:24 2010
@@ -266,7 +266,8 @@
             <jvmarg value="-Xmx1024M"/>
             <jvmarg value="-Xms512M"/>
             <sysproperty key="org.apache.pdfbox.util.TextStripper.file" value="${file}"/>
-            <sysproperty key="java.util.logging.config.file" value="logging.properties"/>
+            <sysproperty key="java.util.logging.config.file"
+                         value="src/test/resources/logging.properties"/>
             <classpath>
                 <pathelement path="${junit.jar}" />
                 <pathelement path="${ant.jar}" />
@@ -292,7 +293,8 @@
             <jvmarg value="-Xms512M"/>
 
             <sysproperty key="org.apache.pdfbox.util.TextStripper.file" value="${file}"/>
-            <sysproperty key="java.util.logging.config.file" value="logging.properties"/>
+            <sysproperty key="java.util.logging.config.file"
+                         value="src/test/resources/logging.properties"/>
             <classpath>
                 <pathelement path="${junit.jar}" />
                 <pathelement path="${ant.jar}" />
@@ -314,7 +316,8 @@
 
     <target name="test-junit" depends="clean,compile" description="run junit tests">
         <junit printsummary="off" fork="on" dir=".">
-            <sysproperty key="java.util.logging.config.file" value="logging.properties"/>
+            <sysproperty key="java.util.logging.config.file"
+                         value="src/test/resources/logging.properties"/>
             <classpath>
                 <pathelement path="${junit.jar}" />
                 <pathelement path="${ant.jar}" />

Modified: pdfbox/trunk/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pom.xml?rev=907530&r1=907529&r2=907530&view=diff
==============================================================================
--- pdfbox/trunk/pom.xml (original)
+++ pdfbox/trunk/pom.xml Mon Feb  8 00:42:24 2010
@@ -163,6 +163,7 @@
       </plugin>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.5</version>
         <configuration>
           <includes>
             <include>org/apache/pdfbox/TestAll.java</include>
@@ -171,6 +172,9 @@
             <include>org/apache/pdfbox/util/TestPDFToImage.java</include>
             -->
           </includes>
+          <systemPropertyVariables>
+            <java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
+          </systemPropertyVariables>
         </configuration>
       </plugin>
       <plugin>

Modified: pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java?rev=907530&r1=907529&r2=907530&view=diff
==============================================================================
--- pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java (original)
+++ pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java Mon Feb  8 00:42:24
2010
@@ -18,15 +18,15 @@
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileWriter;
 import java.io.FilenameFilter;
 import java.io.IOException;
-import java.io.PrintWriter;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.PDDocument;
 
 /**
@@ -56,9 +56,14 @@
  */
 public class TestPDFToImage extends TestCase
 {
+
+    /**
+     * Logger instance.
+     */
+    private static final Log log = LogFactory.getLog(TestPDFToImage.class);
+
     private boolean bFail = false;
     private PDFImageWriter writer = null;
-    private PrintWriter log = null;
     private File mcurFile = null;
 
     /**
@@ -99,8 +104,7 @@
     {
         PDDocument document = null;
 
-        log.println("\nPreparing to convert " + file.getName());
-        log.flush();
+        log.info("Preparing to convert " + file.getName());
         try
         {
             document =  PDDocument.load(file);
@@ -109,10 +113,7 @@
         catch(Exception e)
         { 
             this.bFail=true;
-            System.err.println("Error converting file " + file.getName());
-            e.printStackTrace();
-            log.println("Error converting file " + file.getName() + "\n" + e);
-
+            log.error("Error converting file " + file.getName(), e);
         }
         finally
         {
@@ -138,15 +139,14 @@
                         !filesAreIdentical(outFiles[n], inFile))
                     {
                         this.bFail=true;
-                        log.println("Input and output not identical for file: " + inFile.getName());
+                        log.info("Input and output not identical for file: " + inFile.getName());
                     }
                 }
         }
         catch(Exception e)
         {
             this.bFail=true;
-            System.err.println("Error comparing file output for " + file.getName());
-            e.printStackTrace();
+            log.error("Error comparing file output for " + file.getName(), e);
         }
 
     }
@@ -165,10 +165,6 @@
         String inDirExt = new String("test/input-ext/rendering/");
         String outDirExt = new String("test/output-ext/rendering/");
 
-        try
-        {
-            log = new PrintWriter( new FileWriter( "RenderImage.log" ) );
-
             if ((filename == null) || (filename.length() == 0))
             {
                 File[] testFiles = new File(inDir).listFiles(new FilenameFilter()
@@ -207,14 +203,6 @@
             {
                 fail("One or more failures, see test log for details");
             }
-        }
-        finally
-        {
-            if( log != null )
-            {
-                log.close();
-            }
-        }
     }
 
     /**

Modified: pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java?rev=907530&r1=907529&r2=907530&view=diff
==============================================================================
--- pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java (original)
+++ pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java Mon Feb  8 00:42:24
2010
@@ -18,7 +18,6 @@
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileWriter;
 import java.io.FilenameFilter;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -26,13 +25,14 @@
 import java.io.LineNumberReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
 import java.io.Writer;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.PDDocument;
 
 
@@ -85,9 +85,14 @@
  */
 public class TestTextStripper extends TestCase
 {
+
+    /**
+     * Logger instance.
+     */
+    private static final Log log = LogFactory.getLog(TestTextStripper.class);
+
     private boolean bFail = false;
     private PDFTextStripper stripper = null;
-    private PrintWriter log = null;
     private final String encoding = "UTF-16LE";
 
     /**
@@ -144,7 +149,7 @@
                 if( expectedArray[expectedIndex] != actualArray[actualIndex] )
                 {
                     equals = false;
-                    log.println("Lines differ at index"
+                    log.warn("Lines differ at index"
                      + " expected:" + expectedIndex + "-" + (int)expectedArray[expectedIndex]
                      + " actual:" + actualIndex + "-" + (int)actualArray[actualIndex] );
                     break;
@@ -159,12 +164,12 @@
                 if( expectedIndex != expectedArray.length )
                 {
                     equals = false;
-                    log.println("Expected line is longer at:" + expectedIndex );
+                    log.warn("Expected line is longer at:" + expectedIndex );
                 }
                 if( actualIndex != actualArray.length )
                 {
                     equals = false;
-                    log.println("Actual line is longer at:" + actualIndex );
+                    log.warn("Actual line is longer at:" + actualIndex );
                 }
             }
         }
@@ -216,11 +221,11 @@
     {
         if(bSort)
         {
-            log.println("Preparing to parse " + inFile.getName() + " for sorted test");
+            log.info("Preparing to parse " + inFile.getName() + " for sorted test");
         }
         else
         {
-            log.println("Preparing to parse " + inFile.getName() + " for standard test");
+            log.info("Preparing to parse " + inFile.getName() + " for standard test");
         }
 
         OutputStream os = null;
@@ -263,13 +268,14 @@
 
             if (bLogResult)
             {
-                log.println("Text for " + inFile.getName() + ":\r\n" + stripper.getText(document));
+                log.info("Text for " + inFile.getName() + ":");
+                log.info(stripper.getText(document));
             }
 
             if (!expectedFile.exists())
             {
                 this.bFail = true;
-                log.println(
+                log.error(
                         "FAILURE: Input verification file: " + expectedFile.getAbsolutePath()
+
                 " did not exist");
                 return;
@@ -302,11 +308,11 @@
                         this.bFail = true;
                     }
 
-                    log.println("FAILURE: Line mismatch for file " + inFile.getName() +
+                    log.error("FAILURE: Line mismatch for file " + inFile.getName() +
                             " at expected line: " + expectedReader.getLineNumber() +
-                            " at actual line: " + actualReader.getLineNumber() +
-                            "\r\n  expected line was: \"" + expectedLine + "\"" +
-                            "\r\n  actual line was:   \"" + actualLine + "\"");
+                            " at actual line: " + actualReader.getLineNumber());
+                    log.error("  expected line was: \"" + expectedLine + "\"");
+                    log.error("  actual line was:   \"" + actualLine + "\"");
 
                     //lets report all lines, even though this might produce some verbose
logging
                     //break;
@@ -372,10 +378,6 @@
         File outDir = new File("test/output");
         File inDirExt = new File("test/input-ext");
         File outDirExt = new File("test/output-ext");
-        
-        try
-        {
-            log = new PrintWriter( new FileWriter( "textextract.log" ) );
 
             if ((filename == null) || (filename.length() == 0)) 
             {
@@ -397,14 +399,6 @@
             {
                 fail("One or more failures, see test log for details");
             }
-        }
-        finally
-        {
-            if( log != null )
-            {
-                log.close();
-            }
-        }
     }
 
     /**

Copied: pdfbox/trunk/src/test/resources/logging.properties (from r907513, pdfbox/trunk/logging.properties)
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/test/resources/logging.properties?p2=pdfbox/trunk/src/test/resources/logging.properties&p1=pdfbox/trunk/logging.properties&r1=907513&r2=907530&rev=907530&view=diff
==============================================================================
--- pdfbox/trunk/logging.properties (original)
+++ pdfbox/trunk/src/test/resources/logging.properties Mon Feb  8 00:42:24 2010
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 handlers=java.util.logging.FileHandler
-.level=FINEST
+.level=INFO
 
 java.util.logging.FileHandler.pattern = target/pdfbox.log
 java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter



Mime
View raw message