reactor.core.Fuseable Java Examples

The following examples show how to use reactor.core.Fuseable. 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: FluxPeekFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void conditionalFusionAvailable() {
	AssertSubscriber<Object> ts = AssertSubscriber.create();

	Flux.from(u -> {
		if (!(u instanceof Fuseable.ConditionalSubscriber)) {
			Operators.error(u,
					new IllegalArgumentException("The subscriber is not conditional: " + u));
		}
		else {
			Operators.complete(u);
		}
	})
	          .doOnNext(v -> {
	          })
	          .filter(v -> true)
	          .subscribe(ts);

	ts.assertNoError()
	  .assertNoValues()
	  .assertComplete();
}
 
Example #2
Source File: ReplayProcessorTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void timedAndBoundAfter() throws Exception {
	ReplayProcessor<Integer> rp =
			ReplayProcessor.createSizeAndTimeout(5, Duration.ofSeconds(1));

	StepVerifier.create(rp.hide())
	            .expectFusion(Fuseable.NONE)
	            .then(() -> {
		            for (int i = 0; i < 10; i++) {
			            rp.onNext(i);
		            }

		            VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2));

		            for (int i = 10; i < 20; i++) {
			            rp.onNext(i);
		            }
		            rp.onComplete();
	            })
	            .expectNextCount(20)
	            .verifyComplete();

	Assert.assertFalse("Has subscribers?", rp.hasDownstreams());
   }
 
Example #3
Source File: FluxGenerateTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void fusion() {
	AssertSubscriber<Integer> ts = AssertSubscriber.create();
	ts.requestedFusionMode(Fuseable.ANY);

	List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

	Flux.<Integer, Iterator<Integer>>generate(() -> list.iterator(), (s, o) -> {
		if (s.hasNext()) {
			o.next(s.next());
		}
		else {
			o.complete();
		}
		return s;
	}).subscribe(ts);

	ts.assertFuseableSource()
	  .assertFusionMode(Fuseable.SYNC)
	  .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}
 
Example #4
Source File: FluxFlatMap.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
	if (Operators.setOnce(S, this, s)) {
		if (s instanceof Fuseable.QueueSubscription) {
			@SuppressWarnings("unchecked") Fuseable.QueueSubscription<R> f =
					(Fuseable.QueueSubscription<R>) s;
			int m = f.requestFusion(Fuseable.ANY | Fuseable.THREAD_BARRIER);
			if (m == Fuseable.SYNC) {
				sourceMode = Fuseable.SYNC;
				queue = f;
				done = true;
				parent.drain(null);
				return;
			}
			if (m == Fuseable.ASYNC) {
				sourceMode = Fuseable.ASYNC;
				queue = f;
			}
			// NONE is just fall-through as the queue will be created on demand
		}
		s.request(Operators.unboundedOrPrefetch(prefetch));
	}
}
 
Example #5
Source File: FluxDiscardOnCancelTest.java    From r2dbc-mysql with Apache License 2.0 6 votes vote down vote up
@Test
void assemblyHook() {
    List<Object> publishers = new ArrayList<>();
    Hooks.onEachOperator(objectPublisher -> {
        publishers.add(objectPublisher);

        return objectPublisher;
    });

    Iterator<Integer> items = createItems(5);
    Flux<Integer> flux = Flux.fromIterable(() -> items);

    flux.transform(OperatorUtils::discardOnCancel)
        .as(StepVerifier::create)
        .expectNextCount(5)
        .verifyComplete();

    ObjectAssert<?> element = assertThat(publishers).hasSize(2).element(1);

    if (flux instanceof Fuseable) {
        element.isExactlyInstanceOf(FluxDiscardOnCancelFuseable.class);
    } else {
        element.isExactlyInstanceOf(FluxDiscardOnCancel.class);
    }
}
 
