@Test
public void testInfiniteTake() {

    int count = 100;
    AbstractOnSubscribe<Integer, Void> aos = new AbstractOnSubscribe<Integer, Void>() {
        @Override
        protected void next(SubscriptionState<Integer, Void> state) {
            state.onNext((int)state.calls());
        }
    };
    
    @SuppressWarnings("unchecked")
    Observer<Object> o = mock(Observer.class);
    InOrder inOrder = inOrder(o);
    
    aos.toObservable().take(count).subscribe(o);
    
    verify(o, never()).onError(any(Throwable.class));
    for (int i = 0; i < 100; i++) {
        inOrder.verify(o).onNext(i);
    }
    inOrder.verify(o).onCompleted();
    inOrder.verifyNoMoreInteractions();
}