|
16 | 16 |
|
17 | 17 | package reactor.core.observability.micrometer;
|
18 | 18 |
|
19 |
| -import java.lang.reflect.Field; |
20 | 19 | import java.time.Duration;
|
21 | 20 | import java.util.concurrent.ArrayBlockingQueue;
|
22 | 21 | import java.util.concurrent.CountDownLatch;
|
23 | 22 | import java.util.concurrent.ExecutorService;
|
24 |
| -import java.util.concurrent.Executors; |
25 | 23 | import java.util.concurrent.RejectedExecutionException;
|
26 | 24 | import java.util.concurrent.ThreadPoolExecutor;
|
27 | 25 | import java.util.concurrent.TimeUnit;
|
|
30 | 28 | import io.micrometer.core.instrument.LongTaskTimer;
|
31 | 29 | import io.micrometer.core.instrument.MockClock;
|
32 | 30 | import io.micrometer.core.instrument.Tags;
|
33 |
| -import io.micrometer.core.instrument.internal.DefaultLongTaskTimer; |
34 | 31 | import io.micrometer.core.instrument.search.RequiredSearch;
|
35 | 32 | import io.micrometer.core.instrument.simple.SimpleConfig;
|
36 | 33 | import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
@@ -72,6 +69,60 @@ void closeRegistry() {
|
72 | 69 | registry.close();
|
73 | 70 | }
|
74 | 71 |
|
| 72 | + @Test |
| 73 | + void supportsBothDeprecatedAndNonRestartableSchedulers() { |
| 74 | + Scheduler deprecatedScheduler = new Scheduler() { |
| 75 | + |
| 76 | + @Override |
| 77 | + public Disposable schedule(Runnable task) { |
| 78 | + return Disposables.disposed(); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + public Worker createWorker() { |
| 83 | + throw new UnsupportedOperationException(); |
| 84 | + } |
| 85 | + }; |
| 86 | + |
| 87 | + Scheduler nonRestartableScheduler = new Scheduler() { |
| 88 | + @Override |
| 89 | + public Disposable schedule(Runnable task) { |
| 90 | + return Disposables.disposed(); |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + public Worker createWorker() { |
| 95 | + throw new UnsupportedOperationException(); |
| 96 | + } |
| 97 | + |
| 98 | + @SuppressWarnings("deprecation") |
| 99 | + @Override |
| 100 | + public void start() { |
| 101 | + throw new UnsupportedOperationException(); |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + public void init() { |
| 106 | + } |
| 107 | + }; |
| 108 | + |
| 109 | + TimedScheduler timedDeprecatedScheduler = |
| 110 | + new TimedScheduler(deprecatedScheduler, registry, "test", Tags.empty()); |
| 111 | + |
| 112 | + TimedScheduler timedNonRestartableScheduler = |
| 113 | + new TimedScheduler(nonRestartableScheduler, registry, "test", Tags.empty()); |
| 114 | + |
| 115 | + assertThatNoException().isThrownBy(() -> { |
| 116 | + timedDeprecatedScheduler.init(); |
| 117 | + timedDeprecatedScheduler.start(); |
| 118 | + }); |
| 119 | + |
| 120 | + assertThatNoException().isThrownBy(timedNonRestartableScheduler::init); |
| 121 | + |
| 122 | + assertThatExceptionOfType(UnsupportedOperationException.class) |
| 123 | + .isThrownBy(timedNonRestartableScheduler::start); |
| 124 | + } |
| 125 | + |
75 | 126 | @Test
|
76 | 127 | void aDotIsAddedToPrefix() {
|
77 | 128 | TimedScheduler test = new TimedScheduler(Schedulers.immediate(), registry, "noDot", Tags.empty());
|
|
0 commit comments