1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.status;
15
16 import ch.qos.logback.core.Context;
17 import ch.qos.logback.core.ContextBase;
18 import ch.qos.logback.core.CoreConstants;
19 import org.junit.jupiter.api.Test;
20
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
23
24
25
26
27 public class StatusUtilTest {
28
29 Context context = new ContextBase();
30 StatusUtil statusUtil = new StatusUtil(context);
31
32 @Test
33 public void emptyStatusListShouldResultInNotFound() {
34 assertEquals(-1, statusUtil.timeOfLastReset());
35 }
36
37 @Test
38 public void withoutResetsStatusUtilShouldReturnNotFound() {
39 context.getStatusManager().add(new InfoStatus("test", this));
40 assertEquals(-1, statusUtil.timeOfLastReset());
41 }
42
43 @Test
44 public void statusListShouldReturnLastResetTime() {
45 context.getStatusManager().add(new InfoStatus("test", this));
46 long resetTime = System.currentTimeMillis();
47 context.getStatusManager().add(new InfoStatus(CoreConstants.RESET_MSG_PREFIX, this));
48 context.getStatusManager().add(new InfoStatus("bla", this));
49 assertTrue(resetTime <= statusUtil.timeOfLastReset());
50 }
51
52 }