You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/11/07 10:35:08 UTC

[GitHub] [kafka] clolov commented on a diff in pull request #12823: KAFKA-14132: Replace PowerMock and EasyMock with Mockito in connect tests

clolov commented on code in PR #12823:
URL: https://github.com/apache/kafka/pull/12823#discussion_r1015259138


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/SourceTaskOffsetCommitterTest.java:
##########
@@ -71,122 +74,74 @@ public void setup() {
                 Long.toString(DEFAULT_OFFSET_COMMIT_INTERVAL_MS));
         WorkerConfig config = new StandaloneConfig(workerProps);
         committer = new SourceTaskOffsetCommitter(config, executor, committers);
-        Whitebox.setInternalState(SourceTaskOffsetCommitter.class, "log", mockLog);
     }
 
     @SuppressWarnings("unchecked")
     @Test
     public void testSchedule() {
-        Capture<Runnable> taskWrapper = EasyMock.newCapture();
+        ArgumentCaptor<Runnable> taskWrapper = ArgumentCaptor.forClass(Runnable.class);
 
-        EasyMock.expect(executor.scheduleWithFixedDelay(
-                EasyMock.capture(taskWrapper), eq(DEFAULT_OFFSET_COMMIT_INTERVAL_MS),
+        when(executor.scheduleWithFixedDelay(
+                taskWrapper.capture(), eq(DEFAULT_OFFSET_COMMIT_INTERVAL_MS),
                 eq(DEFAULT_OFFSET_COMMIT_INTERVAL_MS), eq(TimeUnit.MILLISECONDS))
-        ).andReturn((ScheduledFuture) commitFuture);
-
-        PowerMock.replayAll();
+        ).thenReturn((ScheduledFuture) commitFuture);
 
         committer.schedule(taskId, task);
-        assertTrue(taskWrapper.hasCaptured());
         assertNotNull(taskWrapper.getValue());
         assertEquals(singletonMap(taskId, commitFuture), committers);
-
-        PowerMock.verifyAll();
     }
 
     @Test
     public void testClose() throws Exception {
         long timeoutMs = 1000;
 
         // Normal termination, where termination times out.
-        executor.shutdown();
-        PowerMock.expectLastCall();
-
-        EasyMock.expect(executor.awaitTermination(eq(timeoutMs), eq(TimeUnit.MILLISECONDS)))
-                .andReturn(false);
-        mockLog.error(EasyMock.anyString());

Review Comment:
   This is a very fair and clean suggestion. I have added it to the subsequent commits.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org