File tree 2 files changed +18
-0
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ private static final class SwitchSubscriber<T> extends Subscriber<Observable<? e
62
62
volatile boolean infinite = false ;
63
63
64
64
public SwitchSubscriber (Subscriber <? super T > child ) {
65
+ super (child );
65
66
s = new SerializedSubscriber <T >(child );
66
67
ssub = new SerialSubscription ();
67
68
child .add (ssub );
Original file line number Diff line number Diff line change 15
15
*/
16
16
package rx .internal .operators ;
17
17
18
+ import static org .junit .Assert .assertTrue ;
18
19
import static org .mockito .Matchers .any ;
19
20
import static org .mockito .Matchers .anyString ;
20
21
import static org .mockito .Mockito .inOrder ;
25
26
26
27
import java .util .Arrays ;
27
28
import java .util .concurrent .TimeUnit ;
29
+ import java .util .concurrent .atomic .AtomicBoolean ;
28
30
29
31
import org .junit .Before ;
30
32
import org .junit .Test ;
@@ -513,4 +515,19 @@ public void onNext(String s) {
513
515
testSubscriber .assertNoErrors ();
514
516
testSubscriber .assertTerminalEvent ();
515
517
}
518
+
519
+ @ Test
520
+ public void testUnsubscribe () {
521
+ final AtomicBoolean isUnsubscribed = new AtomicBoolean ();
522
+ Observable .switchOnNext (
523
+ Observable .create (new Observable .OnSubscribe <Observable <Integer >>() {
524
+ @ Override
525
+ public void call (final Subscriber <? super Observable <Integer >> subscriber ) {
526
+ subscriber .onNext (Observable .just (1 ));
527
+ isUnsubscribed .set (subscriber .isUnsubscribed ());
528
+ }
529
+ })
530
+ ).take (1 ).subscribe ();
531
+ assertTrue ("Switch doesn't propagate 'unsubscribe'" , isUnsubscribed .get ());
532
+ }
516
533
}
You can’t perform that action at this time.
0 commit comments