Skip to content

Commit 2db8c65

Browse files
committed
set test java to 25, remove deprecated usage
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent 0115183 commit 2db8c65

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import java.io.IOException;
1010
import java.io.InputStream;
1111
import java.net.HttpURLConnection;
12+
import java.net.URI;
1213
import java.net.URISyntaxException;
13-
import java.net.URL;
1414
import java.util.ArrayList;
1515
import java.util.HashMap;
1616
import java.util.List;
@@ -68,18 +68,18 @@ protected Response scrape(String method, String queryString, String... requestHe
6868
throws IOException {
6969
return scrape(
7070
method,
71-
new URL(
71+
URI.create(
7272
"http://localhost:"
7373
+ sampleAppContainer.getMappedPort(9400)
7474
+ "/metrics?"
7575
+ queryString),
7676
requestHeaders);
7777
}
7878

79-
public static Response scrape(String method, URL url, String... requestHeaders)
79+
public static Response scrape(String method, URI uri, String... requestHeaders)
8080
throws IOException {
8181
long timeoutMillis = TimeUnit.SECONDS.toMillis(5);
82-
HttpURLConnection con = (HttpURLConnection) url.openConnection();
82+
HttpURLConnection con = (HttpURLConnection) uri.toURL().openConnection();
8383
con.setRequestMethod(method);
8484
for (int i = 0; i < requestHeaders.length; i += 2) {
8585
con.setRequestProperty(requestHeaders[i], requestHeaders[i + 1]);
@@ -111,7 +111,7 @@ public static Response scrape(String method, URL url, String... requestHeaders)
111111
if (exception != null) {
112112
exception.printStackTrace();
113113
}
114-
fail("timeout while getting metrics from " + url);
114+
fail("timeout while getting metrics from " + uri);
115115
return null; // will not happen
116116
}
117117

integration-tests/it-spring-boot-smoke-test/src/test/java/io/prometheus/metrics/it/springboot/ApplicationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.prometheus.client.it.common.ExporterTest;
66
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_32_1.Metrics;
77
import java.io.IOException;
8-
import java.net.URL;
8+
import java.net.URI;
99
import java.util.List;
1010
import java.util.Optional;
1111
import org.junit.jupiter.api.Test;
@@ -20,7 +20,7 @@ public void testPrometheusProtobufFormat() throws IOException {
2020
ExporterTest.Response response =
2121
ExporterTest.scrape(
2222
"GET",
23-
new URL("http://localhost:8080/actuator/prometheus"),
23+
URI.create("http://localhost:8080/actuator/prometheus"),
2424
"Accept",
2525
"application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily;"
2626
+ " encoding=delimited");

0 commit comments

Comments
 (0)