FutureObserver extends CountDownLatch implements Observer<T>, Future<T>, Disposable { @Override public void onSubscribe(Disposable s) { DisposableHelper.setOnce(this.s, s); } FutureObserver(); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override T get(); @Override T get(long timeout, TimeUnit unit); @Override void onSubscribe(Disposable s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Override void dispose(); @Override boolean isDisposed();  }
@Test public void onSubscribe() throws Exception { List<Throwable> errors = TestHelper.trackPluginErrors(); try { Disposable s = Disposables.empty(); fo.onSubscribe(s); Disposable s2 = Disposables.empty(); fo.onSubscribe(s2); assertFalse(s.isDisposed()); assertTrue(s2.isDisposed()); TestHelper.assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } finally { RxJavaPlugins.reset(); } }