pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject [1/3] pdfbox-jbig2 git commit: make unit test lenient if a test file is missing
Date Mon, 16 Oct 2017 20:30:54 GMT
Repository: pdfbox-jbig2
Updated Branches:
  refs/heads/master 1fd958f97 -> 6a4e06fae


make unit test lenient if a test file is missing

Project: http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/repo
Commit: http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/commit/20370943
Tree: http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/tree/20370943
Diff: http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/diff/20370943

Branch: refs/heads/master
Commit: 20370943ed05a2610beb27378733dc80d35b0074
Parents: 1fd958f
Author: Andreas Lehmkühler <andreas@lehmi.de>
Authored: Mon Oct 16 22:13:23 2017 +0200
Committer: Andreas Lehmkühler <andreas@lehmi.de>
Committed: Mon Oct 16 22:13:23 2017 +0200

----------------------------------------------------------------------
 .../org/apache/pdfbox/jbig2/ChecksumTest.java   | 37 ++++++++++++--------
 1 file changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/pdfbox-jbig2/blob/20370943/src/test/java/org/apache/pdfbox/jbig2/ChecksumTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/pdfbox/jbig2/ChecksumTest.java b/src/test/java/org/apache/pdfbox/jbig2/ChecksumTest.java
index 3dd208c..9db1aec 100644
--- a/src/test/java/org/apache/pdfbox/jbig2/ChecksumTest.java
+++ b/src/test/java/org/apache/pdfbox/jbig2/ChecksumTest.java
@@ -152,24 +152,33 @@ public class ChecksumTest {
     InputStream is = getClass().getResourceAsStream(filepath);
     System.out.println("####################################");
     System.out.println("File: " + filepath);
-    DefaultInputStreamFactory disf = new DefaultInputStreamFactory();
-    ImageInputStream iis = disf.getInputStream(is);
+    if (is != null && is.available() > 0)
+    {
+        DefaultInputStreamFactory disf = new DefaultInputStreamFactory();
+        ImageInputStream iis = disf.getInputStream(is);
 
-    JBIG2Document doc = new JBIG2Document(iis);
+        JBIG2Document doc = new JBIG2Document(iis);
 
-    long time = System.currentTimeMillis();
-    Bitmap b = doc.getPage(imageIndex).getBitmap();
-    long duration = System.currentTimeMillis() - time;
+        long time = System.currentTimeMillis();
+        Bitmap b = doc.getPage(imageIndex).getBitmap();
+        long duration = System.currentTimeMillis() - time;
 
-    byte[] digest = MessageDigest.getInstance("MD5").digest(b.getByteArray());
+        byte[] digest = MessageDigest.getInstance("MD5").digest(b.getByteArray());
 
-    StringBuilder stringBuilder = new StringBuilder();
-    for (byte toAppend : digest) {
-      stringBuilder.append(toAppend);
-    }
-    System.out.println("Completed decoding in " + duration + " ms");
-    System.out.println("####################################\n");
+        StringBuilder stringBuilder = new StringBuilder();
+        for (byte toAppend : digest)
+        {
+            stringBuilder.append(toAppend);
+        }
+        System.out.println("Completed decoding in " + duration + " ms");
+        System.out.println("####################################\n");
 
-    Assert.assertEquals(checksum, stringBuilder.toString());
+        Assert.assertEquals(checksum, stringBuilder.toString());
+    }
+    else
+    {
+        System.out.println("File not found\n");
+        System.out.println("####################################\n");
+    }
   }
 }


Mime
View raw message