nastra commented on code in PR #16310:
URL: https://github.com/apache/iceberg/pull/16310#discussion_r3233359643
##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -4011,9 +3376,91 @@ protected RESTSessionCatalog newSessionCatalog(
return catalog;
}
+ static HTTPRequest reqMatcher(HTTPMethod method) {
+ return argThat(req -> req.method() == method);
+ }
+
+ static HTTPRequest reqMatcher(HTTPMethod method, String path) {
+ return argThat(req -> req.method() == method && req.path().equals(path));
+ }
+
+ static HTTPRequest reqMatcher(HTTPMethod method, String path, Map<String,
String> headers) {
+ return argThat(
+ req ->
+ req.method() == method
+ && req.path().equals(path)
+ && req.headers().equals(HTTPHeaders.of(headers)));
+ }
+
+ static HTTPRequest reqMatcher(
+ HTTPMethod method, String path, Map<String, String> headers, Map<String,
String> parameters) {
+ return argThat(
+ req ->
+ req.method() == method
+ && req.path().equals(path)
+ && req.headers().equals(HTTPHeaders.of(headers))
+ && req.queryParameters().equals(parameters));
+ }
+
+ static HTTPRequest reqMatcher(
+ HTTPMethod method,
+ String path,
+ Map<String, String> headers,
+ Map<String, String> parameters,
+ Object body) {
+ return argThat(
+ req ->
+ req.method() == method
+ && req.path().equals(path)
+ && req.headers().equals(HTTPHeaders.of(headers))
+ && req.queryParameters().equals(parameters)
+ && Objects.equals(req.body(), body));
+ }
+
private static List<HTTPRequest> allRequests(RESTCatalogAdapter adapter) {
ArgumentCaptor<HTTPRequest> captor =
ArgumentCaptor.forClass(HTTPRequest.class);
verify(adapter, atLeastOnce()).execute(captor.capture(), any(), any(),
any());
return captor.getAllValues();
}
+
+ @Test
+ public void closeCascadesToCustomMetricsReporter() throws IOException {
+ CloseTrackingMetricsReporter.CLOSE_COUNT.set(0);
+
+ RESTCatalogAdapter adapter = Mockito.spy(new
RESTCatalogAdapter(backendCatalog));
+ RESTCatalog catalog =
+ new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config)
-> adapter);
+ catalog.initialize(
+ "prod",
+ ImmutableMap.of(
+ CatalogProperties.URI,
+ "ignored",
+ CatalogProperties.METRICS_REPORTER_IMPL,
+ CloseTrackingMetricsReporter.class.getName()));
+
+ catalog.close();
Review Comment:
nit: maybe put the init & closing of the catalog in a try-finally block
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]