pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1635420 - in /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox: encryption/TestSymmetricKeyEncryption.java pdmodel/graphics/image/ValidateXImage.java
Date Thu, 30 Oct 2014 07:48:48 GMT
Author: tilman
Date: Thu Oct 30 07:48:48 2014
New Revision: 1635420

URL: http://svn.apache.org/r1635420
Log:
PDFBOX-2456: add rendering comparison

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java?rev=1635420&r1=1635419&r2=1635420&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java
Thu Oct 30 07:48:48 2014
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.encryption;
 
+import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -23,6 +24,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.ArrayList;
 import javax.crypto.Cipher;
 
 import junit.framework.TestCase;
@@ -34,6 +36,8 @@ import org.apache.pdfbox.pdmodel.encrypt
 import org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
+import org.apache.pdfbox.pdmodel.graphics.image.ValidateXImage;
+import org.apache.pdfbox.rendering.PDFRenderer;
 import org.apache.pdfbox.util.PDFTextStripper;
 import org.junit.Assert;
 import org.junit.Ignore;
@@ -206,6 +210,14 @@ public class TestSymmetricKeyEncryption 
     public void testSymmEncrForKeySize(int keyLength,
             int sizePriorToEncr, PDDocument doc, String password, AccessPermission permission)
throws IOException
     {
+        int numSrcPages = document.getNumberOfPages();
+        PDFRenderer pdfRenderer = new PDFRenderer(document);
+        ArrayList<BufferedImage> srcImgTab = new ArrayList<BufferedImage>();
+        for (int i = 0; i < numSrcPages; ++i)
+        {
+            srcImgTab.add(pdfRenderer.renderImage(i));
+        }
+
         PDDocument encryptedDoc = encrypt(keyLength, sizePriorToEncr, doc, "", permission);
 
         try
@@ -216,6 +228,14 @@ public class TestSymmetricKeyEncryption 
 
             AccessPermission newPermission = encryptedDoc.getCurrentAccessPermission();
 
+            Assert.assertEquals(numSrcPages, encryptedDoc.getNumberOfPages());
+            pdfRenderer = new PDFRenderer(encryptedDoc);
+            for (int i = 0; i < encryptedDoc.getNumberOfPages(); ++i)
+            {
+                BufferedImage bim = pdfRenderer.renderImage(i);
+                ValidateXImage.checkIdent(bim, srcImgTab.get(i));
+            }
+
             File pdfFile = new File(testResultsDir, keyLength + "-bit-decrypted.pdf");
             encryptedDoc.save(pdfFile);
             long sizeAfterDecr = pdfFile.length();

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java?rev=1635420&r1=1635419&r2=1635420&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
Thu Oct 30 07:48:48 2014
@@ -130,7 +130,7 @@ public class ValidateXImage
      * @param expectedImage
      * @param actualImage
      */
-    static void checkIdent(BufferedImage expectedImage, BufferedImage actualImage)
+    static public void checkIdent(BufferedImage expectedImage, BufferedImage actualImage)
     {
         String errMsg = "";
 



Mime
View raw message