[GitHub] [kafka] cmccabe commented on a change in pull request #11137: KAFKA-13133 Replace EasyMock and PowerMock with Mockito for AbstractHerderTest
cmccabe commented on a change in pull request #11137: URL: https://github.com/apache/kafka/pull/11137#discussion_r682796708 ## File path: connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java ## @@ -135,90 +133,88 @@ private final int generation = 5; private final String connector = "connector"; private final ConnectorClientConfigOverridePolicy noneConnectorClientConfigOverridePolicy = new NoneConnectorClientConfigOverridePolicy(); +private Connector insConnector; -@MockStrict private Worker worker; -@MockStrict private WorkerConfigTransformer transformer; -@MockStrict private Plugins plugins; -@MockStrict private ClassLoader classLoader; -@MockStrict private ConfigBackingStore configStore; -@MockStrict private StatusBackingStore statusStore; +final private Worker worker = mock(Worker.class); +final private WorkerConfigTransformer transformer = mock(WorkerConfigTransformer.class); +final private Plugins plugins = mock(Plugins.class); +final private ClassLoader classLoader = mock(ClassLoader.class); +final private ConfigBackingStore configStore = mock(ConfigBackingStore.class); +final private StatusBackingStore statusStore = mock(StatusBackingStore.class); +private ClassLoader loader; + +@Before +public void before() { +loader = Utils.getContextOrKafkaClassLoader(); +} + +@After +public void tearDown() { +if (loader != null) Plugins.compareAndSwapLoaders(loader); +} @Test public void testConnectors() { -AbstractHerder herder = partialMockBuilder(AbstractHerder.class) -.withConstructor( -Worker.class, -String.class, -String.class, -StatusBackingStore.class, -ConfigBackingStore.class, -ConnectorClientConfigOverridePolicy.class -) -.withArgs(worker, workerId, kafkaClusterId, statusStore, configStore, noneConnectorClientConfigOverridePolicy) -.addMockedMethod("generation") -.createMock(); - -EasyMock.expect(herder.generation()).andStubReturn(generation); -EasyMock.expect(herder.rawConfig(connector)).andReturn(null); -EasyMock.expect(configStore.snapshot()).andReturn(SNAPSHOT); -replayAll(); +//AbstractHerder herder = partialMockBuilder(AbstractHerder.class) Review comment: why is this present but commented out? -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [kafka] cmccabe commented on a change in pull request #11137: KAFKA-13133 Replace EasyMock and PowerMock with Mockito for AbstractHerderTest
cmccabe commented on a change in pull request #11137: URL: https://github.com/apache/kafka/pull/11137#discussion_r682796708 ## File path: connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java ## @@ -135,90 +133,88 @@ private final int generation = 5; private final String connector = "connector"; private final ConnectorClientConfigOverridePolicy noneConnectorClientConfigOverridePolicy = new NoneConnectorClientConfigOverridePolicy(); +private Connector insConnector; -@MockStrict private Worker worker; -@MockStrict private WorkerConfigTransformer transformer; -@MockStrict private Plugins plugins; -@MockStrict private ClassLoader classLoader; -@MockStrict private ConfigBackingStore configStore; -@MockStrict private StatusBackingStore statusStore; +final private Worker worker = mock(Worker.class); +final private WorkerConfigTransformer transformer = mock(WorkerConfigTransformer.class); +final private Plugins plugins = mock(Plugins.class); +final private ClassLoader classLoader = mock(ClassLoader.class); +final private ConfigBackingStore configStore = mock(ConfigBackingStore.class); +final private StatusBackingStore statusStore = mock(StatusBackingStore.class); +private ClassLoader loader; + +@Before +public void before() { +loader = Utils.getContextOrKafkaClassLoader(); +} + +@After +public void tearDown() { +if (loader != null) Plugins.compareAndSwapLoaders(loader); +} @Test public void testConnectors() { -AbstractHerder herder = partialMockBuilder(AbstractHerder.class) -.withConstructor( -Worker.class, -String.class, -String.class, -StatusBackingStore.class, -ConfigBackingStore.class, -ConnectorClientConfigOverridePolicy.class -) -.withArgs(worker, workerId, kafkaClusterId, statusStore, configStore, noneConnectorClientConfigOverridePolicy) -.addMockedMethod("generation") -.createMock(); - -EasyMock.expect(herder.generation()).andStubReturn(generation); -EasyMock.expect(herder.rawConfig(connector)).andReturn(null); -EasyMock.expect(configStore.snapshot()).andReturn(SNAPSHOT); -replayAll(); +//AbstractHerder herder = partialMockBuilder(AbstractHerder.class) Review comment: it seems like you intended to remove this? -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [kafka] cmccabe commented on a change in pull request #11137: KAFKA-13133 Replace EasyMock and PowerMock with Mockito for AbstractHerderTest
cmccabe commented on a change in pull request #11137: URL: https://github.com/apache/kafka/pull/11137#discussion_r682796708 ## File path: connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java ## @@ -135,90 +133,88 @@ private final int generation = 5; private final String connector = "connector"; private final ConnectorClientConfigOverridePolicy noneConnectorClientConfigOverridePolicy = new NoneConnectorClientConfigOverridePolicy(); +private Connector insConnector; -@MockStrict private Worker worker; -@MockStrict private WorkerConfigTransformer transformer; -@MockStrict private Plugins plugins; -@MockStrict private ClassLoader classLoader; -@MockStrict private ConfigBackingStore configStore; -@MockStrict private StatusBackingStore statusStore; +final private Worker worker = mock(Worker.class); +final private WorkerConfigTransformer transformer = mock(WorkerConfigTransformer.class); +final private Plugins plugins = mock(Plugins.class); +final private ClassLoader classLoader = mock(ClassLoader.class); +final private ConfigBackingStore configStore = mock(ConfigBackingStore.class); +final private StatusBackingStore statusStore = mock(StatusBackingStore.class); +private ClassLoader loader; + +@Before +public void before() { +loader = Utils.getContextOrKafkaClassLoader(); +} + +@After +public void tearDown() { +if (loader != null) Plugins.compareAndSwapLoaders(loader); +} @Test public void testConnectors() { -AbstractHerder herder = partialMockBuilder(AbstractHerder.class) -.withConstructor( -Worker.class, -String.class, -String.class, -StatusBackingStore.class, -ConfigBackingStore.class, -ConnectorClientConfigOverridePolicy.class -) -.withArgs(worker, workerId, kafkaClusterId, statusStore, configStore, noneConnectorClientConfigOverridePolicy) -.addMockedMethod("generation") -.createMock(); - -EasyMock.expect(herder.generation()).andStubReturn(generation); -EasyMock.expect(herder.rawConfig(connector)).andReturn(null); -EasyMock.expect(configStore.snapshot()).andReturn(SNAPSHOT); -replayAll(); +//AbstractHerder herder = partialMockBuilder(AbstractHerder.class) Review comment: why is this present but commented out? ## File path: connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java ## @@ -135,90 +133,88 @@ private final int generation = 5; private final String connector = "connector"; private final ConnectorClientConfigOverridePolicy noneConnectorClientConfigOverridePolicy = new NoneConnectorClientConfigOverridePolicy(); +private Connector insConnector; -@MockStrict private Worker worker; -@MockStrict private WorkerConfigTransformer transformer; -@MockStrict private Plugins plugins; -@MockStrict private ClassLoader classLoader; -@MockStrict private ConfigBackingStore configStore; -@MockStrict private StatusBackingStore statusStore; +final private Worker worker = mock(Worker.class); +final private WorkerConfigTransformer transformer = mock(WorkerConfigTransformer.class); +final private Plugins plugins = mock(Plugins.class); +final private ClassLoader classLoader = mock(ClassLoader.class); +final private ConfigBackingStore configStore = mock(ConfigBackingStore.class); +final private StatusBackingStore statusStore = mock(StatusBackingStore.class); +private ClassLoader loader; + +@Before +public void before() { +loader = Utils.getContextOrKafkaClassLoader(); +} + +@After +public void tearDown() { +if (loader != null) Plugins.compareAndSwapLoaders(loader); +} @Test public void testConnectors() { -AbstractHerder herder = partialMockBuilder(AbstractHerder.class) -.withConstructor( -Worker.class, -String.class, -String.class, -StatusBackingStore.class, -ConfigBackingStore.class, -ConnectorClientConfigOverridePolicy.class -) -.withArgs(worker, workerId, kafkaClusterId, statusStore, configStore, noneConnectorClientConfigOverridePolicy) -.addMockedMethod("generation") -.createMock(); - -EasyMock.expect(herder.generation()).andStubReturn(generation); -EasyMock.expect(herder.rawConfig(connector)).andReturn(null); -EasyMock.expect(configStore.snapshot()).andReturn(SNAPSHOT); -replayAll(); +//AbstractHerder herder = partialMockBuilder(AbstractHerder.class) Review comment: it seems like you intended to remove this? -- This is an automated message fr