1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.net.mock;
15
16 import java.util.List;
17 import java.util.concurrent.ScheduledExecutorService;
18
19 import ch.qos.logback.core.Context;
20 import ch.qos.logback.core.ContextBase;
21 import ch.qos.logback.core.status.Status;
22 import ch.qos.logback.core.status.StatusListener;
23 import ch.qos.logback.core.status.StatusManager;
24
25
26
27
28
29
30 public class MockContext extends ContextBase {
31
32 private final ScheduledExecutorService scheduledExecutorService;
33
34 private Status lastStatus;
35
36 public MockContext() {
37 this(new MockScheduledExecutorService());
38 }
39
40 public MockContext(ScheduledExecutorService executorService) {
41 this.setStatusManager(new MockStatusManager());
42 this.scheduledExecutorService = executorService;
43 }
44
45 @Override
46 public ScheduledExecutorService getScheduledExecutorService() {
47 return scheduledExecutorService;
48 }
49
50 public Status getLastStatus() {
51 return lastStatus;
52 }
53
54 public void setLastStatus(Status lastStatus) {
55 this.lastStatus = lastStatus;
56 }
57
58 private class MockStatusManager implements StatusManager {
59
60 public void add(Status status) {
61 lastStatus = status;
62 }
63
64 public List<Status> getCopyOfStatusList() {
65 throw new UnsupportedOperationException();
66 }
67
68 public int getCount() {
69 throw new UnsupportedOperationException();
70 }
71
72 public boolean add(StatusListener listener) {
73 throw new UnsupportedOperationException();
74 }
75
76 public void remove(StatusListener listener) {
77 throw new UnsupportedOperationException();
78 }
79
80 public void clear() {
81 throw new UnsupportedOperationException();
82 }
83
84 public List<StatusListener> getCopyOfStatusListenerList() {
85 throw new UnsupportedOperationException();
86 }
87
88 }
89
90 }