File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 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
6262 volatile boolean infinite = false ;
6363
6464 public SwitchSubscriber (Subscriber <? super T > child ) {
65+ super (child );
6566 s = new SerializedSubscriber <T >(child );
6667 ssub = new SerialSubscription ();
6768 child .add (ssub );
Original file line number Diff line number Diff line change 1515 */
1616package rx .internal .operators ;
1717
18+ import static org .junit .Assert .assertTrue ;
1819import static org .mockito .Matchers .any ;
1920import static org .mockito .Matchers .anyString ;
2021import static org .mockito .Mockito .inOrder ;
2526
2627import java .util .Arrays ;
2728import java .util .concurrent .TimeUnit ;
29+ import java .util .concurrent .atomic .AtomicBoolean ;
2830
2931import org .junit .Before ;
3032import org .junit .Test ;
@@ -513,4 +515,19 @@ public void onNext(String s) {
513515 testSubscriber .assertNoErrors ();
514516 testSubscriber .assertTerminalEvent ();
515517 }
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+ }
516533}
You can’t perform that action at this time.
0 commit comments