File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
connector/src/test/java/com/datastax/oss/cdc Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -56,4 +56,32 @@ public final void testExpireAfter() throws Exception {
56
56
assertFalse (mutationCache .isMutationProcessed ("mutation1" , "digest1" ));
57
57
}
58
58
59
+ @ Test
60
+ public final void testMaxCapacity () throws Exception {
61
+ MutationCache <String > mutationCache = new InMemoryCache <>(3 , 10 , Duration .ofHours (1 ));
62
+
63
+ // Access and modify the private field using reflection
64
+ Field field = InMemoryCache .class .getDeclaredField ("mutationCache" );
65
+ field .setAccessible (true );
66
+ field .set (mutationCache , Caffeine .newBuilder ()
67
+ .expireAfterWrite (Duration .ofHours (1 ).getSeconds (), TimeUnit .SECONDS )
68
+ .maximumSize (10 )
69
+ .recordStats ()
70
+ .executor (Runnable ::run ) // https://github.com/ben-manes/caffeine/wiki/Testing
71
+ .build ()
72
+ );
73
+
74
+ for (int i = 0 ; i <20 ; i ++) {
75
+ mutationCache .addMutationMd5 ("mutation" + i , "digest" + i );
76
+ }
77
+
78
+ int count = 0 ;
79
+ for (int i = 0 ; i < 20 ; i ++) {
80
+ if (mutationCache .getMutationCRCs ("mutation" + i ) != null ) {
81
+ count ++;
82
+ }
83
+ }
84
+ assertEquals (10 , count );
85
+ }
86
+
59
87
}
You can’t perform that action at this time.
0 commit comments