15
15
*/
16
16
package rx .internal .operators ;
17
17
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
-
32
18
import org .junit .Before ;
33
19
import org .junit .Test ;
34
20
import org .mockito .InOrder ;
35
21
import org .mockito .Mock ;
36
22
import org .mockito .MockitoAnnotations ;
37
-
38
23
import rx .Observable ;
39
24
import rx .Observable .OnSubscribe ;
40
25
import rx .Observer ;
41
26
import rx .Subscriber ;
42
27
import rx .exceptions .CompositeException ;
43
28
import rx .exceptions .TestException ;
44
29
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
+
45
39
public class OperatorMergeDelayErrorTest {
46
40
47
41
@ Mock
@@ -52,6 +46,36 @@ public void before() {
52
46
MockitoAnnotations .initMocks (this );
53
47
}
54
48
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
+
55
79
@ Test
56
80
public void testErrorDelayed1 () {
57
81
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