本文整理了Java中rx.subjects.Subject.test()
方法的一些代码示例,展示了Subject.test()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.test()
方法的具体详情如下:
包路径:rx.subjects.Subject
类名称:Subject
方法名:test
暂无
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Error() {
io.reactivex.subjects.PublishSubject<Integer> ps2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(ps2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(ps2.hasObservers());
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(ps2.hasObservers());
to.assertFailure(IOException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Lifecycle() {
io.reactivex.subjects.PublishSubject<Integer> pp2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasObservers());
sj1.onNext(1);
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasObservers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
to.assertFailure(rx.exceptions.MissingBackpressureException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Normal() {
io.reactivex.subjects.PublishSubject<Integer> ps2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(ps2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(ps2.hasObservers());
sj1.onNext(1);
sj1.onNext(2);
sj1.onCompleted();
assertFalse(sj1.hasObservers());
assertFalse(ps2.hasObservers());
to.assertResult(1, 2);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Error() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.PublishProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
assertTrue(pp2.getThrowable() instanceof IOException);
to.assertFailure(IOException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Backpressured() {
io.reactivex.subjects.PublishSubject<Integer> pp2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasObservers());
sj1.onNext(1);
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasObservers());
assertFalse(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to.assertFailure(rx.exceptions.MissingBackpressureException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Normal() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.PublishProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onNext(1);
sj1.onNext(2);
sj1.onCompleted();
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to.assertResult(1, 2);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Backpressured() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.ReplayProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onNext(1);
sj1.onNext(2);
sj1.onNext(3);
sj1.onNext(4);
to.assertNoValues().assertNoErrors().assertNotCompleted();
to.requestMore(1).assertValue(1).assertNoErrors().assertNotCompleted();
to.requestMore(2).assertValues(1, 2, 3).assertNoErrors().assertNotCompleted();
sj1.onCompleted();
to.assertValues(1, 2, 3).assertNoErrors().assertNotCompleted();
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to
.requestMore(1)
.assertResult(1, 2, 3, 4);
}
代码示例来源:origin: akarnokd/akarnokd-misc
AssertableSubscriber<Integer> as = ps.test(1);
内容来源于网络,如有侵权,请联系作者删除!