You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Chris Egerton (Jira)" <ji...@apache.org> on 2022/11/01 17:12:00 UTC

[jira] [Commented] (KAFKA-14346) Remove static methods from internal Connect APIs for easier testing

    [ https://issues.apache.org/jira/browse/KAFKA-14346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17627259#comment-17627259 ] 

Chris Egerton commented on KAFKA-14346:
---------------------------------------

Although the examples in the description are probably the most important to address, there are other places where we mock static methods that may also be worth refactoring, including:
 * [Mocking the KeyGenerator and Mac classes|https://github.com/apache/kafka/blob/9ab140d5419d735baae45aff56ffce7f5622744f/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedConfigTest.java#L85-L86] from the Java SDK
 * [Mocking the WorkerConfig class|https://github.com/apache/kafka/blob/9ab140d5419d735baae45aff56ffce7f5622744f/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTest.java#L76-L77] to stub out logic for looking up the Kafka cluster ID

> Remove static methods from internal Connect APIs for easier testing
> -------------------------------------------------------------------
>
>                 Key: KAFKA-14346
>                 URL: https://issues.apache.org/jira/browse/KAFKA-14346
>             Project: Kafka
>          Issue Type: Improvement
>          Components: KafkaConnect
>            Reporter: Chris Egerton
>            Priority: Major
>
> Our use of static methods for internal APIs such as the [RestClient class|https://github.com/apache/kafka/blob/9ab140d5419d735baae45aff56ffce7f5622744f/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java] and [Plugins::compareAndSwapLoaders|https://github.com/apache/kafka/blob/9ab140d5419d735baae45aff56ffce7f5622744f/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java#L123-L129] makes testing difficult, especially with the in-progress migration from EasyMock/PowerMock to Mockito.
> We should remove these static methods and replace them with non-static methods that can be more easily mocked.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)