use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableReplayTest method testTimedAndSizedTruncationError.
@Test
public void testTimedAndSizedTruncationError() {
TestScheduler test = new TestScheduler();
SizeAndTimeBoundReplayBuffer<Integer> buf = new SizeAndTimeBoundReplayBuffer<Integer>(2, 2000, TimeUnit.MILLISECONDS, test);
Assert.assertFalse(buf.hasCompleted());
Assert.assertFalse(buf.hasError());
List<Integer> values = new ArrayList<Integer>();
buf.next(1);
test.advanceTimeBy(1, TimeUnit.SECONDS);
buf.next(2);
test.advanceTimeBy(1, TimeUnit.SECONDS);
buf.collect(values);
Assert.assertEquals(Arrays.asList(2), values);
buf.next(3);
buf.next(4);
values.clear();
buf.collect(values);
Assert.assertEquals(Arrays.asList(3, 4), values);
test.advanceTimeBy(2, TimeUnit.SECONDS);
buf.next(5);
values.clear();
buf.collect(values);
Assert.assertEquals(Arrays.asList(5), values);
Assert.assertFalse(buf.hasCompleted());
Assert.assertFalse(buf.hasError());
test.advanceTimeBy(2, TimeUnit.SECONDS);
buf.error(new TestException());
values.clear();
buf.collect(values);
Assert.assertTrue(values.isEmpty());
Assert.assertEquals(1, buf.size);
Assert.assertFalse(buf.hasCompleted());
Assert.assertTrue(buf.hasError());
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableReplayTest method connectConsumerThrows.
@Test
public void connectConsumerThrows() {
ConnectableFlowable<Integer> co = Flowable.range(1, 2).replay();
try {
co.connect(new Consumer<Disposable>() {
@Override
public void accept(Disposable t) throws Exception {
throw new TestException();
}
});
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
co.test().assertEmpty().cancel();
co.connect();
co.test().assertResult(1, 2);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableGroupByTest method errorFused.
@Test
public void errorFused() {
TestSubscriber<Object> ts = SubscriberFusion.newTest(QueueSubscription.ANY);
Flowable.error(new TestException()).groupBy(Functions.justFunction(1)).subscribe(ts);
SubscriberFusion.assertFusion(ts, QueueSubscription.ASYNC).assertFailure(TestException.class);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableGroupByTest method errorFusedDelayed.
@Test
public void errorFusedDelayed() {
TestSubscriber<Object> ts = SubscriberFusion.newTest(QueueSubscription.ANY);
Flowable.error(new TestException()).groupBy(Functions.justFunction(1), true).subscribe(ts);
SubscriberFusion.assertFusion(ts, QueueSubscription.ASYNC).assertFailure(TestException.class);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableIgnoreElementsTest method testErrorReceived.
@Test
public void testErrorReceived() {
TestObserver<Object> ts = new TestObserver<Object>();
TestException ex = new TestException("boo");
Flowable.error(ex).ignoreElements().subscribe(ts);
ts.assertNoValues();
ts.assertTerminated();
// FIXME no longer testable
// ts.assertUnsubscribed();
ts.assertError(TestException.class);
ts.assertErrorMessage("boo");
}
Aggregations