@SuppressWarnings("unchecked")
    @Test
    void testProcessingHandlerSupportsAsyncRendering() {
        // Set up
        ProcessorLibrary.FutureDataSource futureDataSource = new ProcessorLibrary.FutureDataSource();
        Chain<Processor> asyncCompletionChain = new Chain<>("asyncCompletion", new ProcessorLibrary.DataCounter("async"));
        Chain<Processor> chain =
                new Chain<>("federation", new ProcessorLibrary.DataCounter("sync"),
                        new ProcessorLibrary.Federator(new Chain<Processor>(new ProcessorLibrary.DataSource()),
                                new Chain<>(new ProcessorLibrary.AsyncDataProcessingInitiator(asyncCompletionChain), futureDataSource)));
        List<Chain<Processor>> chains = new ArrayList<>();
        chains.add(chain);
        driver = new ProcessingTestDriver(chains);

        ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=federation");
        String synchronousResponse = responseHandler.read();
        assertEquals(
                "{\"datalist\":[" +
                        "{\"datalist\":[" +
                        "{\"data\":\"first.null\"}," +
                        "{\"data\":\"second.null\"}," +
                        "{\"data\":\"third.null\"}" +
                        "]}",
                synchronousResponse);
        assertEquals(0, responseHandler.available(), "No more data is available at this point");

        // Now, complete async data
        futureDataSource.incomingData.get(0).add(new ProcessorLibrary.StringData(null, "d1"));
        assertEquals(
                "," +
                        "{\"datalist\":[" +
                        "{\"data\":\"d1\"}",
                responseHandler.read());
        futureDataSource.incomingData.get(0).addLast(new ProcessorLibrary.StringData(null, "d2"));

        // ... which leads to the rest of the response becoming available
        assertEquals(
                "," +
                        "{\"data\":\"d2\"}," +
                        "{\"data\":\"[async] Data count: 2\"}" +
                        "]}",
                responseHandler.read());
        assertEquals(",{\"data\":\"[sync] Data count: 3\"}" + // Async items not counted as they arrive after chain completion
                "]}",
                responseHandler.read());
        assertNull(responseHandler.read(), "Transmission completed");
    }
Tests that the ResponseStatus takes precedence over errors
container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java