@Test
public void testProducerRequestThroughAmb() {

    TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
    ts.requestMore(3);
    final AtomicLong requested1 = new AtomicLong();
    final AtomicLong requested2 = new AtomicLong();
    Observable<Integer> o1 = Observable.create(new OnSubscribe<Integer>() {
        @Override
        public void call(Subscriber<? super Integer> s) {
            s.setProducer(new Producer() {
                @Override
                public void request(long n) {
                    System.out.println("1-requested: " + n);
                    requested1.set(n);
                }
            });
        }
    });
    Observable<Integer> o2 = Observable.create(new OnSubscribe<Integer>() {
        @Override
        public void call(Subscriber<? super Integer> s) {
            s.setProducer(new Producer() {
                @Override
                public void request(long n) {
                    System.out.println("2-requested: " + n);
                    requested2.set(n);
                }
            });
        }
    });
    Observable.amb(o1, o2).subscribe(ts);
    assertEquals(3, requested1.get());
    assertEquals(3, requested2.get());
}