|
29 | 29 | import rx.*;
|
30 | 30 | import rx.Observable;
|
31 | 31 | import rx.Observer;
|
| 32 | +import rx.exceptions.*; |
32 | 33 | import rx.functions.*;
|
33 | 34 | import rx.internal.util.RxRingBuffer;
|
34 | 35 | import rx.observers.TestSubscriber;
|
@@ -954,5 +955,107 @@ public Integer call(Object... args) {
|
954 | 955 | throw new RuntimeException();
|
955 | 956 | }
|
956 | 957 |
|
957 |
| - }; |
| 958 | + }; |
| 959 | + |
| 960 | + @SuppressWarnings("unchecked") |
| 961 | + @Test |
| 962 | + public void firstJustError() { |
| 963 | + TestSubscriber<Integer> ts = TestSubscriber.create(); |
| 964 | + |
| 965 | + Observable.combineLatestDelayError( |
| 966 | + Arrays.asList(Observable.just(1), Observable.<Integer>error(new TestException())), |
| 967 | + new FuncN<Integer>() { |
| 968 | + @Override |
| 969 | + public Integer call(Object... args) { |
| 970 | + return ((Integer)args[0]) + ((Integer)args[1]); |
| 971 | + } |
| 972 | + } |
| 973 | + ).subscribe(ts); |
| 974 | + |
| 975 | + ts.assertNoValues(); |
| 976 | + ts.assertError(TestException.class); |
| 977 | + ts.assertNotCompleted(); |
| 978 | + } |
| 979 | + |
| 980 | + @SuppressWarnings("unchecked") |
| 981 | + @Test |
| 982 | + public void secondJustError() { |
| 983 | + TestSubscriber<Integer> ts = TestSubscriber.create(); |
| 984 | + |
| 985 | + Observable.combineLatestDelayError( |
| 986 | + Arrays.asList(Observable.<Integer>error(new TestException()), Observable.just(1)), |
| 987 | + new FuncN<Integer>() { |
| 988 | + @Override |
| 989 | + public Integer call(Object... args) { |
| 990 | + return ((Integer)args[0]) + ((Integer)args[1]); |
| 991 | + } |
| 992 | + } |
| 993 | + ).subscribe(ts); |
| 994 | + |
| 995 | + ts.assertNoValues(); |
| 996 | + ts.assertError(TestException.class); |
| 997 | + ts.assertNotCompleted(); |
| 998 | + } |
| 999 | + |
| 1000 | + @SuppressWarnings("unchecked") |
| 1001 | + @Test |
| 1002 | + public void oneErrors() { |
| 1003 | + TestSubscriber<Integer> ts = TestSubscriber.create(); |
| 1004 | + |
| 1005 | + Observable.combineLatestDelayError( |
| 1006 | + Arrays.asList(Observable.just(10).concatWith(Observable.<Integer>error(new TestException())), Observable.just(1)), |
| 1007 | + new FuncN<Integer>() { |
| 1008 | + @Override |
| 1009 | + public Integer call(Object... args) { |
| 1010 | + return ((Integer)args[0]) + ((Integer)args[1]); |
| 1011 | + } |
| 1012 | + } |
| 1013 | + ).subscribe(ts); |
| 1014 | + |
| 1015 | + ts.assertValues(11); |
| 1016 | + ts.assertError(TestException.class); |
| 1017 | + ts.assertNotCompleted(); |
| 1018 | + } |
| 1019 | + |
| 1020 | + @SuppressWarnings("unchecked") |
| 1021 | + @Test |
| 1022 | + public void twoErrors() { |
| 1023 | + TestSubscriber<Integer> ts = TestSubscriber.create(); |
| 1024 | + |
| 1025 | + Observable.combineLatestDelayError( |
| 1026 | + Arrays.asList(Observable.just(1), Observable.just(10).concatWith(Observable.<Integer>error(new TestException()))), |
| 1027 | + new FuncN<Integer>() { |
| 1028 | + @Override |
| 1029 | + public Integer call(Object... args) { |
| 1030 | + return ((Integer)args[0]) + ((Integer)args[1]); |
| 1031 | + } |
| 1032 | + } |
| 1033 | + ).subscribe(ts); |
| 1034 | + |
| 1035 | + ts.assertValues(11); |
| 1036 | + ts.assertError(TestException.class); |
| 1037 | + ts.assertNotCompleted(); |
| 1038 | + } |
| 1039 | + |
| 1040 | + @SuppressWarnings("unchecked") |
| 1041 | + @Test |
| 1042 | + public void bothError() { |
| 1043 | + TestSubscriber<Integer> ts = TestSubscriber.create(); |
| 1044 | + |
| 1045 | + Observable.combineLatestDelayError( |
| 1046 | + Arrays.asList(Observable.just(1).concatWith(Observable.<Integer>error(new TestException())), |
| 1047 | + Observable.just(10).concatWith(Observable.<Integer>error(new TestException()))), |
| 1048 | + new FuncN<Integer>() { |
| 1049 | + @Override |
| 1050 | + public Integer call(Object... args) { |
| 1051 | + return ((Integer)args[0]) + ((Integer)args[1]); |
| 1052 | + } |
| 1053 | + } |
| 1054 | + ).subscribe(ts); |
| 1055 | + |
| 1056 | + ts.assertValues(11); |
| 1057 | + ts.assertError(CompositeException.class); |
| 1058 | + ts.assertNotCompleted(); |
| 1059 | + } |
| 1060 | + |
958 | 1061 | }
|
0 commit comments