kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject kafka git commit: MINOR: Update powermock and enable its tests when running with Java 9
Date Mon, 18 Sep 2017 09:49:32 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk a339a387e -> a3f068e22


MINOR: Update powermock and enable its tests when running with Java 9

Also:
1. Fix WorkerTest to use the correct `Mock` annotations. `org.easymock.Mock`
is not supported by PowerMock 2.x.
2. Rename `powermock` to `powermockJunit4` in `dependencies.gradle` for
clarity.

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Closes #3881 from ijuma/kafka-5884-powermock-java


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/a3f068e2
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/a3f068e2
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/a3f068e2

Branch: refs/heads/trunk
Commit: a3f068e22da6915cbc473be8da0cfbb229817436
Parents: a339a38
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Mon Sep 18 10:49:12 2017 +0100
Committer: Rajini Sivaram <rajinisivaram@googlemail.com>
Committed: Mon Sep 18 10:49:12 2017 +0100

----------------------------------------------------------------------
 build.gradle                                    | 30 ++++----------------
 .../kafka/connect/runtime/WorkerTest.java       | 19 +++++++------
 gradle/dependencies.gradle                      |  7 ++---
 3 files changed, 20 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/a3f068e2/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index b1950e7..022802a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -193,20 +193,6 @@ subprojects {
   def testShowStandardStreams = false
   def testExceptionFormat = 'full'
 
-  // Exclude PowerMock tests when running with Java 9 until a version of PowerMock that supports
Java 9 is released
-  // The relevant issue is https://github.com/powermock/powermock/issues/783
-  String[] testsToExclude = []
-  if (JavaVersion.current().isJava9Compatible()) {
-    testsToExclude = [
-      "**/KafkaProducerTest.*", "**/BufferPoolTest.*",
-      "**/SourceTaskOffsetCommitterTest.*", "**/WorkerSinkTaskTest.*", "**/WorkerSinkTaskThreadedTest.*",
-      "**/WorkerSourceTaskTest.*", "**/WorkerTest.*", "**/DistributedHerderTest.*", "**/WorkerCoordinatorTest.*",
-      "**/RestServerTest.*", "**/ConnectorPluginsResourceTest.*", "**/ConnectorsResourceTest.*",
-      "**/StandaloneHerderTest.*", "**/FileOffsetBakingStoreTest.*", "**/KafkaConfigBackingStoreTest.*",
-      "**/KafkaOffsetBackingStoreTest.*", "**/OffsetStorageWriterTest.*", "**/KafkaBasedLogTest.*"
-    ]
-  }
-
   test {
     maxParallelForks = userMaxForks ?: Runtime.runtime.availableProcessors()
 
@@ -220,7 +206,6 @@ subprojects {
       exceptionFormat = testExceptionFormat
     }
 
-    exclude(testsToExclude)
   }
 
   task integrationTest(type: Test, dependsOn: compileJava) {
@@ -240,8 +225,6 @@ subprojects {
       includeCategories 'org.apache.kafka.test.IntegrationTest'
     }
 
-    exclude(testsToExclude)
-
   }
 
   task unitTest(type: Test, dependsOn: compileJava) {
@@ -260,8 +243,7 @@ subprojects {
     useJUnit {
       excludeCategories 'org.apache.kafka.test.IntegrationTest'
     }
-
-    exclude(testsToExclude)
+    
   }
 
   jar {
@@ -788,7 +770,7 @@ project(':clients') {
     testCompile libs.bcpkix
     testCompile libs.junit
     testCompile libs.easymock
-    testCompile libs.powermock
+    testCompile libs.powermockJunit4
     testCompile libs.powermockEasymock
 
     testRuntime libs.slf4jlog4j
@@ -1076,7 +1058,7 @@ project(':connect:transforms') {
 
     testCompile libs.easymock
     testCompile libs.junit
-    testCompile libs.powermock
+    testCompile libs.powermockJunit4
     testCompile libs.powermockEasymock
 
     testRuntime libs.slf4jlog4j
@@ -1114,7 +1096,7 @@ project(':connect:json') {
 
     testCompile libs.easymock
     testCompile libs.junit
-    testCompile libs.powermock
+    testCompile libs.powermockJunit4
     testCompile libs.powermockEasymock
 
     testRuntime libs.slf4jlog4j
@@ -1163,7 +1145,7 @@ project(':connect:runtime') {
     testCompile project(':clients').sourceSets.test.output
     testCompile libs.easymock
     testCompile libs.junit
-    testCompile libs.powermock
+    testCompile libs.powermockJunit4
     testCompile libs.powermockEasymock
 
     testCompile project(":connect:json")
@@ -1216,7 +1198,7 @@ project(':connect:file') {
 
     testCompile libs.easymock
     testCompile libs.junit
-    testCompile libs.powermock
+    testCompile libs.powermockJunit4
     testCompile libs.powermockEasymock
 
     testRuntime libs.slf4jlog4j

http://git-wip-us.apache.org/repos/asf/kafka/blob/a3f068e2/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java
----------------------------------------------------------------------
diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java
index 7fad7c1..a807a30 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java
@@ -43,11 +43,12 @@ import org.apache.kafka.connect.util.MockTime;
 import org.apache.kafka.connect.util.ThreadedTest;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
-import org.easymock.Mock;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.powermock.api.easymock.PowerMock;
+import org.powermock.api.easymock.annotation.Mock;
+import org.powermock.api.easymock.annotation.MockStrict;
 import org.powermock.core.classloader.annotations.PowerMockIgnore;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
@@ -76,15 +77,17 @@ public class WorkerTest extends ThreadedTest {
     private Worker worker;
 
     @Mock
-    private Plugins plugins = PowerMock.createMock(Plugins.class);
+    private Plugins plugins;
     @Mock
-    private PluginClassLoader pluginLoader = PowerMock.createMock(PluginClassLoader.class);
+    private PluginClassLoader pluginLoader;
     @Mock
-    private DelegatingClassLoader delegatingLoader =
-            PowerMock.createMock(DelegatingClassLoader.class);
-    private OffsetBackingStore offsetBackingStore = PowerMock.createMock(OffsetBackingStore.class);
-    private TaskStatus.Listener taskStatusListener = PowerMock.createStrictMock(TaskStatus.Listener.class);
-    private ConnectorStatus.Listener connectorStatusListener = PowerMock.createStrictMock(ConnectorStatus.Listener.class);
+    private DelegatingClassLoader delegatingLoader;
+    @Mock
+    private OffsetBackingStore offsetBackingStore;
+    @MockStrict
+    private TaskStatus.Listener taskStatusListener;
+    @MockStrict
+    private ConnectorStatus.Listener connectorStatusListener;
 
     @Before
     public void setup() {

http://git-wip-us.apache.org/repos/asf/kafka/blob/a3f068e2/gradle/dependencies.gradle
----------------------------------------------------------------------
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index 3b95100..a7c99eb 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -61,9 +61,8 @@ versions += [
   junit: "4.12",
   lz4: "1.4",
   metrics: "2.2.0",
-  // A few connect tests fail with powermock 1.6.5 due to https://github.com/powermock/powermock/issues/828,
which
-  // is easy to workaround. However, WorkerTest also fails and it seems to be for a different
reason.
-  powermock: "1.6.4",
+  // PowerMock 1.x doesn't support Java 9, so use PowerMock 2.0.0 beta
+  powermock: "2.0.0-beta.5",
   reflections: "0.9.11",
   rocksDB: "5.3.6",
   scalatest: "3.0.4",
@@ -103,7 +102,7 @@ libs += [
   joptSimple: "net.sf.jopt-simple:jopt-simple:$versions.jopt",
   lz4: "org.lz4:lz4-java:$versions.lz4",
   metrics: "com.yammer.metrics:metrics-core:$versions.metrics",
-  powermock: "org.powermock:powermock-module-junit4:$versions.powermock",
+  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",


Mime
View raw message