@Test public void testDatabase() throws Exception { final String filterName = "dbtest"; BloomFilter<String> bfDb1 = createFilter(filterName, 10_000, 0.01, true); assertEquals(filterName, bfDb1.config().name()); bfDb1.add("element1"); assertTrue(bfDb1.contains("element1")); assertFalse(bfDb1.contains("element2")); BloomFilter<String> bfDb2 = createFilter(filterName, 10_000, 0.01, true, 1); assertEquals(filterName, bfDb2.config().name()); assertFalse(bfDb2.contains("element1")); bfDb2.add("element2"); assertTrue(bfDb2.contains("element2")); assertFalse(bfDb1.contains("element2")); }
@Test public void testPool() throws Exception { int n = 1000; double p = 0.01; BloomFilter<String> bf = createFilter("pooltest", 10_000, 0.01, true); RedisPool pool = bf.config().pool(); FilterBuilder clonedConfig = bf.config().clone().name("pooltest-cloned"); BloomFilter<String> filter = filterTypes == FilterTypes.COUNTING ? clonedConfig.buildCountingBloomFilter() : clonedConfig.buildBloomFilter(); filter.add("filter"); bf.add("bf"); assertTrue(filter.contains("filter")); assertTrue(bf.contains("bf")); assertFalse(filter.contains("bf")); assertSame(pool, filter.config().pool()); }