FutureSubscriber extends CountDownLatch implements FlowableSubscriber<T>, Future<T>, Subscription { @Override public void onSubscribe(Subscription s) { SubscriptionHelper.setOnce(this.s, s, Long.MAX_VALUE); } FutureSubscriber(); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override T get(); @Override T get(long timeout, TimeUnit unit); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Override void cancel(); @Override void request(long n);  }
@Test public void onSubscribe() throws Exception { List<Throwable> errors = TestHelper.trackPluginErrors(); try { BooleanSubscription s = new BooleanSubscription(); fs.onSubscribe(s); BooleanSubscription s2 = new BooleanSubscription(); fs.onSubscribe(s2); assertFalse(s.isCancelled()); assertTrue(s2.isCancelled()); TestHelper.assertError(errors, 0, IllegalStateException.class, "Subscription already set!"); } finally { RxJavaPlugins.reset(); } }