use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class FlowableSequenceEqualTest method doubleErrorFlowable.
@Test
public void doubleErrorFlowable() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.sequenceEqual(Flowable.never(), new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> s) {
s.onSubscribe(new BooleanSubscription());
s.onError(new TestException("First"));
s.onError(new TestException("Second"));
}
}, 8).toFlowable().to(TestHelper.<Boolean>testConsumer()).assertFailureAndMessage(TestException.class, "First");
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class FlowableWindowWithFlowableTest method takeOneAnotherBoundary.
@Test
public void takeOneAnotherBoundary() {
final AtomicReference<Subscriber<? super Object>> refMain = new AtomicReference<>();
final AtomicReference<Subscriber<? super Object>> ref = new AtomicReference<>();
TestSubscriberEx<Flowable<Object>> ts = new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
refMain.set(subscriber);
}
}.window(new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
ref.set(subscriber);
}
}).to(TestHelper.<Flowable<Object>>testConsumer());
ts.assertValueCount(1).assertNotTerminated().cancel();
ref.get().onNext(1);
ts.assertValueCount(1).assertNotTerminated();
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class FlowableWindowWithFlowableTest method mainCompleteBoundaryErrorRace.
@Test
public void mainCompleteBoundaryErrorRace() {
final TestException ex = new TestException();
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<Subscriber<? super Object>> refMain = new AtomicReference<>();
final AtomicReference<Subscriber<? super Object>> ref = new AtomicReference<>();
TestSubscriberEx<Flowable<Object>> ts = new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
refMain.set(subscriber);
}
}.window(new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
ref.set(subscriber);
}
}).to(TestHelper.<Flowable<Object>>testConsumer());
Runnable r1 = new Runnable() {
@Override
public void run() {
refMain.get().onComplete();
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
ref.get().onError(ex);
}
};
TestHelper.race(r1, r2);
ts.assertValueCount(1).assertTerminated();
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class AsyncProcessorTest method onErrorCancelRace.
@Test
@SuppressUndeliverable
public void onErrorCancelRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AsyncProcessor<Object> p = AsyncProcessor.create();
final TestSubscriberEx<Object> ts1 = p.to(TestHelper.<Object>testConsumer());
Runnable r1 = new Runnable() {
@Override
public void run() {
ts1.cancel();
}
};
final TestException ex = new TestException();
Runnable r2 = new Runnable() {
@Override
public void run() {
p.onError(ex);
}
};
TestHelper.race(r1, r2);
if (ts1.errors().size() != 0) {
ts1.assertFailure(TestException.class);
} else {
ts1.assertEmpty();
}
}
}
use of io.reactivex.rxjava3.testsupport.TestHelper in project RxJava by ReactiveX.
the class CompletableTimeoutTest method errorTimeoutRace.
@Test
public void errorTimeoutRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final TestScheduler scheduler = new TestScheduler();
final PublishSubject<Integer> ps = PublishSubject.create();
TestObserverEx<Void> to = ps.ignoreElements().timeout(1, TimeUnit.MILLISECONDS, scheduler, Completable.complete()).to(TestHelper.<Void>testConsumer());
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
ps.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
}
};
TestHelper.race(r1, r2);
to.assertTerminated();
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
Aggregations