@Test
public void testConstructor() throws IOException {

    int port = 8181;
    String counterName = "constructor_test_total";
    String counterHelp = "constructor_test_help";
    double counterValue = 1234.6789;
    CollectorRegistry registry = new CollectorRegistry();
    Counter counter = Counter.build().name(counterName).help(counterHelp).register(registry);
    counter.inc(counterValue);
    // new
    String expectedResponseText = String.join(
        "\n",
        String.format("# HELP %s %s", counterName, counterHelp),
        String.format("# TYPE %s %s", counterName, counter.getClass().getSimpleName().toLowerCase()),
        String.format("%s %.4f", counterName, counterValue)
    );
    PrometheusPullServer exporter = null;
    try {
        exporter = new PrometheusPullServer(port, registry);
        HttpClient client = HttpClientBuilder.create().build();
        HttpGet request = new HttpGet(String.format("http://localhost:%d/metrics", port));
        HttpResponse response = client.execute(request);
        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String responseText = rd.lines().collect(Collectors.joining("\n"));
        // assertions
        Assert.assertEquals(responseText, expectedResponseText);
    } finally {
        // cleanup
        if (exporter != null) {
            exporter.quit();
        }
    }
}