コード例 #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!");
 }
コード例 #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!");
 }
コード例 #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
    }
  }
コード例 #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!");
 }
コード例 #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());
      }
    }
  }
コード例 #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();
  }