@Test
public void testTakeWhileOnSubject1() {

    Subject<Integer, Integer> s = PublishSubject.create();
    Observable<Integer> take = Observable.create(takeWhile(s, new Func1<Integer, Boolean>() {
        @Override
        public Boolean call(Integer input) {
            return input < 3;
        }
    }));
    @SuppressWarnings("unchecked")
    Observer<Integer> observer = mock(Observer.class);
    take.subscribe(observer);
    s.onNext(1);
    s.onNext(2);
    s.onNext(3);
    s.onNext(4);
    s.onNext(5);
    s.onCompleted();
    verify(observer, times(1)).onNext(1);
    verify(observer, times(1)).onNext(2);
    verify(observer, never()).onNext(3);
    verify(observer, never()).onNext(4);
    verify(observer, never()).onNext(5);
    verify(observer, never()).onError(any(Throwable.class));
    verify(observer, times(1)).onCompleted();
}