public void replaceCollector(Collector collector) {
        final CollectorRegistry newRegistry = newCollectorRegistry();
        newRegistry.register(collector);

        DefaultExports.register(newRegistry);
        registryRef.set(newRegistry);
    }
@Test
    void runWithPopulatedCollector() throws Exception {
        final MetricRegistry metricRegistry = new MetricRegistry();
        final Counter counter = metricRegistry.counter("counter");

        counter.inc();

        server.replaceCollector(new DropwizardExports(metricRegistry));

        doGET(server, "/metrics", response -> {
            assertThat(response.body()).isNotNull();
            assertThat(response.body().string()).contains("counter 1.0");
        });
        doGET(server, "/", response -> {
            assertThat(response.body()).isNotNull();
            assertThat(response.body().string()).contains("counter 1.0");
        });
        doGET(server, "/-/healthy", response -> {
            assertThat(response.body()).isNotNull();
            assertThat(response.body().string()).containsIgnoringCase("exporter is healthy");
        });
    }