test/java/math/BigInteger/PrimeTest.java

Print this page
rev 11823 : 8078672: Print and allow setting by Java property seeds used to initialize Random instances in java.lang numerics tests
Summary: Add ability to initial the random number generator from the system property "seed" and print to STDOUT the seed value actually used.
Reviewed-by: XXX

@@ -23,12 +23,14 @@
  * questions.
  */
 
 /*
  * @test
- * @library ..
- * @bug 8026236 8074460
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.*
+ * @run main PrimeTest
+ * @bug 8026236 8074460 8078672
  * @summary test primality verification methods in BigInteger (use -Dseed=X to set PRNG seed)
  * @author bpb
  * @key randomness
  */
 import java.math.BigInteger;

@@ -177,13 +179,12 @@
         } catch (ArithmeticException e) {
             // ignore it
         }
 
         // Create a list of non-prime BigIntegers.
-        RandomSeed rndSeed = new RandomSeed(true);
-        System.out.println("Random number generator seed = " + rndSeed.getSeed());
-        List<BigInteger> nonPrimeBigInts = (rndSeed.getSplittableRandom())
+        SplittableRandom splitRandom = RandomFactory.getSplittableRandom();
+        List<BigInteger> nonPrimeBigInts = (splitRandom)
                 .ints(NUM_NON_PRIMES, 2, maxPrime).mapToObj(BigInteger::valueOf)
                 .filter(b -> !b.isProbablePrime(certainty)).collect(toList());
 
         // If there are any non-probable primes also in the primes list then fail.
         boolean failed = nonPrimeBigInts.stream().anyMatch(primes::contains);