use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class LambdaSubscriberTest method badSourceOnSubscribe.
@Test
public void badSourceOnSubscribe() {
Flowable<Integer> source = Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
BooleanSubscription s1 = new BooleanSubscription();
s.onSubscribe(s1);
BooleanSubscription s2 = new BooleanSubscription();
s.onSubscribe(s2);
assertFalse(s1.isCancelled());
assertTrue(s2.isCancelled());
s.onNext(1);
s.onComplete();
}
});
final List<Object> received = new ArrayList<Object>();
LambdaSubscriber<Object> o = new LambdaSubscriber<Object>(new Consumer<Object>() {
@Override
public void accept(Object v) throws Exception {
received.add(v);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
received.add(e);
}
}, new Action() {
@Override
public void run() throws Exception {
received.add(100);
}
}, new Consumer<Subscription>() {
@Override
public void accept(Subscription s) throws Exception {
s.request(Long.MAX_VALUE);
}
});
source.subscribe(o);
assertEquals(Arrays.asList(1, 100), received);
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class LambdaSubscriberTest method badSourceEmitAfterDone.
@Test
public void badSourceEmitAfterDone() {
Flowable<Integer> source = Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
BooleanSubscription s1 = new BooleanSubscription();
s.onSubscribe(s1);
s.onNext(1);
s.onComplete();
s.onNext(2);
s.onError(new TestException());
s.onComplete();
}
});
final List<Object> received = new ArrayList<Object>();
LambdaSubscriber<Object> o = new LambdaSubscriber<Object>(new Consumer<Object>() {
@Override
public void accept(Object v) throws Exception {
received.add(v);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
received.add(e);
}
}, new Action() {
@Override
public void run() throws Exception {
received.add(100);
}
}, new Consumer<Subscription>() {
@Override
public void accept(Subscription s) throws Exception {
s.request(Long.MAX_VALUE);
}
});
source.subscribe(o);
assertEquals(Arrays.asList(1, 100), received);
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class SubscriberResourceWrapperTest method error.
@Test
public void error() {
BooleanSubscription bs = new BooleanSubscription();
Disposable d = Disposables.empty();
s.setResource(d);
s.onSubscribe(bs);
s.onError(new TestException());
assertTrue(d.isDisposed());
assertFalse(bs.isCancelled());
ts.assertFailure(TestException.class);
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class BlockingSubscriberTest method blockingFirstTimeout2.
@Test(timeout = 5000)
public void blockingFirstTimeout2() {
BlockingFirstSubscriber<Integer> bf = new BlockingFirstSubscriber<Integer>();
bf.onSubscribe(new BooleanSubscription());
Thread.currentThread().interrupt();
try {
bf.blockingGet();
fail("Should have thrown!");
} catch (RuntimeException ex) {
assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException);
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method reentrantOnNextOnError.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantOnNextOnError() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Subscriber[] a = { null };
final TestSubscriber ts = new TestSubscriber();
FlowableSubscriber s = new FlowableSubscriber() {
@Override
public void onSubscribe(Subscription s) {
ts.onSubscribe(s);
}
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onError(a[0], new TestException(), wip, error);
}
ts.onNext(t);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
}
@Override
public void onComplete() {
ts.onComplete();
}
};
a[0] = s;
s.onSubscribe(new BooleanSubscription());
HalfSerializer.onNext(s, 1, wip, error);
ts.assertFailure(TestException.class, 1);
}
Aggregations