Search in sources :

Example 1 with Scannable

use of reactor.core.Scannable in project reactor-core by reactor.

the class DefaultStepVerifierBuilder method expectNoAccessibleContext.

@Override
public DefaultStepVerifierBuilder<T> expectNoAccessibleContext() {
    return consumeSubscriptionWith(sub -> {
        Scannable lowest = Scannable.from(sub);
        Scannable verifierSubscriber = Scannable.from(lowest.scan(Scannable.Attr.ACTUAL));
        Context c = Flux.fromStream(verifierSubscriber.parents()).ofType(CoreSubscriber.class).map(CoreSubscriber::currentContext).blockLast();
        if (c != null) {
            throw errorFormatter.assertionError("Expected no accessible Context, got " + c);
        }
    });
}
Also used : Context(reactor.util.context.Context) Scannable(reactor.core.Scannable)

Example 2 with Scannable

use of reactor.core.Scannable in project reactor-core by reactor.

the class BaseOperatorTest method touchInner.

final void touchInner(@Nullable Object t) {
    if (t == null)
        return;
    Scannable o = Scannable.from(t);
    o.scan(Scannable.Attr.ACTUAL);
    o.scan(Scannable.Attr.BUFFERED);
    o.scan(Scannable.Attr.CANCELLED);
    o.scan(Scannable.Attr.CAPACITY);
    o.scan(Scannable.Attr.DELAY_ERROR);
    o.scan(Scannable.Attr.ERROR);
    o.scan(Scannable.Attr.PREFETCH);
    o.scan(Scannable.Attr.PARENT);
    o.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM);
    o.scan(Scannable.Attr.TERMINATED);
    o.inners();
}
Also used : Scannable(reactor.core.Scannable)

Example 3 with Scannable

use of reactor.core.Scannable in project reactor-core by reactor.

the class BaseOperatorTest method fluxState.

final PO fluxState(OperatorScenario<I, PI, O, PO> scenario, boolean conditional) {
    Flux<I> source = Flux.from(s -> {
        Scannable t = Scannable.from(s);
        assertThat(t.scan(Scannable.Attr.ERROR)).isNull();
        assertThat(t.scanOrDefault(Scannable.Attr.TERMINATED, false)).isFalse();
        if (scenario.prefetch() != -1) {
            assertThat(t.scan(Scannable.Attr.PREFETCH)).isEqualTo(scenario.prefetch());
        }
        touchTreeState(s);
        s.onSubscribe(Operators.emptySubscription());
        // noop path
        s.onSubscribe(Operators.emptySubscription());
        // noop path
        s.onSubscribe(Operators.cancelledSubscription());
        s.onComplete();
        touchTreeState(s);
        if (scenario.shouldAssertPostTerminateState()) {
            assertThat(t.scanOrDefault(Scannable.Attr.TERMINATED, true)).isTrue();
        }
    });
    return applyStateScenario(scenario, conditional, source);
}
Also used : Scannable(reactor.core.Scannable)

Example 4 with Scannable

use of reactor.core.Scannable in project reactor-core by reactor.

the class FluxOnBackpressureBufferTimeoutTest method scanOperator.

@Test
public void scanOperator() {
    Scannable test = (Scannable) Flux.never().onBackpressureBuffer(Duration.ofSeconds(1), 123, v -> {
    }, Schedulers.single());
    assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.single());
}
Also used : TestPublisher(reactor.test.publisher.TestPublisher) StepVerifier(reactor.test.StepVerifier) Iterator(java.util.Iterator) VirtualTimeScheduler(reactor.test.scheduler.VirtualTimeScheduler) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) Test(org.junit.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) BackpressureBufferTimeoutSubscriber(reactor.core.publisher.FluxOnBackpressureBufferTimeout.BackpressureBufferTimeoutSubscriber) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) List(java.util.List) CoreSubscriber(reactor.core.CoreSubscriber) Duration(java.time.Duration) Subscription(org.reactivestreams.Subscription) Schedulers(reactor.core.scheduler.Schedulers) Collections(java.util.Collections) Scannable(reactor.core.Scannable) Test(org.junit.Test)

Example 5 with Scannable

use of reactor.core.Scannable in project reactor-core by reactor.

the class FluxPublishOnTest method scanRunOn.

@Test
public void scanRunOn() {
    Scannable publishOnScannable = Scannable.from(Flux.just(1).hide().publishOn(Schedulers.elastic()));
    Scannable runOnScannable = publishOnScannable.scan(Scannable.Attr.RUN_ON);
    Assertions.assertThat(runOnScannable).isNotNull().matches(Scannable::isScanAvailable, "isScanAvailable");
    System.out.println(runOnScannable + " isScannable " + runOnScannable.isScanAvailable());
    System.out.println(runOnScannable.scan(Scannable.Attr.NAME));
    runOnScannable.parents().forEach(System.out::println);
    System.out.println(runOnScannable.scan(Scannable.Attr.BUFFERED));
}
Also used : Scannable(reactor.core.Scannable) FluxOperatorTest(reactor.test.publisher.FluxOperatorTest) Test(org.junit.Test)

Aggregations

Scannable (reactor.core.Scannable)8 Test (org.junit.Test)5 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 List (java.util.List)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Consumer (java.util.function.Consumer)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Subscription (org.reactivestreams.Subscription)2 StepVerifier (reactor.test.StepVerifier)2 IOException (java.io.IOException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 After (org.junit.After)1 Before (org.junit.Before)1 Publisher (org.reactivestreams.Publisher)1 Subscriber (org.reactivestreams.Subscriber)1 CoreSubscriber (reactor.core.CoreSubscriber)1 Exceptions (reactor.core.Exceptions)1 Fuseable (reactor.core.Fuseable)1