Esempio n. 1
0
 /**
  * https://github.com/ReactiveX/RxJava/issues/198
  *
  * <p>Rx Design Guidelines 5.2
  *
  * <p>"when calling the Subscribe method that only has an onNext argument, the OnError behavior
  * will be to rethrow the exception on the thread that the message comes out from the Observable.
  * The OnCompleted behavior in this case is to do nothing."
  *
  * @throws InterruptedException
  */
 @Test
 @Ignore("Subscribers can't throw")
 public void testErrorThrownWithoutErrorHandlerAsynchronous() throws InterruptedException {
   final CountDownLatch latch = new CountDownLatch(1);
   final AtomicReference<Throwable> exception = new AtomicReference<>();
   Observable.create(
           observer -> {
             new Thread(
                     () -> {
                       try {
                         observer.onError(new Error("failure"));
                       } catch (Throwable e) {
                         // without an onError handler it has to just throw on whatever thread
                         // invokes it
                         exception.set(e);
                       }
                       latch.countDown();
                     })
                 .start();
           })
       .subscribe();
   // wait for exception
   latch.await(3000, TimeUnit.MILLISECONDS);
   assertNotNull(exception.get());
   assertEquals("failure", exception.get().getMessage());
 }