@Test
  public void testOnFailureThenCancel() {
    mMultiplexProducer.produceResults(mConsumer1, mProducerContext1);
    mForwardingConsumer1.onFailure(mException);
    assertTrue(mMultiplexProducer.mMultiplexers.isEmpty());

    mMultiplexProducer.produceResults(mConsumer2, mProducerContext2);
    assertTrue(mMultiplexProducer.mMultiplexers.size() == 1);
    mProducerContext1.cancel();
    mForwardingConsumer1.onCancellation();
    assertTrue(mMultiplexProducer.mMultiplexers.size() == 1);
  }
An extra flag to check we maintain other flags than just whether this is the last result
imagepipeline/src/test/java/com/facebook/imagepipeline/producers/MultiplexProducerTest.java