SubscriberResourceWrapper extends AtomicReference<Disposable> implements FlowableSubscriber<T>, Disposable, Subscription { @Override public void cancel() { dispose(); } SubscriberResourceWrapper(Subscriber<? super T> actual); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Override void request(long n); @Override void dispose(); @Override boolean isDisposed(); @Override void cancel(); void setResource(Disposable resource);  }
@Test public void cancel() { BooleanSubscription bs = new BooleanSubscription(); Disposable d = Disposables.empty(); s.setResource(d); s.onSubscribe(bs); assertFalse(d.isDisposed()); assertFalse(s.isDisposed()); ts.cancel(); assertTrue(bs.isCancelled()); assertTrue(d.isDisposed()); assertTrue(s.isDisposed()); }