@Test
@SuppressWarnings("unchecked")
public void testTakeUntilOtherCompleted() {

    Subscription sSource = mock(Subscription.class);
    Subscription sOther = mock(Subscription.class);
    TestObservable source = new TestObservable(sSource);
    TestObservable other = new TestObservable(sOther);
    Observer<String> result = mock(Observer.class);
    Observable<String> stringObservable = takeUntil(Observable.create(source), Observable.create(other));
    stringObservable.subscribe(result);
    source.sendOnNext("one");
    source.sendOnNext("two");
    other.sendOnCompleted();
    source.sendOnNext("three");
    verify(result, times(1)).onNext("one");
    verify(result, times(1)).onNext("two");
    verify(result, times(0)).onNext("three");
    verify(result, times(1)).onCompleted();
    verify(sSource, times(1)).unsubscribe();
    verify(sOther, times(1)).unsubscribe(); // unsubscribed since SafeSubscriber unsubscribes after onComplete
}