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

    Observable<Integer> w = Observable.from(1, 2, 3);
    Scheduler scheduler = spy(OperatorTester.forwardingScheduler(Schedulers.immediate()));
    Observer<Integer> observer = mock(Observer.class);
    Subscription subscription = Observable.create(subscribeOn(w, scheduler)).subscribe(observer);
    verify(scheduler, times(1)).schedule(any(Action1.class));
    subscription.unsubscribe();
    verify(scheduler, times(1)).schedule(any(Action1.class));
    verifyNoMoreInteractions(scheduler);
    verify(observer, times(1)).onNext(1);
    verify(observer, times(1)).onNext(2);
    verify(observer, times(1)).onNext(3);
    verify(observer, times(1)).onCompleted();
}