@Test
public void testTimed() {

    Observable<String> source = Observable.create(new Observable.OnSubscribeFunc<String>() {
        @Override
        public Subscription onSubscribe(Observer<? super String> observer) {
            push(observer, "one", 98);
            push(observer, "two", 99);
            push(observer, "three", 100);
            push(observer, "four", 101);
            push(observer, "five", 102);
            complete(observer, 150);
            return Subscriptions.empty();
        }
    });
    Observable<List<String>> buffered = Observable.create(buffer(source, 100, TimeUnit.MILLISECONDS, scheduler));
    buffered.subscribe(observer);
    InOrder inOrder = Mockito.inOrder(observer);
    scheduler.advanceTimeTo(101, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, Mockito.times(1)).onNext(list("one", "two", "three"));
    scheduler.advanceTimeTo(201, TimeUnit.MILLISECONDS);
    inOrder.verify(observer, Mockito.times(1)).onNext(list("four", "five"));
    inOrder.verify(observer, Mockito.never()).onNext(Mockito.anyListOf(String.class));
    inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
    inOrder.verify(observer, Mockito.times(1)).onCompleted();
}