|
|
|
|
@ -16,8 +16,12 @@
@@ -16,8 +16,12 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.scheduling.config; |
|
|
|
|
|
|
|
|
|
import io.micrometer.observation.tck.TestObservationRegistry; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.scheduling.SchedulingAwareRunnable; |
|
|
|
|
import org.springframework.scheduling.support.ScheduledMethodRunnable; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
|
|
|
|
@ -72,6 +76,18 @@ class TaskTests {
@@ -72,6 +76,18 @@ class TaskTests {
|
|
|
|
|
assertThat(executionOutcome.throwable()).isInstanceOf(IllegalStateException.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldDelegateToSchedulingAwareRunnable() throws Exception { |
|
|
|
|
ScheduledMethodRunnable methodRunnable = new ScheduledMethodRunnable(new TestRunnable(), |
|
|
|
|
TestRunnable.class.getMethod("run"), "myScheduler", TestObservationRegistry::create); |
|
|
|
|
Task task = new Task(methodRunnable); |
|
|
|
|
|
|
|
|
|
assertThat(task.getRunnable()).isInstanceOf(SchedulingAwareRunnable.class); |
|
|
|
|
SchedulingAwareRunnable actual = (SchedulingAwareRunnable) task.getRunnable(); |
|
|
|
|
assertThat(actual.getQualifier()).isEqualTo(methodRunnable.getQualifier()); |
|
|
|
|
assertThat(actual.isLongLived()).isEqualTo(methodRunnable.isLongLived()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class TestRunnable implements Runnable { |
|
|
|
|
|
|
|
|
|
|