pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1591050 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
Date Tue, 29 Apr 2014 18:41:07 GMT
Author: tilman
Date: Tue Apr 29 18:41:06 2014
New Revision: 1591050

URL: http://svn.apache.org/r1591050
Log:
PDFBOX-2034: testFilters now does deterministic and non-deterministic tests

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java?rev=1591050&r1=1591049&r2=1591050&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java Tue Apr 29
18:41:06 2014
@@ -34,15 +34,29 @@ import org.apache.pdfbox.cos.COSName;
 public class TestFilters extends TestCase
 {
     /**
-     * This will test all of the filters in the system.
+     * This will test all of the filters in the system. There will be COUNT
+     * of deterministic tests and COUNT of non-deterministic tests, see also
+     * the discussion in PDFBOX-1977.
      *
      * @throws IOException If there is an exception while encoding.
      */
     public void testFilters() throws IOException
     {
-        for(int iter=0;iter<10;iter++) 
+        final int COUNT = 10;
+        Random rd = new Random(123456);
+        for (int iter = 0; iter < COUNT * 2; iter++)
         {
-            final long seed = new Random().nextLong();
+            long seed;
+            if (iter < COUNT)
+            {
+                // deterministic seed
+                seed = rd.nextLong();
+            }
+            else
+            {
+                // non-deterministic seed
+                seed = new Random().nextLong();
+            }
             boolean success = false;
             try 
             {
@@ -56,7 +70,7 @@ public class TestFilters extends TestCas
                     final int left = numBytes - upto;
                     if (random.nextBoolean() || left < 2) 
                     {
-                        // Fill w/ truly random bytes:
+                        // Fill w/ pseudo-random bytes:
                         final int end = upto + Math.min(left, 10+random.nextInt(100));
                         while(upto < end) 
                         {



Mime
View raw message