Esempio n. 1
0
 @Test
 public void testDifferentError3() {
   TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
   ts.onError(new RuntimeException());
   try {
     ts.assertError(TestException.class);
   } catch (AssertionError ex) {
     // expected
     return;
   }
   fail("Different Error present but no assertion error!");
 }
Esempio n. 2
0
 @Test
 public void testNoErrors() {
   TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
   ts.onError(new TestException());
   try {
     ts.assertNoErrors();
   } catch (AssertionError ex) {
     // expected
     return;
   }
   fail("Error present but no assertion error!");
 }
Esempio n. 3
0
  @Test
  public void testNoTerminalEventBut1Error() {
    TestSubscriber<Integer> ts = TestSubscriber.create();

    ts.onError(new TestException());

    try {
      ts.assertNoTerminalEvent();
      fail("Failed to report there were terminal event(s)!");
    } catch (AssertionError ex) {
      // expected
    }
  }
Esempio n. 4
0
 @Test
 public void testMultipleErrors3() {
   TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
   ts.onError(new TestException());
   ts.onError(new TestException());
   try {
     ts.assertError(new TestException());
   } catch (AssertionError ex) {
     if (!(ex.getCause() instanceof CompositeException)) {
       fail("Multiple Error present but the reported error doesn't have a composite cause!");
     }
     // expected
     return;
   }
   fail("Multiple Error present but no assertion error!");
 }
Esempio n. 5
0
  @Test
  public void testNoTerminalEventBut2Errors() {
    TestSubscriber<Integer> ts = TestSubscriber.create();

    ts.onError(new TestException());
    ts.onError(new TestException());

    try {
      ts.assertNoTerminalEvent();
      fail("Failed to report there were terminal event(s)!");
    } catch (AssertionError ex) {
      // expected
      if (!(ex.getCause() instanceof CompositeException)) {
        fail("Did not report a composite exception cause: " + ex.getCause());
      }
    }
  }
Esempio n. 6
0
  @Test(timeout = 1000)
  public void testOnErrorCrashCountsDownLatch() {
    TestObserver<Integer> to =
        new TestObserver<Integer>() {
          @Override
          public void onError(Throwable e) {
            throw new TestException();
          }
        };
    TestSubscriber<Integer> ts = TestSubscriber.create(to);

    try {
      ts.onError(new RuntimeException());
    } catch (TestException ex) {
      // expected
    }

    ts.awaitTerminalEvent();
  }