reactor.core.Scannable Java Examples
The following examples show how to use
reactor.core.Scannable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MonoDelayElementTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanSubscriber() { CoreSubscriber<String> actual = new LambdaMonoSubscriber<>(null, e -> {}, null, null); MonoDelayElement.DelayElementSubscriber<String> test = new MonoDelayElement.DelayElementSubscriber<>( actual, Schedulers.single(), 10, TimeUnit.MILLISECONDS); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE); assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(Schedulers.single()); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #2
Source File: FluxHandleTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanFuseableConditionalSubscriber() { @SuppressWarnings("unchecked") Fuseable.ConditionalSubscriber<? super Object> subscriber = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class); FluxHandleFuseable.HandleFuseableConditionalSubscriber<String, String> test = new FluxHandleFuseable.HandleFuseableConditionalSubscriber<>(subscriber, (a, b) -> {}); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subscriber); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.error = new IllegalStateException("boom"); assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error); test.onComplete(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #3
Source File: FluxMapTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanFuseableConditionalSubscriber() { @SuppressWarnings("unchecked") Fuseable.ConditionalSubscriber<String> actual = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class); FluxMapFuseable.MapFuseableConditionalSubscriber<Integer, String> test = new FluxMapFuseable.MapFuseableConditionalSubscriber<>(actual, i -> String.valueOf(i)); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #4
Source File: MonoFlatMapManyTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanInner() { CoreSubscriber<Integer> mainActual = new LambdaMonoSubscriber<>(null, e -> {}, null, null); CoreSubscriber<Integer> actual = new LambdaMonoSubscriber<>(null, e -> {}, null, null); MonoFlatMapMany.FlatMapManyMain<String, Integer> main = new MonoFlatMapMany.FlatMapManyMain<> (mainActual, s -> Flux.just(1, 2, 3)); MonoFlatMapMany.FlatMapManyInner<Integer> test = new MonoFlatMapMany.FlatMapManyInner<>(main, actual); Subscription innerSubscription = Operators.emptySubscription(); test.onSubscribe(innerSubscription); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(innerSubscription); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main); main.requested = 3L; assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(3L); }
Example #5
Source File: FluxSkipUntilOtherTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanOtherSubscriber() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxSkipUntilOther.SkipUntilMainSubscriber<Integer> main = new FluxSkipUntilOther.SkipUntilMainSubscriber<>(actual); FluxSkipUntilOther.SkipUntilOtherSubscriber<Integer> test = new FluxSkipUntilOther.SkipUntilOtherSubscriber<>(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); Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); main.cancel(); Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #6
Source File: FluxIntervalTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanIntervalRunnable() { Scheduler.Worker worker = Schedulers.single().createWorker(); try { CoreSubscriber<Long> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxInterval.IntervalRunnable test = new FluxInterval.IntervalRunnable(actual, worker); assertThat(test.scan(Scannable.Attr.RUN_ON)).isSameAs(worker); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); } finally { worker.dispose(); } }
Example #7
Source File: FluxNameFuseableTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanOperator() throws Exception { Tuple2<String, String> tag1 = Tuples.of("foo", "oof"); Tuple2<String, String> tag2 = Tuples.of("bar", "rab"); Set<Tuple2<String, String>> tags = new HashSet<>(); tags.add(tag1); tags.add(tag2); Flux<Integer> source = Flux.range(1, 4).map(i -> i); FluxNameFuseable<Integer> test = new FluxNameFuseable<>(source, "foo", tags); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source); assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(-1); assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo"); //noinspection unchecked final Stream<Tuple2<String, String>> scannedTags = test.scan(Scannable.Attr.TAGS); assertThat(scannedTags).isNotNull(); assertThat(scannedTags.iterator()).containsExactlyInAnyOrder(tag1, tag2); }
Example #8
Source File: FluxBufferBoundaryTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanOther() { CoreSubscriber<Object> actual = new LambdaSubscriber<>(null, null, null, null); FluxBufferBoundary.BufferBoundaryMain<String, Integer, List<String>> main = new FluxBufferBoundary.BufferBoundaryMain<>( actual, null, ArrayList::new); FluxBufferBoundary.BufferBoundaryOther<Integer> test = new FluxBufferBoundary.BufferBoundaryOther<>(main); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); //the request is not tracked when there is a parent test.request(2); assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(0L); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #9
Source File: FluxExpandTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanExpandBreathSubscriber() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, Throwable::printStackTrace, null,null); ExpandBreathSubscriber<Integer> test = new ExpandBreathSubscriber<>(actual, i -> i > 5 ? Mono.empty() : Mono.just(i + 1), 123); Subscription s = Operators.emptySubscription(); test.onSubscribe(s); assertThat(test.scan(Scannable.Attr.PARENT)).isEqualTo(s); assertThat(test.scan(Scannable.Attr.ACTUAL)).isEqualTo(actual); test.request(3); assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(3); assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(0); test.onNext(1); assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #10
Source File: FluxSwitchOnFirstTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void shouldCancelSourceOnUnrelatedPublisherErrorConditional() { FluxIdentityProcessor<Long> testPublisher = Processors.multicast(); testPublisher.onNext(1L); StepVerifier.create(testPublisher.switchOnFirst((s, f) -> Flux.error(new RuntimeException("test")).delaySubscription(Duration.ofMillis(10))).filter(__ -> true)) .then(() -> { List<? extends Scannable> subs = testPublisher.inners().collect(Collectors.toList()); Assertions.assertThat(subs) .hasSize(1) .first() .extracting(psi -> psi.scan(Attr.ACTUAL)) .isInstanceOf(Fuseable.ConditionalSubscriber.class); }) .expectErrorSatisfies(t -> Assertions.assertThat(t) .hasMessage("test") .isExactlyInstanceOf(RuntimeException.class) ) .verify(Duration.ofSeconds(5)); Assertions.assertThat(testPublisher.scan(Attr.CANCELLED)).isTrue(); }
Example #11
Source File: FluxScanTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanSubscriber() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxScan.ScanSubscriber<Integer> test = new FluxScan.ScanSubscriber<>(actual, (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); test.value = 5; Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1); Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.onComplete(); Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #12
Source File: FluxDoFinallyTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanSubscriber() { CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxDoFinally.DoFinallySubscriber<String> test = new FluxDoFinally.DoFinallySubscriber<>(actual, st -> {}); 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.CANCELLED)).isFalse(); Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.onError(new IllegalStateException("boom")); Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #13
Source File: FluxSwitchMapTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanInner() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxSwitchMap.SwitchMapMain<Integer, Integer> main = new FluxSwitchMap.SwitchMapMain<>(actual, i -> Mono.just(i), Queues.unbounded().get(), 234); FluxSwitchMap.SwitchMapInner<Integer> test = new FluxSwitchMap.SwitchMapInner<Integer>(main, 1, 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); Assertions.assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(1); Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #14
Source File: FluxFirstNonEmptyEmittingTests.java From spring-cloud-commons with Apache License 2.0 | 6 votes |
@Test public void scanRaceCoordinator() { CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> { }, null, null); FluxFirstNonEmptyEmitting.RaceCoordinator<String> parent = new FluxFirstNonEmptyEmitting.RaceCoordinator<>( 1); FluxFirstNonEmptyEmitting.FirstNonEmptyEmittingSubscriber<String> test = new FluxFirstNonEmptyEmitting.FirstNonEmptyEmittingSubscriber<>( actual, parent, 1); Subscription sub = Operators.emptySubscription(); test.onSubscribe(sub); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(sub); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(parent.scan(Scannable.Attr.CANCELLED)).isFalse(); parent.cancelled = true; assertThat(parent.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #15
Source File: DefaultStepVerifierBuilder.java From reactor-core with Apache License 2.0 | 6 votes |
@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 messageFormatter.assertionError("Expected no accessible Context, got " + c); } }); }
Example #16
Source File: FluxHandleTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanSubscriber() { CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxHandle.HandleSubscriber<String, String> test = new FluxHandle.HandleSubscriber<>(actual, (a, b) -> {}); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.error = new IllegalStateException("boom"); assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error); test.onComplete(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #17
Source File: MonoZipTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanWhenInner() { CoreSubscriber<? super String> actual = new LambdaMonoSubscriber<>(null, e -> {}, null, null); MonoZip.ZipCoordinator<String> coordinator = new MonoZip.ZipCoordinator<>(actual, 2, false, a -> null); MonoZip.ZipInner<String> test = new MonoZip.ZipInner<>(coordinator); Subscription innerSub = Operators.cancelledSubscription(); test.onSubscribe(innerSub); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(innerSub); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(coordinator); assertThat(coordinator.scan(Scannable.Attr.TERMINATED)).isFalse(); //done == 1 test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom"); assertThat(coordinator.scan(Scannable.Attr.TERMINATED)).isTrue(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #18
Source File: FluxPublishTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanPubSubInner() { FluxPublish<Integer> main = new FluxPublish<>(Flux.just(1), 123, Queues.unbounded()); FluxPublish.PublishSubscriber<Integer> parent = new FluxPublish.PublishSubscriber<>(789, main); Subscription sub = Operators.emptySubscription(); parent.onSubscribe(sub); FluxPublish.PubSubInner<Integer> test = new FluxPublish.PublishInner<>(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(parent); test.request(35); assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example #19
Source File: FluxDetachTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanSubscriberCancelled() { CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxDetach.DetachSubscriber<String> test = new FluxDetach.DetachSubscriber<>(actual); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.PARENT)).isNull(); assertThat(test.scan(Scannable.Attr.ACTUAL)).isNull(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #20
Source File: MonoMetricsTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void sequenceNameFromScanUnavailable() { Mono<String> delegate = Mono.just("foo"); Mono<String> source = new Mono<String>() { @Override public void subscribe(CoreSubscriber<? super String> actual) { delegate.subscribe(actual); } }; MonoMetrics<String> test = new MonoMetrics<>(source, registry); assertThat(Scannable.from(source).isScanAvailable()) .as("source scan unavailable").isFalse(); assertThat(test.name).isEqualTo(REACTOR_DEFAULT_NAME); }
Example #21
Source File: InnerProducerTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanDefaultMethod() { CoreSubscriber<String> actual = new LambdaSubscriber<>(null, null, null, null); InnerProducer<String> test = new InnerProducer<String>() { @Override public CoreSubscriber<? super String> actual() { return actual; } @Override public void request(long n) { } @Override public void cancel() { } }; assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); }
Example #22
Source File: FluxMergeSequentialTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanMain() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxMergeSequential.MergeSequentialMain<Integer, Integer> test = new FluxMergeSequential.MergeSequentialMain<Integer, Integer>(actual, i -> Mono.just(i), 5, 123, ErrorMode.BOUNDARY, Queues.unbounded()); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue(); test.requested = 35; assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35); assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(5); test.subscribers.add(new FluxMergeSequential.MergeSequentialInner<>(test, 123)); assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1); assertThat(test.scan(Scannable.Attr.ERROR)).isNull(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #23
Source File: DelegateServiceSchedulerTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanNameAnonymous() { final ExecutorService fixedExecutor = Executors.newFixedThreadPool(3); final ExecutorService cachedExecutor = Executors.newCachedThreadPool(); final ExecutorService singleExecutor = Executors.newSingleThreadExecutor(); Scheduler fixedThreadPool = afterTest.autoDispose(Schedulers.fromExecutorService(fixedExecutor)); Scheduler cachedThreadPool = afterTest.autoDispose(Schedulers.fromExecutorService(cachedExecutor)); Scheduler singleThread = afterTest.autoDispose(Schedulers.fromExecutorService(singleExecutor)); String fixedId = Integer.toHexString(System.identityHashCode(fixedExecutor)); String cachedId = Integer.toHexString(System.identityHashCode(cachedExecutor)); String singleId = Integer.toHexString(System.identityHashCode(singleExecutor)); assertThat(Scannable.from(fixedThreadPool).scan(Scannable.Attr.NAME)) .as("fixedThreadPool") .isEqualTo("fromExecutorService(anonymousExecutor@" + fixedId + ")"); assertThat(Scannable.from(cachedThreadPool).scan(Scannable.Attr.NAME)) .as("cachedThreadPool") .isEqualTo("fromExecutorService(anonymousExecutor@" + cachedId + ")"); assertThat(Scannable.from(singleThread).scan(Scannable.Attr.NAME)) .as("singleThread") .isEqualTo("fromExecutorService(anonymousExecutor@" + singleId + ")"); }
Example #24
Source File: ReplayProcessorTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanProcessor() { ReplayProcessor<String> test = ReplayProcessor.create(16, false); Subscription subscription = Operators.emptySubscription(); test.onSubscribe(subscription); assertThat(test.scan(Scannable.Attr.PARENT)).isEqualTo(subscription); assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(16); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.ERROR)).isNull(); test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom"); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }
Example #25
Source File: FluxTakeTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void failFusedDoubleError() { FluxIdentityProcessor<Integer> up = Processors.unicast(); Hooks.onErrorDropped(e -> assertThat(e).hasMessage("test2")); StepVerifier.create(up .take(2)) .consumeSubscriptionWith(s -> { assertTrackableBeforeOnSubscribe((InnerOperator)s); }) .then(() -> { InnerOperator processorDownstream = (InnerOperator) up.scan(Scannable.Attr.ACTUAL); assertTrackableAfterOnSubscribe(processorDownstream); processorDownstream.onError(new Exception("test")); assertTrackableAfterOnComplete(processorDownstream); processorDownstream.onError(new Exception("test2")); }) .verifyErrorMessage("test"); }
Example #26
Source File: ParallelMergeSequentialTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanMainSubscriberError() { LambdaSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> { }, null, s -> s.request(2)); MergeSequentialMain<Integer> test = new MergeSequentialMain<>(subscriber, 4, 123, Queues.small()); subscriber.onSubscribe(test); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.ERROR)).isNull(); test.onError(new IllegalStateException("boom")); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom"); }
Example #27
Source File: FluxTakeTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void scanSubscriber() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxTake.TakeSubscriber<Integer> test = new FluxTake.TakeSubscriber<>(actual, 5); 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(); }
Example #28
Source File: MonoCallableOnAssemblyTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void scanOperator() { AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get()); MonoCallableOnAssembly<?> test = new MonoCallableOnAssembly<>(Mono.empty(), stacktrace); assertThat(test.scan(Scannable.Attr.ACTUAL_METADATA)).as("ACTUAL_METADATA").isTrue(); }
Example #29
Source File: FluxMetrics.java From reactor-core with Apache License 2.0 | 5 votes |
/** * Extract the tags from the upstream * * @param source the upstream * * @return a {@link Tags} of {@link Tag} */ static Tags resolveTags(Publisher<?> source, Tags tags, String sequenceName) { Scannable scannable = Scannable.from(source); tags = tags.and(Tag.of(FluxMetrics.TAG_SEQUENCE_NAME, sequenceName)); if (scannable.isScanAvailable()) { return scannable.tags() //Note the combiner below is for parallel streams, which won't be used //For the identity, `commonTags` should be ok (even if reduce uses it multiple times) //since it deduplicates .reduce(tags, TAG_ACCUMULATOR, TAG_COMBINER); } return tags; }
Example #30
Source File: FluxJustTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void scanSubscription() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, sub -> sub.request(100)); FluxJust.WeakScalarSubscription<Integer> test = new FluxJust.WeakScalarSubscription<>(1, actual); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); }