@Test
    void requireThatResponseStatsAreCollected() throws Exception {
        RequestTypeHandler handler = new RequestTypeHandler();
        var cfg = new ServerConfig.Builder().metric(new ServerConfig.Metric.Builder().reporterEnabled(false));
        JettyTestDriver driver = JettyTestDriver.newConfiguredInstance(handler, cfg, new ConnectorConfig.Builder());
        var statisticsCollector = MetricAggregatingRequestLog.getBean(driver.server());;
        {
            List<MetricAggregatingRequestLog.StatisticsEntry> stats = statisticsCollector.takeStatistics();
            assertEquals(0, stats.size());
        }

        {
            driver.client().newPost("/status.html").execute();
            var entry = waitForStatistics(statisticsCollector);
            assertEquals("http", entry.dimensions.scheme);
            assertEquals("POST", entry.dimensions.method);
            assertEquals("http.status.2xx", entry.name);
            assertEquals("write", entry.dimensions.requestType);
            assertEquals(1, entry.value);
        }

        {
            driver.client().newGet("/status.html").execute();
            var entry = waitForStatistics(statisticsCollector);
            assertEquals("http", entry.dimensions.scheme);
            assertEquals("GET", entry.dimensions.method);
            assertEquals("http.status.2xx", entry.name);
            assertEquals("read", entry.dimensions.requestType);
            assertEquals(1, entry.value);
        }

        {
            handler.setRequestType(Request.RequestType.READ);
            driver.client().newPost("/status.html").execute();
            var entry = waitForStatistics(statisticsCollector);
            assertEquals("read", entry.dimensions.requestType, "Handler overrides request type");
        }

        assertTrue(driver.close());
    }
@author Oyvind Bakksjo
@author Simon Thoresen Hult
@author bjorncs
container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java