@Test
public void testNestedTrampolineWithUnsubscribe() {

    final ArrayList<String> workDone = new ArrayList<String>();
    final CompositeSubscription workers = new CompositeSubscription();
    Worker worker = Schedulers.trampoline().createWorker();
    try {
        workers.add(worker);
        worker.schedule(new Action0() {

            @Override
            public void call() {
                workers.add(doWorkOnNewTrampoline("A", workDone));
            }

        });

        final Worker worker2 = Schedulers.trampoline().createWorker();
        workers.add(worker2);
        worker2.schedule(new Action0() {

            @Override
            public void call() {
                workers.add(doWorkOnNewTrampoline("B", workDone));
                // we unsubscribe worker2 ... it should not affect work scheduled on a separate Trampline.Worker
                worker2.unsubscribe();
            }

        });
    
        assertEquals(6, workDone.size());
        assertEquals(Arrays.asList("A.1", "A.B.1", "A.B.2", "B.1", "B.B.1", "B.B.2"), workDone);
    } finally {
        workers.unsubscribe();
    }
}