1515 */
1616package rx .internal .operators ;
1717
18- import static org .junit .Assert .assertEquals ;
19- import static org .junit .Assert .assertNotNull ;
20- import static org .junit .Assert .fail ;
21- import static org .mockito .Matchers .any ;
22- import static org .mockito .Matchers .anyInt ;
23- import static org .mockito .Mockito .inOrder ;
24- import static org .mockito .Mockito .mock ;
25- import static org .mockito .Mockito .never ;
26- import static org .mockito .Mockito .times ;
27- import static org .mockito .Mockito .verify ;
28-
29- import java .util .ArrayList ;
30- import java .util .List ;
31-
3218import org .junit .Before ;
3319import org .junit .Test ;
3420import org .mockito .InOrder ;
3521import org .mockito .Mock ;
3622import org .mockito .MockitoAnnotations ;
37-
3823import rx .Observable ;
3924import rx .Observable .OnSubscribe ;
4025import rx .Observer ;
4126import rx .Subscriber ;
4227import rx .exceptions .CompositeException ;
4328import rx .exceptions .TestException ;
4429
30+ import java .util .ArrayList ;
31+ import java .util .List ;
32+ import java .util .concurrent .CountDownLatch ;
33+
34+ import static org .junit .Assert .*;
35+ import static org .mockito .Matchers .any ;
36+ import static org .mockito .Matchers .anyInt ;
37+ import static org .mockito .Mockito .*;
38+
4539public class OperatorMergeDelayErrorTest {
4640
4741 @ Mock
@@ -52,6 +46,36 @@ public void before() {
5246 MockitoAnnotations .initMocks (this );
5347 }
5448
49+ @ Test (timeout =1000L )
50+ public void testSynchronousError () {
51+ final Observable <Observable <String >> o1 = Observable .error (new RuntimeException ("unit test" ));
52+
53+ final CountDownLatch latch = new CountDownLatch (1 );
54+ Observable .mergeDelayError (o1 ).subscribe (new Subscriber <String >() {
55+ @ Override
56+ public void onCompleted () {
57+ fail ("Expected onError path" );
58+ }
59+
60+ @ Override
61+ public void onError (Throwable e ) {
62+ latch .countDown ();
63+ }
64+
65+ @ Override
66+ public void onNext (String s ) {
67+ fail ("Expected onError path" );
68+ }
69+ });
70+
71+ try {
72+ latch .await ();
73+ } catch (InterruptedException ex ) {
74+ fail ("interrupted" );
75+ }
76+ }
77+
78+
5579 @ Test
5680 public void testErrorDelayed1 () {
5781 final Observable <String > o1 = Observable .create (new TestErrorObservable ("four" , null , "six" )); // we expect to lose "six" from the source (and it should never be sent by the source since onError was called
0 commit comments