@Test
public void testBufferStopsWhenUnsubscribed1() {

    Observable<Integer> source = Observable.never();
    Observer<List<Integer>> o = mock(Observer.class);
    Subscription s = source.buffer(100, 200, TimeUnit.MILLISECONDS, scheduler).subscribe(o);
    InOrder inOrder = Mockito.inOrder(o);
    scheduler.advanceTimeBy(1001, TimeUnit.MILLISECONDS);
    inOrder.verify(o, times(5)).onNext(Arrays.<Integer> asList());
    s.unsubscribe();
    scheduler.advanceTimeBy(999, TimeUnit.MILLISECONDS);
    inOrder.verifyNoMoreInteractions();
}