diff --git a/simpleclient_httpserver/src/test/java/io/prometheus/client/exporter/TestHTTPServer.java b/simpleclient_httpserver/src/test/java/io/prometheus/client/exporter/TestHTTPServer.java index 1a49b0f95..3b5040d6c 100644 --- a/simpleclient_httpserver/src/test/java/io/prometheus/client/exporter/TestHTTPServer.java +++ b/simpleclient_httpserver/src/test/java/io/prometheus/client/exporter/TestHTTPServer.java @@ -65,15 +65,11 @@ String requestWithCompression(String context, String suffix) throws IOException return s.hasNext() ? s.next() : ""; } - @Test - public void testUnbound() throws IOException { + @Test(expected = IllegalArgumentException.class) + public void testRefuseUsingUnbound() throws IOException { CollectorRegistry registry = new CollectorRegistry(); - try { - HTTPServer s = new HTTPServer(HttpServer.create(), registry, true); - s.stop(); - fail("Should refuse to use an unbound HttpServer"); - } catch (IllegalArgumentException expected) { - } + HTTPServer s = new HTTPServer(HttpServer.create(), registry, true); + s.stop(); } @Test