Example #6
Source File: ParallelLog.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void subscribe(CoreSubscriber<? super T>[] subscribers) {
	if (!validate(subscribers)) {
		return;
	}
	
	int n = subscribers.length;
	CoreSubscriber<? super T>[] parents = new CoreSubscriber[n];

	boolean conditional = subscribers[0] instanceof Fuseable.ConditionalSubscriber;

	for (int i = 0; i < n; i++) {
		if (conditional) {
			parents[i] = new FluxPeekFuseable.PeekConditionalSubscriber<>(
					(Fuseable.ConditionalSubscriber<T>)subscribers[i], log);
		}
		else {
			parents[i] = new FluxPeek.PeekSubscriber<>(subscribers[i], log);
		}
	}
	
	source.subscribe(parents);
}
 
Example #7
Source File: FluxUsingTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
  public void scanConditionalSubscriber() {
@SuppressWarnings("unchecked")
Fuseable.ConditionalSubscriber<Integer> actual = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class);
FluxUsing.UsingConditionalSubscriber<Integer, String> test =
		new FluxUsing.UsingConditionalSubscriber<>(actual, s -> {}, "", true);
      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.onComplete();
      Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
      Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
  }
 
Example #8
Source File: FluxSubscribeOnValueTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void testSubscribeOnValueFusion() {

	StepVerifier.create(Flux.range(1, 100)
	                        .flatMap(f -> Flux.just(f)
	                                          .subscribeOn(Schedulers.parallel())
	                                          .log("testSubscribeOnValueFusion", Level.FINE)
	                                          .map(this::slow)))
	            .expectFusion(Fuseable.ASYNC, Fuseable.NONE)
	            .expectNextCount(100)
	            .verifyComplete();

	int minExec = 2;

	for (Integer counted : execs.values()) {
		assertTrue("Thread used less than " + minExec + " " + "times",
				counted >= minExec);
	}

}
 
Example #9
Source File: FluxMetricsFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void queueClearEmptySizeDelegates() {
	AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create();
	FluxMetricsFuseable.MetricsFuseableSubscriber<Integer> fuseableSubscriber =
			new FluxMetricsFuseable.MetricsFuseableSubscriber<>(testSubscriber,
					registry, Clock.SYSTEM, "foo", Tags.empty());

	Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>();
	testQueue.offer(1);
	assertThat(testQueue.size()).isEqualTo(1);

	fuseableSubscriber.onSubscribe(testQueue);

	assertThat(fuseableSubscriber.isEmpty()).as("isEmpty").isFalse();
	assertThat(fuseableSubscriber.size()).as("size").isEqualTo(1);

	fuseableSubscriber.clear();

	assertThat(testQueue.size()).as("original queue impacted").isZero();
	assertThat(fuseableSubscriber.size()).as("size after clear").isEqualTo(0);
}
 
Example #10
Source File: FluxPublishMulticast.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public CoreSubscriber<? super T> subscribeOrReturn(CoreSubscriber<? super R> actual) {
	FluxPublishMulticaster<T> multicast = new FluxPublishMulticaster<>(prefetch,
			queueSupplier,
			actual.currentContext());

	Publisher<? extends R> out = Objects.requireNonNull(transform.apply(multicast),
			"The transform returned a null Publisher");

	if (out instanceof Fuseable) {
		out.subscribe(new CancelFuseableMulticaster<>(actual, multicast));
	}
	else {
		out.subscribe(new CancelMulticaster<>(actual, multicast));
	}

	return multicast;
}
 
Example #11
Source File: FluxFilterFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void failureStrategyResumeConditionalSyncFused() {
    Hooks.onNextError(OnNextFailureStrategy.RESUME_DROP);
    try {
        StepVerifier.create(Flux.range(0, 2)
                                .filter(i -> 4 / i == 4)
                                .filter(i -> true))
                    .expectFusion(Fuseable.ANY, Fuseable.SYNC)
                    .expectNext(1)
                    .expectComplete()
                    .verifyThenAssertThat()
                    .hasDroppedExactly(0)
                    .hasDroppedErrorWithMessage("/ by zero");
    }
    finally {
        Hooks.resetOnNextError();
    }
}
 
