use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableDebounceTest method debounceWithTimeBackpressure.
@Test
public void debounceWithTimeBackpressure() throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
TestSubscriberEx<Integer> subscriber = new TestSubscriberEx<>();
Flowable.merge(Flowable.just(1), Flowable.just(2).delay(10, TimeUnit.MILLISECONDS, scheduler)).debounce(20, TimeUnit.MILLISECONDS, scheduler).take(1).subscribe(subscriber);
scheduler.advanceTimeBy(30, TimeUnit.MILLISECONDS);
subscriber.assertValue(2);
subscriber.assertTerminated();
subscriber.assertNoErrors();
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableTakeUntilPredicateTest method errorIncludesLastValueAsCause.
@Test
public void errorIncludesLastValueAsCause() {
TestSubscriberEx<String> ts = new TestSubscriberEx<>();
final TestException e = new TestException("Forced failure");
Predicate<String> predicate = new Predicate<String>() {
@Override
public boolean test(String t) {
throw e;
}
};
Flowable.just("abc").takeUntil(predicate).subscribe(ts);
ts.assertTerminated();
ts.assertNotComplete();
ts.assertError(TestException.class);
// FIXME last cause value is not saved
// assertTrue(ts.errors().get(0).getCause().getMessage().contains("abc"));
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableTimeoutTests method shouldUnsubscribeFromUnderlyingSubscriptionOnTimeout.
@Test
public void shouldUnsubscribeFromUnderlyingSubscriptionOnTimeout() throws InterruptedException {
// From https://github.com/ReactiveX/RxJava/pull/951
final Subscription s = mock(Subscription.class);
Flowable<String> never = Flowable.unsafeCreate(new Publisher<String>() {
@Override
public void subscribe(Subscriber<? super String> subscriber) {
subscriber.onSubscribe(s);
}
});
TestScheduler testScheduler = new TestScheduler();
Flowable<String> observableWithTimeout = never.timeout(1000, TimeUnit.MILLISECONDS, testScheduler);
TestSubscriberEx<String> subscriber = new TestSubscriberEx<>();
observableWithTimeout.subscribe(subscriber);
testScheduler.advanceTimeBy(2000, TimeUnit.MILLISECONDS);
subscriber.assertFailureAndMessage(TimeoutException.class, timeoutMessage(1000, TimeUnit.MILLISECONDS));
verify(s, times(1)).cancel();
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowablePublishTest method syncFusedObserveOn2.
@Test
public void syncFusedObserveOn2() {
ConnectableFlowable<Integer> cf = Flowable.range(0, 1000).publish();
Flowable<Integer> obs = cf.observeOn(ImmediateThinScheduler.INSTANCE);
for (int i = 0; i < 1000; i++) {
for (int j = 1; j < 6; j++) {
List<TestSubscriberEx<Integer>> tss = new ArrayList<>();
for (int k = 1; k < j; k++) {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
tss.add(ts);
obs.subscribe(ts);
}
Disposable connection = cf.connect();
for (TestSubscriberEx<Integer> ts : tss) {
ts.awaitDone(5, TimeUnit.SECONDS).assertSubscribed().assertValueCount(1000).assertNoErrors().assertComplete();
}
connection.dispose();
}
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowablePublishTest method subscribeAfterDisconnectThenConnect.
@Test
public void subscribeAfterDisconnectThenConnect() {
ConnectableFlowable<Integer> source = Flowable.just(1).publish();
TestSubscriberEx<Integer> ts1 = new TestSubscriberEx<>();
source.subscribe(ts1);
Disposable connection = source.connect();
ts1.assertValue(1);
ts1.assertNoErrors();
ts1.assertTerminated();
source.reset();
TestSubscriberEx<Integer> ts2 = new TestSubscriberEx<>();
source.subscribe(ts2);
Disposable connection2 = source.connect();
ts2.assertValue(1);
ts2.assertNoErrors();
ts2.assertTerminated();
System.out.println(connection);
System.out.println(connection2);
}
Aggregations