@Test(timeout = 3000)
public void testSubscribeOn() {

    final int start = 1;
    final int count = 100;
    AbstractOnSubscribe<Integer, Void> aos = new AbstractOnSubscribe<Integer, Void>() {
        @Override
        protected void next(SubscriptionState<Integer, Void> state) {
            long calls = state.calls();
            if (calls <= count) {
                state.onNext((int)calls + start);
                if (calls == count) {
                    state.onCompleted();
                }
            }
        }
    };
    @SuppressWarnings("unchecked")
    Observer<Object> o = mock(Observer.class);
    InOrder inOrder = inOrder(o);
    TestSubscriber<Object> ts = new TestSubscriber<Object>(o);
    aos.toObservable().subscribeOn(Schedulers.newThread()).subscribe(ts);
    
    ts.awaitTerminalEvent();
    
    verify(o, never()).onError(any(Throwable.class));
    for (int i = 1; i <= count; i++) {
        inOrder.verify(o).onNext(i);
    }
    inOrder.verify(o).onCompleted();
    inOrder.verifyNoMoreInteractions();
}