Search in sources :

Example 1 with OverflowStrategy

use of reactor.core.publisher.FluxSink.OverflowStrategy in project reactor-core by reactor.

the class FluxCreateTest method secondOnCancelHandlerIsDisposedImmediately.

@ParameterizedTestWithName
@EnumSource(OverflowStrategy.class)
void secondOnCancelHandlerIsDisposedImmediately(OverflowStrategy overflowStrategy) {
    AtomicInteger firstDisposed = new AtomicInteger();
    AtomicInteger secondDisposed = new AtomicInteger();
    Flux.create(sink -> sink.onCancel(firstDisposed::incrementAndGet).onCancel(secondDisposed::incrementAndGet), overflowStrategy).subscribe();
    assertThat(firstDisposed).as("first handler for %s", overflowStrategy).hasValue(0);
    assertThat(secondDisposed).as("second handler for %s", overflowStrategy).hasValue(1);
}
Also used : IntStream(java.util.stream.IntStream) StepVerifier(reactor.test.StepVerifier) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SerializedFluxSink(reactor.core.publisher.FluxCreate.SerializedFluxSink) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OverflowStrategy(reactor.core.publisher.FluxSink.OverflowStrategy) EnumSource(org.junit.jupiter.params.provider.EnumSource) Scheduler(reactor.core.scheduler.Scheduler) AtomicReference(java.util.concurrent.atomic.AtomicReference) BufferAsyncSink(reactor.core.publisher.FluxCreate.BufferAsyncSink) CoreSubscriber(reactor.core.CoreSubscriber) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LatestAsyncSink(reactor.core.publisher.FluxCreate.LatestAsyncSink) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Schedulers(reactor.core.scheduler.Schedulers) RaceTestUtils(reactor.test.util.RaceTestUtils) Subscriber(org.reactivestreams.Subscriber) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) Semaphore(java.util.concurrent.Semaphore) Step(reactor.test.StepVerifier.Step) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) Assertions.fail(org.assertj.core.api.Assertions.fail) Subscription(org.reactivestreams.Subscription) AssertSubscriber(reactor.test.subscriber.AssertSubscriber) Exceptions(reactor.core.Exceptions) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Example 2 with OverflowStrategy

use of reactor.core.publisher.FluxSink.OverflowStrategy in project reactor-core by reactor.

the class FluxCreateTest method secondOnDisposeHandlerIsDisposedImmediately.

@ParameterizedTestWithName
@EnumSource(OverflowStrategy.class)
void secondOnDisposeHandlerIsDisposedImmediately(OverflowStrategy overflowStrategy) {
    AtomicInteger firstDisposed = new AtomicInteger();
    AtomicInteger secondDisposed = new AtomicInteger();
    Flux.create(sink -> sink.onDispose(firstDisposed::incrementAndGet).onDispose(secondDisposed::incrementAndGet), overflowStrategy).subscribe();
    assertThat(firstDisposed).as("first handler for %s", overflowStrategy).hasValue(0);
    assertThat(secondDisposed).as("second handler for %s", overflowStrategy).hasValue(1);
}
Also used : IntStream(java.util.stream.IntStream) StepVerifier(reactor.test.StepVerifier) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SerializedFluxSink(reactor.core.publisher.FluxCreate.SerializedFluxSink) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OverflowStrategy(reactor.core.publisher.FluxSink.OverflowStrategy) EnumSource(org.junit.jupiter.params.provider.EnumSource) Scheduler(reactor.core.scheduler.Scheduler) AtomicReference(java.util.concurrent.atomic.AtomicReference) BufferAsyncSink(reactor.core.publisher.FluxCreate.BufferAsyncSink) CoreSubscriber(reactor.core.CoreSubscriber) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LatestAsyncSink(reactor.core.publisher.FluxCreate.LatestAsyncSink) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Schedulers(reactor.core.scheduler.Schedulers) RaceTestUtils(reactor.test.util.RaceTestUtils) Subscriber(org.reactivestreams.Subscriber) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) Semaphore(java.util.concurrent.Semaphore) Step(reactor.test.StepVerifier.Step) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) Assertions.fail(org.assertj.core.api.Assertions.fail) Subscription(org.reactivestreams.Subscription) AssertSubscriber(reactor.test.subscriber.AssertSubscriber) Exceptions(reactor.core.Exceptions) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Aggregations

ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Executors (java.util.concurrent.Executors)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Semaphore (java.util.concurrent.Semaphore)2 TimeUnit (java.util.concurrent.TimeUnit)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 IntStream (java.util.stream.IntStream)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.fail (org.assertj.core.api.Assertions.fail)2 Test (org.junit.jupiter.api.Test)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 Subscriber (org.reactivestreams.Subscriber)2 Subscription (org.reactivestreams.Subscription)2 CoreSubscriber (reactor.core.CoreSubscriber)2 Exceptions (reactor.core.Exceptions)2 Scannable (reactor.core.Scannable)2 BufferAsyncSink (reactor.core.publisher.FluxCreate.BufferAsyncSink)2