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