use of io.reactivex.rxjava3.core.Flowable 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.core.Flowable in project RxJava by ReactiveX.
the class FlowableRepeatTest method noCancelPreviousRepeatWhen.
@Test
public void noCancelPreviousRepeatWhen() {
final AtomicInteger counter = new AtomicInteger();
Flowable<Integer> source = Flowable.just(1).doOnCancel(new Action() {
@Override
public void run() throws Exception {
counter.getAndIncrement();
}
});
final AtomicInteger times = new AtomicInteger();
source.repeatWhen(new Function<Flowable<Object>, Flowable<?>>() {
@Override
public Flowable<?> apply(Flowable<Object> e) throws Exception {
return e.takeWhile(new Predicate<Object>() {
@Override
public boolean test(Object v) throws Exception {
return times.getAndIncrement() < 4;
}
});
}
}).test().assertResult(1, 1, 1, 1, 1);
assertEquals(0, counter.get());
}
use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.
the class ParallelJoinTest method onNextMissingBackpressureDelayErrorRace.
@Test
public void onNextMissingBackpressureDelayErrorRace() throws Throwable {
TestHelper.withErrorTracking(errors -> {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
AtomicReference<Subscriber<? super Integer>> ref2 = new AtomicReference<>();
Flowable<Integer> f1 = new Flowable<Integer>() {
@Override
public void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
ref1.set(s);
}
};
Flowable<Integer> f2 = new Flowable<Integer>() {
@Override
public void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
ref2.set(s);
}
};
ParallelFlowable.fromArray(f1, f2).sequentialDelayError(1).test(0);
TestHelper.race(() -> {
ref1.get().onNext(1);
ref1.get().onNext(2);
}, () -> {
ref2.get().onNext(3);
ref2.get().onNext(4);
});
errors.clear();
}
});
}
use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.
the class ParallelSortedJoinTest method error3.
@Test
public void error3() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.<Integer>error(new TestException()).parallel().sorted(Functions.<Integer>naturalComparator()).test(0).assertFailure(TestException.class);
assertTrue(errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.
the class ParallelSortedJoinTest method error.
@Test
public void error() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.<Integer>error(new TestException()).parallel().sorted(Functions.<Integer>naturalComparator()).test().assertFailure(TestException.class);
assertTrue(errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations