From cc1202d062b1a49d8856cd208dabf90753e7a2bd Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Sun, 9 Jun 2024 00:17:43 +0800 Subject: [PATCH] KAFKA-16878 Remove powermock and easymock from code base (#16236) Reviewers: TaiJuWu , Chia-Ping Tsai --- build.gradle | 18 ++---------------- checkstyle/import-control.xml | 5 ----- ...cribeTopicPartitionsRequestHandlerTest.java | 2 -- .../unit/kafka/server/KafkaApisTest.scala | 2 -- gradle/dependencies.gradle | 12 ------------ 5 files changed, 2 insertions(+), 37 deletions(-) diff --git a/build.gradle b/build.gradle index fdd1f3cc08b6b..7561708b7fcfc 100644 --- a/build.gradle +++ b/build.gradle @@ -522,13 +522,6 @@ subprojects { // The suites are for running sets of tests in IDEs. // Gradle will run each test class, so we exclude the suites to avoid redundantly running the tests twice. def testsToExclude = ['**/*Suite.class'] - // Exclude PowerMock tests when running with Java 16 or newer until a version of PowerMock that supports the relevant versions is released - // The relevant issues are https://github.com/powermock/powermock/issues/1094 and https://github.com/powermock/powermock/issues/1099 - if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16)) { - testsToExclude.addAll([ - // connect tests - ]) - } test { maxParallelForks = maxTestForks @@ -825,10 +818,7 @@ subprojects { jacoco { toolVersion = versions.jacoco } - - // NOTE: Jacoco Gradle plugin does not support "offline instrumentation" this means that classes mocked by PowerMock - // may report 0 coverage, since the source was modified after initial instrumentation. - // See https://github.com/jacoco/jacoco/issues/51 + jacocoTestReport { dependsOn tasks.test sourceSets sourceSets.main @@ -2376,7 +2366,6 @@ project(':streams') { testImplementation libs.log4j testImplementation libs.junitJupiter testImplementation libs.junitVintageEngine - testImplementation libs.easymock testImplementation libs.bcpkix testImplementation libs.hamcrest testImplementation libs.mockitoCore @@ -3257,12 +3246,9 @@ project(':connect:runtime') { testImplementation project(':storage') testImplementation project(':connect:test-plugins') testImplementation project(':group-coordinator') - - testImplementation libs.easymock + testImplementation libs.junitJupiterApi testImplementation libs.junitVintageEngine - testImplementation libs.powermockJunit4 - testImplementation libs.powermockEasymock testImplementation libs.mockitoCore testImplementation libs.httpclient diff --git a/checkstyle/import-control.xml b/checkstyle/import-control.xml index 2f90548ffa918..7e7e61b097793 100644 --- a/checkstyle/import-control.xml +++ b/checkstyle/import-control.xml @@ -30,8 +30,6 @@ - - @@ -622,9 +620,6 @@ - - - diff --git a/core/src/test/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandlerTest.java b/core/src/test/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandlerTest.java index 058ab9522b283..5c1cfc2f59f15 100644 --- a/core/src/test/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandlerTest.java +++ b/core/src/test/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandlerTest.java @@ -125,7 +125,6 @@ void testDescribeTopicPartitionsRequest() { Action expectedActions2 = new Action(AclOperation.DESCRIBE, new ResourcePattern(ResourceType.TOPIC, authorizedTopic, PatternType.LITERAL), 1, true, true); Action expectedActions3 = new Action(AclOperation.DESCRIBE, new ResourcePattern(ResourceType.TOPIC, authorizedNonExistTopic, PatternType.LITERAL), 1, true, true); - // Here we need to use AuthHelperTest.matchSameElements instead of EasyMock.eq since the order of the request is unknown when(authorizer.authorize(any(RequestContext.class), argThat(t -> t.contains(expectedActions1) || t.contains(expectedActions2) || t.contains(expectedActions3)))) .thenAnswer(invocation -> { @@ -328,7 +327,6 @@ void testDescribeTopicPartitionsRequestWithEdgeCases() { Action expectedActions1 = new Action(AclOperation.DESCRIBE, new ResourcePattern(ResourceType.TOPIC, authorizedTopic, PatternType.LITERAL), 1, true, true); Action expectedActions2 = new Action(AclOperation.DESCRIBE, new ResourcePattern(ResourceType.TOPIC, authorizedTopic2, PatternType.LITERAL), 1, true, true); - // Here we need to use AuthHelperTest.matchSameElements instead of EasyMock.eq since the order of the request is unknown when(authorizer.authorize(any(RequestContext.class), argThat(t -> t.contains(expectedActions1) || t.contains(expectedActions2)))) .thenAnswer(invocation -> { diff --git a/core/src/test/scala/unit/kafka/server/KafkaApisTest.scala b/core/src/test/scala/unit/kafka/server/KafkaApisTest.scala index bd0ded29debf9..16b12e3fc5ff2 100644 --- a/core/src/test/scala/unit/kafka/server/KafkaApisTest.scala +++ b/core/src/test/scala/unit/kafka/server/KafkaApisTest.scala @@ -2825,7 +2825,6 @@ class KafkaApisTest extends Logging { @Test def requiredAclsNotPresentWriteTxnMarkersThrowsAuthorizationException(): Unit = { - // Here we need to use AuthHelperTest.matchSameElements instead of EasyMock.eq since the order of the request is unknown val topicPartition = new TopicPartition("t", 0) val (_, request) = createWriteTxnMarkersRequest(asList(topicPartition)) @@ -4098,7 +4097,6 @@ class KafkaApisTest extends Logging { new Action(AclOperation.DESCRIBE, new ResourcePattern(ResourceType.TOPIC, authorizedTopic, PatternType.LITERAL), 1, true, true) ) - // Here we need to use AuthHelperTest.matchSameElements instead of EasyMock.eq since the order of the request is unknown when(authorizer.authorize(any[RequestContext], argThat((t: java.util.List[Action]) => t.containsAll(expectedActions.asJava)))) .thenAnswer { invocation => val actions = invocation.getArgument(1).asInstanceOf[util.List[Action]].asScala diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 70b86bad88492..b81c641560cff 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -76,14 +76,6 @@ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) else mockitoArtifactName = "mockito-inline" -// easymock 5.2 is required for Java 21 support, but it breaks tests using powermock -// powermock doesn't work with Java 16 or newer and hence it's safe to use the newer version in this case only -String easymockVersion -if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16)) - easymockVersion = "5.2.0" -else - easymockVersion = "4.3" - // When adding, removing or updating dependencies, please also update the LICENSE-binary file accordingly. // See https://issues.apache.org/jira/browse/KAFKA-12622 for steps to verify the LICENSE-binary file is correct. versions += [ @@ -149,7 +141,6 @@ versions += [ netty: "4.1.110.Final", opentelemetryProto: "1.0.0-alpha", pcollections: "4.0.1", - powermock: "2.0.9", reflections: "0.10.2", reload4j: "1.2.25", rocksDB: "7.9.2", @@ -184,7 +175,6 @@ libs += [ caffeine: "com.github.ben-manes.caffeine:caffeine:$versions.caffeine", commonsCli: "commons-cli:commons-cli:$versions.commonsCli", commonsValidator: "commons-validator:commons-validator:$versions.commonsValidator", - easymock: "org.easymock:easymock:$easymockVersion", jacksonAnnotations: "com.fasterxml.jackson.core:jackson-annotations:$versions.jackson", jacksonDatabind: "com.fasterxml.jackson.core:jackson-databind:$versions.jackson", jacksonDataformatCsv: "com.fasterxml.jackson.dataformat:jackson-dataformat-csv:$versions.jackson", @@ -246,8 +236,6 @@ libs += [ nettyTransportNativeEpoll: "io.netty:netty-transport-native-epoll:$versions.netty", pcollections: "org.pcollections:pcollections:$versions.pcollections", opentelemetryProto: "io.opentelemetry.proto:opentelemetry-proto:$versions.opentelemetryProto", - powermockJunit4: "org.powermock:powermock-module-junit4:$versions.powermock", - powermockEasymock: "org.powermock:powermock-api-easymock:$versions.powermock", reflections: "org.reflections:reflections:$versions.reflections", rocksDBJni: "org.rocksdb:rocksdbjni:$versions.rocksDB", scalaCollectionCompat: "org.scala-lang.modules:scala-collection-compat_$versions.baseScala:$versions.scalaCollectionCompat",