Search in sources :

Example 76 with Subscription

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

the class FluxWindowTest method scanOverlapSubscriber.

@Test
public void scanOverlapSubscriber() {
    CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxWindow.WindowOverlapSubscriber<Integer> test = new FluxWindow.WindowOverlapSubscriber<Integer>(actual, 123, 3, Queues.unbounded(), Queues.<UnicastProcessor<Integer>>unbounded().get());
    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);
    test.requested = 35;
    Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
    test.onNext(2);
    Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
    Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
    test.onError(new IllegalStateException("boom"));
    Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
    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 77 with Subscription

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

the class FluxWindowTest method scanExactSubscriber.

@Test
public void scanExactSubscriber() {
    CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxWindow.WindowExactSubscriber<Integer> test = new FluxWindow.WindowExactSubscriber<Integer>(actual, 123, 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)

Example 78 with Subscription

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

the class FluxZipIterableTest method scanSingleSubscriber.

@Test
public void scanSingleSubscriber() {
    CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxZipIterable.ZipSubscriber<Integer, Integer, Integer> test = new FluxZipIterable.ZipSubscriber<>(actual, new ArrayList<Integer>().iterator(), (i, j) -> i + j);
    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.TERMINATED)).isFalse();
    test.onComplete();
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
Also used : ArrayList(java.util.ArrayList) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test) FluxOperatorTest(reactor.test.publisher.FluxOperatorTest)

Example 79 with Subscription

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

the class FluxZipTest method scanSingleSubscriber.

@Test
public void scanSingleSubscriber() {
    CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
    }, null, null);
    FluxZip.ZipSingleCoordinator<Integer, Integer> main = new FluxZip.ZipSingleCoordinator<Integer, Integer>(actual, new Object[1], 1, i -> 5);
    FluxZip.ZipSingleSubscriber<Integer> test = new FluxZip.ZipSingleSubscriber<>(main, 0);
    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.onNext(7);
    Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
    Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
    Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Also used : Subscription(org.reactivestreams.Subscription) Test(org.junit.Test) FluxOperatorTest(reactor.test.publisher.FluxOperatorTest)

Example 80 with Subscription

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

the class MonoProcessorTest method scanProcessorSubscription.

@Test
public void scanProcessorSubscription() {
    MonoProcessor<String> test = MonoProcessor.create();
    Subscription subscription = Operators.emptySubscription();
    test.onSubscribe(subscription);
    assertThat(test.scan(Scannable.Attr.ACTUAL)).isNull();
    assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(subscription);
    test.getOrStart();
    assertThat(test.scan(Scannable.Attr.ACTUAL)).isNotNull();
}
Also used : Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

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