@Test
public void publishCancelOneAsync() {

    for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
        final PublishProcessor<Integer> pp = PublishProcessor.create();
        final AtomicReference<Flowable<Integer>> ref = new AtomicReference<Flowable<Integer>>();
        pp.publish(new Function<Flowable<Integer>, Publisher<Integer>>() {
            @Override
            public Publisher<Integer> apply(Flowable<Integer> f) throws Exception {
                ref.set(f);
                return Flowable.never();
            }
        }).test();
        final TestSubscriber<Integer> ts1 = ref.get().test();
        TestSubscriber<Integer> ts2 = ref.get().test();
        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                pp.onNext(1);
            }
        };
        Runnable r2 = new Runnable() {
            @Override
            public void run() {
                ts1.cancel();
            }
        };
        TestHelper.race(r1, r2);
        ts2.assertValuesOnly(1);
    }
}