@Test
 public void testDelegate3() {
   TestSubscriber<Integer> ts1 = TestSubscriber.create();
   TestSubscriber<Integer> ts2 = TestSubscriber.create(ts1, 0);
   ts2.onCompleted();
   ts1.assertCompleted();
 }
  @Test
  public void testDelegate1() {
    TestObserver<Integer> to = new TestObserver<Integer>();
    TestSubscriber<Integer> ts = TestSubscriber.create(to);
    ts.onCompleted();

    to.assertTerminalEvent();
  }
 @Test
 public void testCompleted() {
   TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
   ts.onCompleted();
   try {
     ts.assertNotCompleted();
   } catch (AssertionError ex) {
     // expected
     return;
   }
   fail("Completed and no assertion error!");
 }
  @Test
  public void testNoTerminalEventBut1Completed() {
    TestSubscriber<Integer> ts = TestSubscriber.create();

    ts.onCompleted();

    try {
      ts.assertNoTerminalEvent();
      fail("Failed to report there were terminal event(s)!");
    } catch (AssertionError ex) {
      // expected
    }
  }
  @Test(timeout = 1000)
  public void testOnCompletedCrashCountsDownLatch() {
    TestObserver<Integer> to =
        new TestObserver<Integer>() {
          @Override
          public void onCompleted() {
            throw new TestException();
          }
        };
    TestSubscriber<Integer> ts = TestSubscriber.create(to);

    try {
      ts.onCompleted();
    } catch (TestException ex) {
      // expected
    }

    ts.awaitTerminalEvent();
  }
 @Test(expected = NullPointerException.class)
 public void testNullDelegate3() {
   TestSubscriber<Integer> ts = new TestSubscriber<Integer>((Subscriber<Integer>) null, 0);
   ts.onCompleted();
 }