Search in sources :

Example 71 with Subscription

use of org.reactivestreams.Subscription in project reactor-core by reactor.

the class BlockingOptionalMonoSubscriber method dispose.

@Override
public final void dispose() {
    cancelled = true;
    Subscription s = this.s;
    if (s != null) {
        this.s = null;
        s.cancel();
    }
}
Also used : Subscription(org.reactivestreams.Subscription)

Example 72 with Subscription

use of org.reactivestreams.Subscription in project reactor-core by reactor.

the class BlockingSingleSubscriber method dispose.

@Override
public final void dispose() {
    cancelled = true;
    Subscription s = this.s;
    if (s != null) {
        this.s = null;
        s.cancel();
    }
}
Also used : Subscription(org.reactivestreams.Subscription)

Example 73 with Subscription

use of org.reactivestreams.Subscription in project reactor-core by reactor.

the class FluxWindowBoundaryTest method scanOtherSubscriber.

@Test
public void scanOtherSubscriber() {
    CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxWindowBoundary.WindowBoundaryMain<Integer, Integer> main = new FluxWindowBoundary.WindowBoundaryMain<>(actual, Queues.unbounded(), Queues.<Integer>unbounded().get());
    FluxWindowBoundary.WindowBoundaryOther<Integer> test = new FluxWindowBoundary.WindowBoundaryOther<>(main);
    Subscription parent = Operators.emptySubscription();
    test.onSubscribe(parent);
    Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
    Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
    test.requested = 35;
    Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
    test.cancel();
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Example 74 with Subscription

use of org.reactivestreams.Subscription in project reactor-core by reactor.

the class FluxWindowPredicateTest method scanMainSubscriber.

@Test
public void scanMainSubscriber() {
    CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxWindowPredicate.WindowPredicateMain<Integer> test = new FluxWindowPredicate.WindowPredicateMain<>(actual, Queues.<Flux<Integer>>unbounded().get(), Queues.unbounded(), 123, i -> true, Mode.WHILE);
    Subscription parent = Operators.emptySubscription();
    test.onSubscribe(parent);
    Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
    Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
    Assertions.assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
    test.requested = 35;
    Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
    test.queue.offer(Flux.just(1).groupBy(i -> i).blockFirst());
    Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
    Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
    test.error = new IllegalStateException("boom");
    Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
    test.onComplete();
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
    test.cancel();
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : Subscription(org.reactivestreams.Subscription) Test(org.junit.Test) FluxOperatorTest(reactor.test.publisher.FluxOperatorTest)

Example 75 with Subscription

use of org.reactivestreams.Subscription in project reactor-core by reactor.

the class FluxWindowTest method scanSkipSubscriber.

@Test
public void scanSkipSubscriber() {
    CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxWindow.WindowSkipSubscriber<Integer> test = new FluxWindow.WindowSkipSubscriber<Integer>(actual, 123, 3, Queues.unbounded());
    Subscription parent = Operators.emptySubscription();
    test.onSubscribe(parent);
    Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
    Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
    Assertions.assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(123);
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
    test.onComplete();
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
    test.cancel();
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : Subscription(org.reactivestreams.Subscription) Test(org.junit.Test) FluxOperatorTest(reactor.test.publisher.FluxOperatorTest)

Aggregations

Subscription (org.reactivestreams.Subscription)627 Test (org.junit.Test)506 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)158 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)131 ArrayList (java.util.ArrayList)117 AtomicReference (java.util.concurrent.atomic.AtomicReference)105 List (java.util.List)80 FluxOperatorTest (reactor.test.publisher.FluxOperatorTest)74 Subscriber (org.reactivestreams.Subscriber)68 AtomicLong (java.util.concurrent.atomic.AtomicLong)56 Assert (org.junit.Assert)56 Arrays (java.util.Arrays)43 BaseSequentialTest (com.oath.cyclops.streams.BaseSequentialTest)42 Vector (cyclops.data.Vector)39 ReactiveSeq (cyclops.reactive.ReactiveSeq)39 Executor (java.util.concurrent.Executor)38 Spouts (cyclops.reactive.Spouts)36 Arrays.asList (java.util.Arrays.asList)36 Executors (java.util.concurrent.Executors)35 StepVerifier (reactor.test.StepVerifier)34