@SuppressWarnings("unchecked")
    @Test
    void testStatusAndHeadersCanBeSetAsynchronously() throws Exception {
        Map<String, List<String>> responseHeaders = new HashMap<>();
        responseHeaders.put("foo", List.of("fooValue"));
        responseHeaders.put("bar", List.of("barValue", "bazValue"));

        // Set up
        ProcessorLibrary.ListenableFutureDataSource futureDataSource = new ProcessorLibrary.ListenableFutureDataSource(true, false);
        Chain<Processor> chain = new Chain<>("main", new ProcessorLibrary.AsyncDataProcessingInitiator(new Chain<>("async", new ProcessorLibrary.StatusSetter(500), new ResponseHeaderSetter(responseHeaders))), futureDataSource);
        driver = new ProcessingTestDriver(chain);

        ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
        assertEquals(0, responseHandler.available(), "No data is available at this point");

        com.yahoo.processing.Request request = futureDataSource.incomingData.get().getOwner().request();
        futureDataSource.incomingData.get().addLast(new ProcessorLibrary.StringData(request, "d1"));
        //assertEquals("{\"datalist\":[{\"data\":\"d1\"}]}", consumeFrom(responseHandler.content));
        assertEquals("{\"errors\":[\"500: \"],\"datalist\":[{\"data\":\"d1\"}]}", responseHandler.read());

        assertEquals(500, responseHandler.getStatus());
        assertEquals("[fooValue]", responseHandler.getResponse().headers().get("foo").toString());
        assertEquals("[barValue, bazValue]", responseHandler.getResponse().headers().get("bar").toString());
        assertNull(responseHandler.read(), "Transmission completed");
    }
Tests that the ResponseStatus takes precedence over errors
container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java