@Test
    void testWaitForAll() {
        Chain<Searcher> slowChain = new Chain<>(
                new ComponentId("slow"),
                List.of(new Searcher[]{new WaitingSearcher("slow", 30000)}
                )
        );

        Chain<Searcher> fastChain = new Chain<>(
                new ComponentId("fast"),
                List.of(new Searcher[]{new SimpleSearcher()})
        );

        FutureResult slowFuture = new AsyncExecution(slowChain, Execution.Context.createContextStub()).search(new Query("?hits=0"));
        FutureResult fastFuture = new AsyncExecution(fastChain, Execution.Context.createContextStub()).search(new Query("?hits=0"));
        fastFuture.get();
        FutureResult [] reslist = new FutureResult[]{slowFuture, fastFuture};
        List<Result> results = AsyncExecution.waitForAll(List.of(reslist), 0);

        //assertTrue(slowFuture.isCancelled());
        assertTrue(fastFuture.isDone() && !fastFuture.isCancelled());

        assertNotNull(results.get(0).hits().getErrorHit());
        assertNull(results.get(1).hits().getErrorHit());
    }
Test for aynchrounous execution

@author Arne Bergene Fossaa
container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java