15
15
*/
16
16
package rx .internal .operators ;
17
17
18
- import static org .junit .Assert .assertEquals ;
18
+ import static org .junit .Assert .* ;
19
19
import static org .mockito .Matchers .any ;
20
20
import static org .mockito .Mockito .never ;
21
21
import static org .mockito .Mockito .times ;
28
28
29
29
import rx .Observable ;
30
30
import rx .Observer ;
31
+ import rx .Subscriber ;
32
+ import rx .exceptions .OnErrorNotImplementedException ;
31
33
import rx .functions .Action1 ;
32
34
import rx .functions .Func1 ;
33
35
@@ -121,7 +123,7 @@ public void call(String s) {
121
123
@ Test
122
124
public void testIssue1451Case1 () {
123
125
// https://github.com/Netflix/RxJava/issues/1451
124
- int [] nums = {1 , 2 , 3 };
126
+ int [] nums = { 1 , 2 , 3 };
125
127
final AtomicInteger count = new AtomicInteger ();
126
128
for (final int n : nums ) {
127
129
Observable
@@ -147,7 +149,7 @@ public void call(List<Boolean> booleans) {
147
149
@ Test
148
150
public void testIssue1451Case2 () {
149
151
// https://github.com/Netflix/RxJava/issues/1451
150
- int [] nums = {1 , 2 , 3 };
152
+ int [] nums = { 1 , 2 , 3 };
151
153
final AtomicInteger count = new AtomicInteger ();
152
154
for (final int n : nums ) {
153
155
Observable
@@ -169,4 +171,34 @@ public void call(List<Boolean> booleans) {
169
171
}
170
172
assertEquals (nums .length , count .get ());
171
173
}
174
+
175
+ @ Test
176
+ public void testFatalError () {
177
+ try {
178
+ Observable .just (1 , 2 , 3 )
179
+ .flatMap (new Func1 <Integer , Observable <?>>() {
180
+ @ Override
181
+ public Observable <?> call (Integer integer ) {
182
+ return Observable .create (new Observable .OnSubscribe <Object >() {
183
+ @ Override
184
+ public void call (Subscriber <Object > o ) {
185
+ throw new NullPointerException ("Test NPE" );
186
+ }
187
+ });
188
+ }
189
+ })
190
+ .doOnNext (new Action1 <Object >() {
191
+ @ Override
192
+ public void call (Object o ) {
193
+ System .out .println ("Won't come here" );
194
+ }
195
+ })
196
+ .subscribe ();
197
+ fail ("should have thrown an exception" );
198
+ } catch (OnErrorNotImplementedException e ) {
199
+ assertTrue (e .getCause () instanceof NullPointerException );
200
+ assertEquals (e .getCause ().getMessage (), "Test NPE" );
201
+ System .out .println ("Received exception: " + e );
202
+ }
203
+ }
172
204
}
0 commit comments