### Question:
CompositeCancellable implements Cancellable { @Override public void cancel() { if (cancelledUpdater.compareAndSet(this, 0, 1)) { Throwable t = null; for (Cancellable other : others) { try { if (other != null) { other.cancel(); } } catch (Throwable tt) { if (t == null) { t = tt; } else { t.addSuppressed(tt); } } } if (t != null) { throwException(t); } } } private  CompositeCancellable(Cancellable... others); @Override void cancel();  }### Answer:
@Test public void testOne() { Cancellable composite = holder.init(1); assertThat("Composite of 1 must not create a new instance.", composite, is(holder.components[0])); composite.cancel(); }
@Test public void testTwo() { holder.init(2).cancel(); }
@Test public void testMany() { holder.init(5).cancel(); }
@Test public void cancellablesMayContainNull() { Cancellable cancellable = holder.init(5); holder.components[3] = null; cancellable.cancel(); holder.verify(); }