5
5
import static org .junit .Assert .assertEquals ;
6
6
7
7
import java .util .HashMap ;
8
+ import java .util .Map ;
8
9
import org .hamcrest .Matchers ;
9
10
import org .junit .Test ;
10
11
14
15
15
16
public class AllowAndDenyListClientSideCacheTest extends ClientSideCacheTestBase {
16
17
18
+ private static MapClientSideCache createMapClientSideCache (Map <Long , Object > map , ClientSideCacheable cacheable ) {
19
+ MapClientSideCache mapCache = new MapClientSideCache (map );
20
+ mapCache .setCacheable (cacheable );
21
+ return mapCache ;
22
+ }
23
+
17
24
@ Test
18
25
public void none () {
19
26
HashMap <Long , Object > map = new HashMap <>();
20
27
try (JedisPooled jedis = new JedisPooled (hnp , clientConfig .get (),
21
- new MapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , null , null , null )),
28
+ createMapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , null , null , null )),
22
29
singleConnectionPoolConfig .get ())) {
23
30
control .set ("foo" , "bar" );
24
31
assertThat (map , Matchers .aMapWithSize (0 ));
@@ -31,7 +38,7 @@ public void none() {
31
38
public void whiteListCommand () {
32
39
HashMap <Long , Object > map = new HashMap <>();
33
40
try (JedisPooled jedis = new JedisPooled (hnp , clientConfig .get (),
34
- new MapClientSideCache (map , new AllowAndDenyListWithStringKeys (singleton (Protocol .Command .GET ), null , null , null )),
41
+ createMapClientSideCache (map , new AllowAndDenyListWithStringKeys (singleton (Protocol .Command .GET ), null , null , null )),
35
42
singleConnectionPoolConfig .get ())) {
36
43
control .set ("foo" , "bar" );
37
44
assertThat (map , Matchers .aMapWithSize (0 ));
@@ -44,7 +51,7 @@ public void whiteListCommand() {
44
51
public void blackListCommand () {
45
52
HashMap <Long , Object > map = new HashMap <>();
46
53
try (JedisPooled jedis = new JedisPooled (hnp , clientConfig .get (),
47
- new MapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , singleton (Protocol .Command .GET ), null , null )),
54
+ createMapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , singleton (Protocol .Command .GET ), null , null )),
48
55
singleConnectionPoolConfig .get ())) {
49
56
control .set ("foo" , "bar" );
50
57
assertThat (map , Matchers .aMapWithSize (0 ));
@@ -57,7 +64,7 @@ public void blackListCommand() {
57
64
public void whiteListKey () {
58
65
HashMap <Long , Object > map = new HashMap <>();
59
66
try (JedisPooled jedis = new JedisPooled (hnp , clientConfig .get (),
60
- new MapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , null , singleton ("foo" ), null )),
67
+ createMapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , null , singleton ("foo" ), null )),
61
68
singleConnectionPoolConfig .get ())) {
62
69
control .set ("foo" , "bar" );
63
70
assertThat (map , Matchers .aMapWithSize (0 ));
@@ -70,7 +77,7 @@ public void whiteListKey() {
70
77
public void blackListKey () {
71
78
HashMap <Long , Object > map = new HashMap <>();
72
79
try (JedisPooled jedis = new JedisPooled (hnp , clientConfig .get (),
73
- new MapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , null , null , singleton ("foo" ))),
80
+ createMapClientSideCache (map , new AllowAndDenyListWithStringKeys (null , null , null , singleton ("foo" ))),
74
81
singleConnectionPoolConfig .get ())) {
75
82
control .set ("foo" , "bar" );
76
83
assertThat (map , Matchers .aMapWithSize (0 ));
0 commit comments