use of reactor.core.scheduler.Scheduler.Worker in project reactor-core by reactor.
the class ImmediateSchedulerTest method scanWorker.
@Test
public void scanWorker() {
Worker worker = Schedulers.immediate().createWorker();
Scannable s = (Scannable) worker;
assertThat(s.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(s.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(s.scan(Scannable.Attr.NAME)).isEqualTo(Schedulers.IMMEDIATE + ".worker");
worker.dispose();
assertThat(s.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(s.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of reactor.core.scheduler.Scheduler.Worker in project reactor-core by reactor.
the class ImmediateSchedulerTest method directAndWorkerTimeSchedulingRejected.
@Test
public void directAndWorkerTimeSchedulingRejected() {
Scheduler scheduler = scheduler();
Worker worker = scheduler.createWorker();
try {
assertThatExceptionOfType(RejectedExecutionException.class).isThrownBy(() -> scheduler.schedule(() -> {
}, 100, TimeUnit.MILLISECONDS)).isSameAs(Exceptions.failWithRejectedNotTimeCapable());
assertThatExceptionOfType(RejectedExecutionException.class).isThrownBy(() -> scheduler.schedulePeriodically(() -> {
}, 100, 100, TimeUnit.MILLISECONDS)).isSameAs(Exceptions.failWithRejectedNotTimeCapable());
assertThatExceptionOfType(RejectedExecutionException.class).isThrownBy(() -> worker.schedule(() -> {
}, 100, TimeUnit.MILLISECONDS)).isSameAs(Exceptions.failWithRejectedNotTimeCapable());
assertThatExceptionOfType(RejectedExecutionException.class).isThrownBy(() -> worker.schedulePeriodically(() -> {
}, 100, 100, TimeUnit.MILLISECONDS)).isSameAs(Exceptions.failWithRejectedNotTimeCapable());
} finally {
worker.dispose();
}
}
Aggregations