Example #12
Source File: FluxPublishMulticastTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Scenario<String, String>> scenarios_errorFromUpstreamFailure() {
	return Arrays.asList(scenario(f -> f.publish(p -> p)),

			scenario(f -> f.publish(p ->
					p.subscribeWith(Processors.unicast())))
					.fusionMode(Fuseable.ASYNC),

			scenario(f -> f.publish(p -> p))
					.shouldHitDropNextHookAfterTerminate(false),

			scenario(f -> Flux.never().publish(p -> {
				Disposable d = p.subscribe();
				Disposable d2 = p.subscribe();
				d.dispose();
				d2.dispose();

				return f;
			})).shouldHitDropErrorHookAfterTerminate(false)
			   .shouldHitDropNextHookAfterTerminate(false)

	);
}
 
Example #13
Source File: FluxSubscribeOnCallableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void normalBackpressuredFused() {
	StepVerifier.withVirtualTime(() -> Mono.fromCallable(() -> 1)
	                                       .flux()
	                                       .subscribeOn(
			Schedulers.single()), 0)
	            .expectFusion(Fuseable.ASYNC)
	            .thenAwait()
	            .consumeSubscriptionWith(s -> {
	            	assertThat(FluxSubscribeOnCallable
				            .CallableSubscribeOnSubscription.class.cast(s)
		            .size()).isEqualTo(1);
	            })
	            .thenRequest(1)
	            .thenAwait()
	            .expectNext(1)
	            .expectComplete()
	            .verify();
}
 
Example #14
Source File: FluxDistinctTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void distinctPredicateThrowsConditional() {
	IllegalStateException error = new IllegalStateException("forced failure");

	@SuppressWarnings("unchecked")
	Fuseable.ConditionalSubscriber<Integer> actualConditional = Mockito.mock(Fuseable.ConditionalSubscriber.class);
	when(actualConditional.currentContext()).thenReturn(Context.empty());
	when(actualConditional.tryOnNext(anyInt())).thenReturn(false);

	DistinctConditionalSubscriber<Integer, Integer, Set<Integer>> conditionalSubscriber =
			new DistinctConditionalSubscriber<>(
					actualConditional,
					new HashSet<>(),
					k -> k,
					(c, k) -> { throw error; },
					Set::clear);

	conditionalSubscriber.tryOnNext(1);

	verify(actualConditional, times(1)).onError(error);
}
 
Example #15
Source File: ReplayProcessorTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void timedFusedError() throws Exception {
	VirtualTimeScheduler.getOrSet();

	ReplayProcessor<Integer> rp =
			ReplayProcessor.createTimeout(Duration.ofSeconds(1));


	for (int i = 0; i < 5; i++) {
		rp.onNext(i);
	}

	VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2));

	for (int i = 5; i < 10; i++) {
		rp.onNext(i);
	}
	rp.onError(new Exception("test"));

	StepVerifier.create(rp)
	            .expectFusion(Fuseable.NONE)
	            .expectNext(5,6,7,8,9)
	            .verifyErrorMessage("test");
}
 
Example #16
Source File: ReplayProcessorTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void timedFusedAfter() throws Exception {
	ReplayProcessor<Integer> rp =
			ReplayProcessor.createTimeout(Duration.ofSeconds(1));

	StepVerifier.create(rp)
	            .expectFusion(Fuseable.NONE)
	            .then(() -> {
		            for (int i = 0; i < 5; i++) {
			            rp.onNext(i);
		            }

		            VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2));

		            for (int i = 5; i < 10; i++) {
			            rp.onNext(i);
		            }
		            rp.onComplete();
	            })
	            .expectNext(0,1,2,3,4,5,6,7,8,9)
	            .verifyComplete();
}
 
