Polish gh-29883
This commit is contained in:
@@ -36,7 +36,6 @@ import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.scheduling.config.ScheduledTask;
|
||||
import org.springframework.scheduling.config.ScheduledTaskHolder;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.support.ScheduledTaskObservationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -155,14 +154,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
targetDefinition.getPropertyValues().add("observationRegistry", this.observationRegistry);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
context.registerBean("schedulingConfigurer", SchedulingConfigurer.class, () -> {
|
||||
return new SchedulingConfigurer() {
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
taskRegistrar.setObservationRegistry(observationRegistry);
|
||||
}
|
||||
};
|
||||
});
|
||||
context.registerBean("schedulingConfigurer", SchedulingConfigurer.class, () -> taskRegistrar -> taskRegistrar.setObservationRegistry(observationRegistry));
|
||||
context.refresh();
|
||||
}
|
||||
|
||||
@@ -198,7 +190,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
this.observationRegistry = observationRegistry;
|
||||
}
|
||||
|
||||
public void await() throws InterruptedException {
|
||||
void await() throws InterruptedException {
|
||||
this.latch.await(3, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +199,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class FixedDelayBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void fixedDelay() {
|
||||
void fixedDelay() {
|
||||
this.latch.countDown();
|
||||
}
|
||||
}
|
||||
@@ -216,7 +208,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class FixedDelayErrorBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void error() {
|
||||
void error() {
|
||||
this.latch.countDown();
|
||||
throw new IllegalStateException("test error");
|
||||
}
|
||||
@@ -226,7 +218,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class FixedDelayReactiveBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Mono<Object> fixedDelay() {
|
||||
Mono<Object> fixedDelay() {
|
||||
return Mono.empty().doOnTerminate(() -> this.latch.countDown());
|
||||
}
|
||||
}
|
||||
@@ -235,7 +227,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class FixedDelayReactiveErrorBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Mono<Object> error() {
|
||||
Mono<Object> error() {
|
||||
return Mono.error(new IllegalStateException("test error"))
|
||||
.doOnTerminate(() -> this.latch.countDown());
|
||||
}
|
||||
@@ -245,7 +237,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class CancelledTaskBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void cancelled() {
|
||||
void cancelled() {
|
||||
this.latch.countDown();
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
@@ -260,7 +252,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class CancelledReactiveTaskBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Flux<Long> cancelled() {
|
||||
Flux<Long> cancelled() {
|
||||
return Flux.interval(Duration.ZERO, Duration.ofSeconds(1))
|
||||
.doOnNext(el -> this.latch.countDown());
|
||||
}
|
||||
@@ -270,9 +262,10 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class CurrentObservationBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void hasCurrentObservation() {
|
||||
assertThat(this.observationRegistry.getCurrentObservation()).isNotNull();
|
||||
assertThat(this.observationRegistry.getCurrentObservation().getContext()).isInstanceOf(ScheduledTaskObservationContext.class);
|
||||
void hasCurrentObservation() {
|
||||
Observation observation = this.observationRegistry.getCurrentObservation();
|
||||
assertThat(observation).isNotNull();
|
||||
assertThat(observation.getContext()).isInstanceOf(ScheduledTaskObservationContext.class);
|
||||
this.latch.countDown();
|
||||
}
|
||||
}
|
||||
@@ -281,7 +274,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
||||
static class CurrentObservationReactiveBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Mono<String> hasCurrentObservation() {
|
||||
Mono<String> hasCurrentObservation() {
|
||||
return Mono.just("test")
|
||||
.tap(() -> new DefaultSignalListener<String>() {
|
||||
@Override
|
||||
|
||||
@@ -101,6 +101,7 @@ class DefaultScheduledTaskObservationConventionTests {
|
||||
|
||||
static class BeanWithScheduledMethods implements TaskProcessor {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user