1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.spi;
15
16 import org.junit.jupiter.api.BeforeEach;
17 import org.junit.jupiter.api.Test;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20
21
22
23
24
25
26 public class ScenarioBasedCyclicBufferTrackerTest {
27
28 CyclicBufferTrackerSimulator simulator;
29 CyclicBufferTrackerSimulator.Parameters parameters = new CyclicBufferTrackerSimulator.Parameters();
30
31 void verify() {
32 CyclicBufferTracker<Object> at = simulator.realCBTracker;
33 CyclicBufferTrackerT<Object> t_at = simulator.t_CBTracker;
34 assertEquals(t_at.liveKeysAsOrderedList(), at.liveKeysAsOrderedList());
35 assertEquals(t_at.lingererKeysAsOrderedList(), at.lingererKeysAsOrderedList());
36 }
37
38 @BeforeEach
39 public void setUp() {
40 parameters.keySpaceLen = 128;
41 parameters.maxTimestampInc = ComponentTracker.DEFAULT_TIMEOUT / 2;
42 }
43
44 @Test
45 public void shortTest() {
46 parameters.keySpaceLen = 64;
47 parameters.maxTimestampInc = 500;
48 parameters.simulationLength = 70;
49
50 simulator = new CyclicBufferTrackerSimulator(parameters);
51 simulator.buildScenario();
52 simulator.simulate();
53 verify();
54 }
55
56 @Test
57 public void mediumTest() {
58 parameters.simulationLength = 20000;
59
60 simulator = new CyclicBufferTrackerSimulator(parameters);
61 simulator.buildScenario();
62 simulator.simulate();
63 verify();
64 }
65
66 @Test
67 public void longTest() {
68 parameters.simulationLength = 100 * 1000;
69 simulator = new CyclicBufferTrackerSimulator(parameters);
70 simulator.buildScenario();
71 simulator.simulate();
72 verify();
73 }
74 }