pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1813419 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java
Date Thu, 26 Oct 2017 15:23:53 GMT
Author: tilman
Date: Thu Oct 26 15:23:53 2017
New Revision: 1813419

URL: http://svn.apache.org/viewvc?rev=1813419&view=rev
Log:
PDFBOX-3974: don't download the test files, these have been downloaded to target/pdfs subdir
in previous build phase

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java?rev=1813419&r1=1813418&r2=1813419&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java Thu Oct
26 15:23:53 2017
@@ -28,13 +28,9 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.net.URISyntaxException;
-import java.net.URL;
 
 import org.apache.pdfbox.cos.COSDocument;
-import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.io.MemoryUsageSetting;
 import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
 import org.apache.pdfbox.io.RandomAccessRead;
@@ -48,9 +44,9 @@ import org.junit.Test;
 
 public class TestPDFParser
 {
-
     private static final String PATH_OF_PDF = "src/test/resources/input/yaddatest.pdf";
     private static final File tmpDirectory = new File(System.getProperty("java.io.tmpdir"));
+    private static final File TARGETPDFDIR = new File("target/pdfs");
 
     private int numberOfTmpFiles = 0;
 
@@ -127,27 +123,12 @@ public class TestPDFParser
      * file. An incorrect algorithm would result in an outline dictionary being mistaken
for an
      * /Info.
      *
-     * @throws MalformedURLException
      * @throws IOException
      */
     @Test
-    public void testPDFBox3208() throws MalformedURLException, IOException
+    public void testPDFBox3208() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12784025/PDFBOX-3208-L33MUTT2SVCWGCS6UIYL5TH3PNPXHIS6.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3208 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR,"PDFBOX-3208-L33MUTT2SVCWGCS6UIYL5TH3PNPXHIS6.pdf")))
         {
             PDDocumentInformation di = doc.getDocumentInformation();
             assertEquals("Liquent Enterprise Services", di.getAuthor());
@@ -165,27 +146,12 @@ public class TestPDFParser
      * Test whether the /Info is retrieved correctly when rebuilding the trailer of a corrupt
file,
      * despite the /Info dictionary not having a modification date.
      *
-     * @throws MalformedURLException
      * @throws IOException
      */
     @Test
-    public void testPDFBox3940() throws MalformedURLException, IOException
+    public void testPDFBox3940() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12888957/079977.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3940 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR,"PDFBOX-3940-079977.pdf")))
         {
             PDDocumentInformation di = doc.getDocumentInformation();
             assertEquals("Unknown", di.getAuthor());
@@ -201,54 +167,24 @@ public class TestPDFParser
     /**
      * PDFBOX-3783: test parsing of file with trash after %%EOF.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3783() throws MalformedURLException, IOException
+    public void testPDFBox3783() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12867102/PDFBOX-3783-72GLBIGUC6LB46ELZFBARRJTLN4RBSQM.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3783 will be skipped");
-            return;
-        }
-
-        PDDocument.load(byteArray).close();
+        PDDocument.load(new File(TARGETPDFDIR,"PDFBOX-3783-72GLBIGUC6LB46ELZFBARRJTLN4RBSQM.pdf")).close();
     }
 
     /**
      * PDFBOX-3785, PDFBOX-3957:
      * Test whether truncated file with several revisions has correct page count.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3785() throws MalformedURLException, IOException
+    public void testPDFBox3785() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12867113/202097.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3785 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR,"PDFBOX-3785-202097.pdf")))
         {
             assertEquals(11, doc.getNumberOfPages());
         }
@@ -257,105 +193,45 @@ public class TestPDFParser
     /**
      * PDFBOX-3947: test parsing of file with broken object stream.
      *
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3947() throws MalformedURLException, IOException
+    public void testPDFBox3947() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12890031/670064.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3947 will be skipped");
-            return;
-        }
-
-        PDDocument.load(byteArray).close();
+        PDDocument.load(new File(TARGETPDFDIR, "PDFBOX-3947-670064.pdf")).close();
     }
 
     /**
      * PDFBOX-3948: test parsing of file with object stream containing some unexpected newlines.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3948() throws MalformedURLException, IOException
+    public void testPDFBox3948() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12890034/EUWO6SQS5TM4VGOMRD3FLXZHU35V2CP2.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3948 will be skipped");
-            return;
-        }
-
-        PDDocument.load(byteArray).close();
+        PDDocument.load(new File(TARGETPDFDIR, "PDFBOX-3948-EUWO6SQS5TM4VGOMRD3FLXZHU35V2CP2.pdf")).close();
     }
 
     /**
      * PDFBOX-3949: test parsing of file with incomplete object stream.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3949() throws MalformedURLException, IOException
+    public void testPDFBox3949() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12890037/MKFYUGZWS3OPXLLVU2Z4LWCTVA5WNOGF.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3949 will be skipped");
-            return;
-        }
-
-        PDDocument.load(byteArray).close();
+        PDDocument.load(new File(TARGETPDFDIR, "PDFBOX-3949-MKFYUGZWS3OPXLLVU2Z4LWCTVA5WNOGF.pdf")).close();
     }
 
     /**
      * PDFBOX-3950: test parsing and rendering of truncated file with missing pages.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3950() throws MalformedURLException, IOException
+    public void testPDFBox3950() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12890042/23EGDHXSBBYQLKYOKGZUOVYVNE675PRD.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3950 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR, "PDFBOX-3950-23EGDHXSBBYQLKYOKGZUOVYVNE675PRD.pdf")))
         {
             assertEquals(4, doc.getNumberOfPages());
             PDFRenderer renderer = new PDFRenderer(doc);
@@ -380,27 +256,12 @@ public class TestPDFParser
     /**
      * PDFBOX-3951: test parsing of truncated file.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3951() throws MalformedURLException, IOException
+    public void testPDFBox3951() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12890047/FIHUZWDDL2VGPOE34N6YHWSIGSH5LVGZ.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3951 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR, "PDFBOX-3951-FIHUZWDDL2VGPOE34N6YHWSIGSH5LVGZ.pdf")))
         {
             assertEquals(143, doc.getNumberOfPages());
         }
@@ -409,27 +270,12 @@ public class TestPDFParser
     /**
      * PDFBOX-3964: test parsing of broken file.
      * 
-     * @throws MalformedURLException
      * @throws IOException 
      */
     @Test
-    public void testPDFBox3964() throws MalformedURLException, IOException
+    public void testPDFBox3964() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12892097/c687766d68ac766be3f02aaec5e0d713_2.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3964 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR, "PDFBOX-3964-c687766d68ac766be3f02aaec5e0d713_2.pdf")))
         {
             assertEquals(10, doc.getNumberOfPages());
         }
