use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableObserveOnTest method badSource.
@Test
public void badSource() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestScheduler scheduler = new TestScheduler();
TestSubscriber<Integer> to = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> observer) {
observer.onSubscribe(new BooleanSubscription());
observer.onComplete();
observer.onNext(1);
observer.onError(new TestException());
observer.onComplete();
}
}.observeOn(scheduler).test();
scheduler.triggerActions();
to.assertResult();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableFilterTest method sourceIgnoresCancelConditional.
@Test
public void sourceIgnoresCancelConditional() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
ConditionalSubscriber<? super Integer> cs = (ConditionalSubscriber<? super Integer>) s;
cs.onSubscribe(new BooleanSubscription());
cs.tryOnNext(1);
cs.tryOnNext(2);
cs.onError(new IOException());
cs.onComplete();
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableFilterTest method sourceIgnoresCancel.
@Test
public void sourceIgnoresCancel() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onNext(2);
s.onError(new IOException());
s.onComplete();
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableRetryTest method testSourceObservableRetry1.
@Test
public void testSourceObservableRetry1() throws InterruptedException {
final AtomicInteger subsCount = new AtomicInteger(0);
final TestSubscriber<String> ts = new TestSubscriber<String>();
Publisher<String> onSubscribe = new Publisher<String>() {
@Override
public void subscribe(Subscriber<? super String> s) {
s.onSubscribe(new BooleanSubscription());
subsCount.incrementAndGet();
s.onError(new RuntimeException("failed"));
}
};
Flowable.unsafeCreate(onSubscribe).retry(1).subscribe(ts);
assertEquals(2, subsCount.get());
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableRetryWithPredicateTest method testRetryOnSpecificExceptionAndNotOther.
@Test
public void testRetryOnSpecificExceptionAndNotOther() {
final IOException ioe = new IOException();
final TestException te = new TestException();
Flowable<Integer> source = Flowable.unsafeCreate(new Publisher<Integer>() {
int count;
@Override
public void subscribe(Subscriber<? super Integer> t1) {
t1.onSubscribe(new BooleanSubscription());
count++;
t1.onNext(0);
t1.onNext(1);
if (count == 1) {
t1.onError(ioe);
return;
}
t1.onNext(2);
t1.onNext(3);
t1.onError(te);
}
});
@SuppressWarnings("unchecked") DefaultSubscriber<Integer> o = mock(DefaultSubscriber.class);
InOrder inOrder = inOrder(o);
source.retry(retryOnTestException).subscribe(o);
inOrder.verify(o).onNext(0);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(0);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onError(te);
verify(o, never()).onError(ioe);
verify(o, never()).onComplete();
}
Aggregations