Example #17
Source File: SignalLoggerTests.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void testLogCollectionSubscription() {
	Flux<Integer> source = Flux.just(1, 2, 3);
	FluxPeekFuseable<Integer> flux = new FluxPeekFuseable<>(source, null, null, null, null, null, null, null);
	SignalLogger<Integer> signalLogger = new SignalLogger<>(flux,
			"test",
			Level.INFO,
			false, CollectionSpecialLogger::new,
			SignalType.ON_SUBSCRIBE);

	StepVerifier.create(flux.doOnSubscribe(Objects.requireNonNull(signalLogger.onSubscribeCall())))
	            .expectSubscription()
	            .expectNext(1, 2, 3)
	            .expectComplete()
	            .verify();

	//verify that passing the subscription directly to logger would have considered
	// it a Collection and thus failed with this custom Logger.
	StepVerifier.create(flux.doOnSubscribe(s -> signalLogger.log(SignalType.ON_SUBSCRIBE, s)))
	            .expectErrorMatches(t -> t instanceof UnsupportedOperationException &&
			            t.getMessage().equals(Fuseable.QueueSubscription.NOT_SUPPORTED_MESSAGE))
	            .verify();
}
 
Example #18
Source File: FluxFilterTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void discardConditionalTryOnNextPredicateFail() {
	List<Object> discarded = new ArrayList<>();
	Fuseable.ConditionalSubscriber<Integer> actual = new FluxPeekFuseableTest.ConditionalAssertSubscriber<>(
					Context.of(Hooks.KEY_ON_DISCARD, (Consumer<?>) discarded::add));

	FilterConditionalSubscriber<Integer> subscriber =
			new FilterConditionalSubscriber<>(actual, i -> {
				throw new IllegalStateException("boom");
			});
	subscriber.onSubscribe(Operators.emptySubscription());

	subscriber.tryOnNext(1);

	assertThat(discarded).containsExactly(1);
}
 
Example #19
Source File: FluxArrayTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void scanConditionalSubscriptionRequested() {
	@SuppressWarnings("unchecked")
	Fuseable.ConditionalSubscriber<? super Object> subscriber = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class);
	//the mock will not drain the request, so it can be tested
	Mockito.when(subscriber.tryOnNext(Mockito.any()))
	       .thenReturn(false);

	FluxArray.ArrayConditionalSubscription<Object> test =
			new FluxArray.ArrayConditionalSubscription<>(subscriber,
					new Object[]{"foo", "bar", "baz"});

	test.request(2);
	assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(2L);
	assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(3);
}
 
Example #20
Source File: FluxPublishOnTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void publishOnAsyncDetection() {
 Publisher<String> a = Flux.just("a");
 Publisher<String> b = Mono.just("b");

 Flux<Tuple2<String, String>> flux =
   Flux.from(a)
       .flatMap(value -> Mono.just(value)
                             .zipWith(Mono.from(b)))
       .publishOn(Schedulers.single());

 StepVerifier.create(flux)
             .expectFusion(Fuseable.ASYNC)
             .assertNext(tuple -> {
             	assertThat(tuple.getT1()).isEqualTo("a");
              assertThat(tuple.getT2()).isEqualTo("b");
             })
             .verifyComplete();
}
 
Example #21
Source File: FluxSwitchOnFirstTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCancelSourceOnUnrelatedPublisherCompleteConditional() {
    FluxIdentityProcessor<Long> testPublisher = Processors.multicast();

    testPublisher.onNext(1L);

    StepVerifier.create(testPublisher.switchOnFirst((s, f) -> Flux.empty().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);
                })
                .expectComplete()
                .verify(Duration.ofSeconds(5));

    Assertions.assertThat(testPublisher.scan(Attr.CANCELLED)).isTrue();
}
 
