@Test public void loadExistingFilter() { int n = 1000; double p = 0.01; String name = "loadExistingTest"; String testString = "simpletest"; String testString2 = "simpletest2"; cleanupRedis(); BloomFilter<String> first = createFilter(name, n, p, true); first.add(testString); System.out.println(first.asString()); BloomFilter<String> loaded = createFilter(name, n, p, false); System.out.println(loaded.asString()); assertTrue(loaded.contains(testString)); loaded.add(testString2); assertTrue(first.contains(testString2)); cleanupRedis(); }
@Test public void overwriteExistingFilter() { int n = 1000; double p = 0.01; String name = "loadExistingTest"; String testString = "simpletest"; String testString2 = "simpletest2"; cleanupRedis(); BloomFilter<String> first = createFilter(name, n, p, true); first.add(testString); System.out.println(first.asString()); BloomFilter<String> loaded = createFilter(name, n, p, true); System.out.println(loaded.asString()); assertFalse(loaded.contains(testString)); assertTrue(loaded.getExpectedElements() == n); assertEquals(first.getSize(), loaded.getSize()); assertEquals(first.getHashes(), loaded.getHashes()); assertEquals(0, Math.round(first.getEstimatedPopulation())); loaded.add(testString2); assertTrue(first.contains(testString2)); cleanupRedis(); }