View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
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   * A
23   *
24   * @author Ceki Gülcü
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  }