pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1713114 - /pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
Date Sat, 07 Nov 2015 12:15:50 GMT
Author: tilman
Date: Sat Nov  7 12:15:50 2015
New Revision: 1713114

URL: http://svn.apache.org/viewvc?rev=1713114&view=rev
Log:
PDFBOX-3044: change encoding to utf8, don't fail immediately

Modified:
    pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java

Modified: pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java?rev=1713114&r1=1713113&r2=1713114&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
Sat Nov  7 12:15:50 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.util;
 
+import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
@@ -99,7 +100,7 @@ public class TestTextStripper extends Te
 
     private boolean bFail = false;
     private PDFTextStripper stripper = null;
-    private final String encoding = "UTF-16LE";
+    private final String encoding = "UTF-8";
 
     /**
      * Test class constructor.
@@ -242,7 +243,7 @@ public class TestTextStripper extends Te
             }
         }
 
-        PDDocument document = PDDocument.load(inFile);
+        PDDocument document = PDDocument.loadNonSeq(inFile, null);
         try
         {
             
@@ -262,10 +263,11 @@ public class TestTextStripper extends Te
 
             OutputStream os = new FileOutputStream(outFile);
             try {
-                os.write( 0xFF );
-                os.write( 0xFE );
+                os.write (0xEF);
+                os.write (0xBB);
+                os.write (0xBF);
 
-                Writer writer = new OutputStreamWriter(os, encoding);
+                Writer writer = new BufferedWriter(new OutputStreamWriter(os, encoding));
                 try {
                     //Allows for sorted tests 
                     stripper.setSortByPosition(bSort);
@@ -292,6 +294,8 @@ public class TestTextStripper extends Te
                 " did not exist");
                 return;
             }
+            
+            boolean localFail = false;
 
             LineNumberReader expectedReader =
                 new LineNumberReader(new InputStreamReader(new FileInputStream(expectedFile),
encoding));
@@ -313,6 +317,7 @@ public class TestTextStripper extends Te
                 if (!stringsEqual(expectedLine, actualLine))
                 {
                     this.bFail = true;
+                    localFail = true;
                     log.error("FAILURE: Line mismatch for file " + inFile.getName() +
                             " ( sort = "+bSort+")" +
                             " at expected line: " + expectedReader.getLineNumber() +
@@ -329,6 +334,12 @@ public class TestTextStripper extends Te
                     break;
                 }
             }
+            expectedReader.close();
+            actualReader.close();
+            if (!localFail)
+            {
+                outFile.delete();
+            }
         }
         finally
         {



Mime
View raw message