@Test
public void testNegativeRequestThrowsIllegalArgumentException() throws InterruptedException {

    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
    Observable.just(1,2,3,4).subscribe(new Subscriber<Integer>() {
        @Override
        public void onStart() {
            request(1);
        }
        
        @Override
        public void onCompleted() {
            
        }
        @Override
        public void onError(Throwable e) {
           exception.set(e);
           latch.countDown();
        }
        @Override
        public void onNext(Integer t) {
            request(-1);
            request(1);
        }});
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    assertTrue(exception.get() instanceof IllegalArgumentException);
}