use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowablePublishTest method asyncFusedObserveOn.
@Test
public void asyncFusedObserveOn() {
ConnectableFlowable<Integer> cf = Flowable.range(0, 1000).observeOn(ImmediateThinScheduler.INSTANCE).publish();
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);
cf.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 syncFusedObserveOn.
@Test
public void syncFusedObserveOn() {
ConnectableFlowable<Integer> cf = Flowable.range(0, 1000).publish();
Flowable<Integer> obs = cf.observeOn(Schedulers.computation());
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 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.TestSubscriberEx in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method onErrorOnCompleteRace.
@Test
@SuppressUndeliverable
public void onErrorOnCompleteRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
ts.onSubscribe(new BooleanSubscription());
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
HalfSerializer.onError(ts, ex, wip, error);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
HalfSerializer.onComplete(ts, wip, error);
}
};
TestHelper.race(r1, r2);
if (ts.completions() != 0) {
ts.assertResult();
} else {
ts.assertFailure(TestException.class);
}
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class StrictSubscriberTest method normalOnError.
@Test
public void normalOnError() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
SubscriberWrapper<Integer> wrapper = new SubscriberWrapper<>(ts);
Flowable.range(1, 5).concatWith(Flowable.<Integer>error(new TestException())).subscribe(wrapper);
ts.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
Aggregations