mimaison commented on code in PR #17804:
URL: https://github.com/apache/kafka/pull/17804#discussion_r1951123499


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/ConnectRestServerTest.java:
##########
@@ -375,6 +395,44 @@ public void testDefaultCustomizedHttpResponseHeaders() 
throws IOException  {
         checkCustomizedHttpResponseHeaders(headerConfig, expectedHeaders);
     }
 
+    static final class MonitorableConnectRestExtension extends 
PluginsTest.TestConnectRestExtension implements Monitorable {
+
+        private boolean called = false;
+        private static MetricName metricName;
+
+        @Override
+        public void register(ConnectRestExtensionContext restPluginContext) {
+            called = true;
+        }
+
+        @Override
+        public void withPluginMetrics(PluginMetrics metrics) {
+            metricName = metrics.metricName("name", "description", Map.of());
+            metrics.addMetric(metricName, (Gauge<Boolean>) (config, now) -> 
called);
+        }
+    }
+
+    @Test
+    public void testMonitorableConnectRestExtension() {
+        Map<String, String> configMap = new HashMap<>(baseServerProps());
+        configMap.put(RestServerConfig.REST_EXTENSION_CLASSES_CONFIG, 
MonitorableConnectRestExtension.class.getName());
+
+        doReturn(plugins).when(herder).plugins();
+        doReturn(Collections.singletonList(new 
MonitorableConnectRestExtension())).when(plugins).newPlugins(any(), any(), 
any());
+        server = new ConnectRestServer(null, restClient, configMap);
+
+        // the call throws because of mocks but the ConnectRestExtension 
should have been initialized
+        assertThrows(ConnectException.class, () -> 
server.initializeResources(herder));

Review Comment:
   I had forgotten about this hack, I've now fixed the mocks so the 
`initializeResources()` call does not throw.



-- 
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]

Reply via email to