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.Collections;
17 import java.util.List;
18 import java.util.concurrent.AbstractExecutorService;
19 import java.util.concurrent.Callable;
20 import java.util.concurrent.ScheduledExecutorService;
21 import java.util.concurrent.ScheduledFuture;
22 import java.util.concurrent.TimeUnit;
23
24
25
26
27
28
29
30
31 public class MockScheduledExecutorService extends AbstractExecutorService implements ScheduledExecutorService {
32
33 private Runnable lastCommand;
34
35 public Runnable getLastCommand() {
36 return lastCommand;
37 }
38
39 public void shutdown() {
40 }
41
42 public List<Runnable> shutdownNow() {
43 return Collections.emptyList();
44 }
45
46 public boolean isShutdown() {
47 return true;
48 }
49
50 public boolean isTerminated() {
51 return true;
52 }
53
54 public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
55 return true;
56 }
57
58 public void execute(Runnable command) {
59 command.run();
60 lastCommand = command;
61 }
62
63 @Override
64 public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
65 throw new UnsupportedOperationException();
66 }
67
68 @Override
69 public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
70 throw new UnsupportedOperationException();
71 }
72
73 @Override
74 public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
75 throw new UnsupportedOperationException();
76 }
77
78 @Override
79 public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
80 throw new UnsupportedOperationException();
81 }
82
83 }