@@ -439,27 +285,12 @@ public class TestPDFParser
      * Test whether /Info dictionary is retrieved correctly in brute force search for the
      * Info/Catalog dictionaries.
      *
-     * @throws MalformedURLException
      * @throws IOException
      */
     @Test
-    public void testPDFBox3977() throws MalformedURLException, IOException
+    public void testPDFBox3977() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12893582/63NGFQRI44HQNPIPEJH5W2TBM6DJZWMI.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testPDFBox3977 will be skipped");
-            return;
-        }
-
-        try (PDDocument doc = PDDocument.load(byteArray))
+        try (PDDocument doc = PDDocument.load(new File(TARGETPDFDIR,"PDFBOX-3977-63NGFQRI44HQNPIPEJH5W2TBM6DJZWMI.pdf")))
         {
             PDDocumentInformation di = doc.getDocumentInformation();
             assertEquals("QuarkXPress(tm) 6.52", di.getCreator());
@@ -473,26 +304,12 @@ public class TestPDFParser
     /**
      * Test parsing the "genko_oc_shiryo1.pdf" file, which is susceptible to regression.
      * 
-     * @throws Exception 
+     * @throws IOException 
      */
     @Test
-    public void testParseGenko() throws Exception
+    public void testParseGenko() throws IOException
     {
-        byte[] byteArray;
-        try
-        {
-            try (InputStream is = new URL("https://issues.apache.org/jira/secure/attachment/12867433/genko_oc_shiryo1.pdf").openStream())
-            {
-                byteArray = IOUtils.toByteArray(is);
-            }
-        }
-        catch (IOException ex)
-        {
-            System.err.println("URL loading failed, testParseGenko will be skipped");
-            return;
-        }
-
-        PDDocument.load(byteArray).close();
+        PDDocument.load(new File(TARGETPDFDIR, "genko_oc_shiryo1.pdf")).close();
     }
 
     private void executeParserTest(RandomAccessRead source, MemoryUsageSetting memUsageSetting)
throws IOException



Mime
View raw message