RandomWrapper extends Random { RandomWrapper() { this(seedUniquifier() ^ System.nanoTime()); } RandomWrapper();   RandomWrapper(long seed); @Override void nextBytes(byte[] bytes); @Override int nextInt(); @Override int nextInt(int n); @Override long nextLong(); @Override boolean nextBoolean(); @Override float nextFloat(); @Override double nextDouble(); @Override double nextGaussian();  }
@Test public void testRandomWrapper() { RandomWrapper randomWrapper = new RandomWrapper(); Random random = new Random(randomWrapper.getSeed()); RandomWrapper randomWrapper2 = new RandomWrapper(randomWrapper.getSeed()); for (int i = 0; i < 100; i++) { int randomInt = randomWrapper.nextInt(); assertEquals("distinct result random", randomInt, random.nextInt()); assertEquals("distinct result randomWrapper2", randomInt, randomWrapper2.nextInt()); } }