@Test public void testSoakTestWithRandomData() throws IOException, InterruptedException { // for (int i = 30; i < 50; i++) { System.out.print("SoakTesting "); int max = 1000000; for (int j = 1; j < max; j++) { if (j % 100 == 0) System.out.print("."); Random rnd = new Random(System.currentTimeMillis()); final ChronicleMap<Integer, CharSequence> map = rnd.nextBoolean() ? map1 : map2; if (rnd.nextBoolean()) { map.put((int) rnd.nextInt(100), "test" + j); } else { map.remove((int) rnd.nextInt(100)); } } System.out.println("\nwaiting till equal"); waitTillUnchanged(1000); System.out.println("time t=" + t); Assert.assertEquals(new TreeMap(map1), new TreeMap(map2)); }
private void waitTillUnchanged(final int timeOutMs) throws InterruptedException { Map map1UnChanged = new HashMap(); Map map2UnChanged = new HashMap(); int numberOfTimesTheSame = 0; for (int t = 0; t < timeOutMs + 100; t++) { if (map1.equals(map1UnChanged) && map2.equals(map2UnChanged)) { numberOfTimesTheSame++; } else { numberOfTimesTheSame = 0; map1UnChanged = new HashMap(map1); map2UnChanged = new HashMap(map2); } Thread.sleep(50); if (numberOfTimesTheSame == 100) { break; } } }