-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathSynchronousTestExecutor.java
More file actions
64 lines (52 loc) · 1.61 KB
/
SynchronousTestExecutor.java
File metadata and controls
64 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package io.getunleash;
import io.getunleash.util.UnleashScheduledExecutor;
import java.util.concurrent.Delayed;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SynchronousTestExecutor implements UnleashScheduledExecutor {
private static final Logger LOG = LoggerFactory.getLogger(SynchronousTestExecutor.class);
@Override
public void setInterval(Runnable command, long initialDelaySec, long periodSec)
throws RejectedExecutionException {
LOG.warn("i will only do this once");
scheduleOnce(command);
}
@Override
public ScheduledFuture<Void> scheduleOnce(Runnable runnable) {
runnable.run();
return new AlreadyCompletedScheduledFuture();
}
private static class AlreadyCompletedScheduledFuture implements ScheduledFuture<Void> {
@Override
public long getDelay(TimeUnit timeUnit) {
return 0;
}
@Override
public int compareTo(Delayed delayed) {
return 0;
}
@Override
public boolean cancel(boolean b) {
return false;
}
@Override
public boolean isCancelled() {
return false;
}
@Override
public boolean isDone() {
return false;
}
@Override
public Void get() {
return null;
}
@Override
public Void get(long l, TimeUnit timeUnit) {
return null;
}
}
}