1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.turbo;
15
16 import static org.junit.jupiter.api.Assertions.*;
17 import org.junit.jupiter.api.Test;
18
19 public class LRUMessageCacheTest {
20
21 @Test
22 public void testEldestEntriesRemoval() {
23 final LRUMessageCache cache = new LRUMessageCache(2);
24 assertEquals(0, cache.getMessageCountAndThenIncrement("0"));
25 assertEquals(1, cache.getMessageCountAndThenIncrement("0"));
26 assertEquals(0, cache.getMessageCountAndThenIncrement("1"));
27 assertEquals(1, cache.getMessageCountAndThenIncrement("1"));
28
29 assertEquals(0, cache.getMessageCountAndThenIncrement("2"));
30
31
32 assertEquals(0, cache.getMessageCountAndThenIncrement("0"));
33
34
35 assertEquals(0, cache.getMessageCountAndThenIncrement("1"));
36
37 assertEquals(0, cache.getMessageCountAndThenIncrement("2"));
38 }
39
40 }