Example #22
Source File: FluxDistinctTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void scanConditionalSubscriber() {
	@SuppressWarnings("unchecked")
	Fuseable.ConditionalSubscriber<String> actual = Mockito.mock(MockUtils.TestScannableConditionalSubscriber.class);
	DistinctConditionalSubscriber<String, Integer, Set<Integer>> test =
			new DistinctConditionalSubscriber<>(actual, new HashSet<>(), String::hashCode, Set::add, Set::clear);
	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 #23
Source File: FluxPeekFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void conditionalFusionAvailableWithFuseable() {
	AssertSubscriber<Object> ts = AssertSubscriber.create();

	Flux.wrap(u -> {
		if (!(u instanceof Fuseable.ConditionalSubscriber)) {
			Operators.error(u,
					new IllegalArgumentException("The subscriber is not conditional: " + u));
		}
		else {
			Operators.complete(u);
		}
	})
	    .doOnNext(v -> {
	          })
	    .filter(v -> true)
	    .subscribe(ts);

	ts.assertNoError()
	  .assertNoValues()
	  .assertComplete();
}
 
Example #24
Source File: StepVerifierTests.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyDrainOnRequestInCaseOfFusion2() {
	ArrayList<Long> requests = new ArrayList<>();
	FluxIdentityProcessor<Integer> processor = Processors.unicast();
	StepVerifier.create(processor.doOnRequest(requests::add), 0)
			.expectFusion(Fuseable.ANY)
			.then(() -> {
				processor.onNext(1);
				processor.onComplete();
			})
			.thenRequest(1)
			.thenRequest(1)
			.thenRequest(1)
			.expectNext(1)
			.verifyComplete();

	assertThat(requests).containsExactly(1L, 1L, 1L);
}
 
Example #25
Source File: FluxMapTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@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 #26
Source File: MonoMetricsFuseableTest.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Test
public void queueClearEmptySizeDelegates() {
	AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create();
	MetricsFuseableSubscriber<Integer> fuseableSubscriber =
			new MetricsFuseableSubscriber<>(testSubscriber,
					registry, Clock.SYSTEM, Tags.empty());

	Fuseable.QueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>();
	testQueue.offer(1);
	assertThat(testQueue.size()).isEqualTo(1);

	fuseableSubscriber.onSubscribe(testQueue);

	assertThat(fuseableSubscriber.isEmpty()).as("isEmpty").isFalse();
	assertThat(fuseableSubscriber.size()).as("size").isEqualTo(1);

	fuseableSubscriber.clear();

	assertThat(testQueue.size()).as("original queue impacted").isZero();
	assertThat(fuseableSubscriber.size()).as("size after clear").isEqualTo(0);
}
 
Example #27
Source File: FluxOnBackpressureBuffer.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
	if ((requestedMode & Fuseable.ASYNC) != 0) {
		enabledFusion = true;
		return Fuseable.ASYNC;
	}
	return Fuseable.NONE;
}
 
Example #28
Source File: FluxPublish.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onSubscribe(Subscription s) {
	if (Operators.setOnce(S, this, s)) {
		if (s instanceof Fuseable.QueueSubscription) {
			@SuppressWarnings("unchecked") Fuseable.QueueSubscription<T> f =
					(Fuseable.QueueSubscription<T>) s;

			int m = f.requestFusion(Fuseable.ANY | Fuseable.THREAD_BARRIER);
			if (m == Fuseable.SYNC) {
				sourceMode = m;
				queue = f;
				drain();
				return;
			}
			if (m == Fuseable.ASYNC) {
				sourceMode = m;
				queue = f;
				s.request(Operators.unboundedOrPrefetch(prefetch));
				return;
			}
		}

		queue = parent.queueSupplier.get();

		s.request(Operators.unboundedOrPrefetch(prefetch));
	}
}
 
Example #29
Source File: UnboundedProcessor.java    From rsocket-java with Apache License 2.0 5 votes vote down vote up
@Override
public int requestFusion(int requestedMode) {
  if ((requestedMode & Fuseable.ASYNC) != 0) {
    outputFused = true;
    return Fuseable.ASYNC;
  }
  return Fuseable.NONE;
}
 
Example #30
Source File: StepVerifierTests.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyFusionModeExpectedError() {
	Mono<String> flux = Mono.just("foo");

	assertThatExceptionOfType(AssertionError.class)
			.isThrownBy(() -> StepVerifier.create(flux)
	            .expectFusion(Fuseable.SYNC, Fuseable.ASYNC)
	            .expectNext("foo")
	            .expectComplete()
	            .verify())
			.withMessage("expectation failed (expected fusion mode: (async); actual: (sync))");
}