Skip to content

Commit

Permalink
Upgraded to Mockito 4.11.0 with the latest Byte Buddy for JDK 21 (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
azagniotov authored Jan 24, 2024
1 parent 8967c78 commit d5fe569
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 45 deletions.
88 changes: 49 additions & 39 deletions conf/gradle/tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,36 @@
* limitations under the License.
*/

configurations.all {
resolutionStrategy {
force "junit:junit:${junitVersion}"
force "com.google.truth:truth:${googleTruthVersion}"

// https://github.com/mockito/mockito/issues/2231
force "org.mockito:mockito-inline:${mockitoVersion}"
force "org.mockito:mockito-core:${mockitoVersion}"
// Explicitly adding a recent Byte Buddy to Mockito for the compatibility with JDK 21 and Mockito 4.x.x
force "net.bytebuddy:byte-buddy:${byteBuddyVersion}"

// https://github.com/googleapis/google-http-java-client/issues/167#issuecomment-571987053
force "com.google.http-client:google-http-client-apache-v2:${googleHttpClient}"

force "org.eclipse.jetty.http2:http2-client:${jettyVersion}"
force "org.eclipse.jetty.http2:http2-http-client-transport:${jettyVersion}"
}
}

testing {
suites {
test {
useJUnit()
dependencies {
implementation "junit:junit:4.13.1"
implementation "org.mockito:mockito-core:${mockitoVersion}"
// https://github.com/mockito/mockito/issues/2231
implementation "org.mockito:mockito-inline:${mockitoVersion}"
implementation "com.google.truth:truth:1.1.5"
implementation "com.google.http-client:google-http-client-apache-v2:1.38.1"
implementation "junit:junit"
implementation "org.mockito:mockito-core"
implementation "org.mockito:mockito-inline"
implementation "net.bytebuddy:byte-buddy"
implementation "com.google.truth:truth"
implementation "com.google.http-client:google-http-client-apache-v2"
}
}

Expand All @@ -39,23 +58,21 @@ testing {
useJUnit()
dependencies {
implementation project()
implementation "junit:junit:4.13.1"
implementation "org.mockito:mockito-core:${mockitoVersion}"
// https://github.com/mockito/mockito/issues/2231
implementation "org.mockito:mockito-inline:${mockitoVersion}"
implementation "com.google.truth:truth:1.1.5"

implementation "org.eclipse.jetty.http2:http2-client:${jettyVersion}"
implementation "org.eclipse.jetty.http2:http2-http-client-transport:${jettyVersion}"
implementation "junit:junit"
implementation "org.mockito:mockito-core"
implementation "org.mockito:mockito-inline"
implementation "net.bytebuddy:byte-buddy"
implementation "com.google.truth:truth"
implementation "com.google.http-client:google-http-client-apache-v2"

implementation "org.eclipse.jetty.http2:http2-client"
implementation "org.eclipse.jetty.http2:http2-http-client-transport"

if (project.hasProperty("useNativeJdkAlpnProcessor")) {
implementation "org.eclipse.jetty:jetty-alpn-java-client:${jettyVersion}"
} else {
implementation "org.eclipse.jetty:jetty-alpn-openjdk8-client:${jettyVersion}"
}

// https://github.com/googleapis/google-http-java-client/issues/167#issuecomment-571987053
implementation "com.google.http-client:google-http-client-apache-v2:1.38.1"
}

targets {
Expand All @@ -78,23 +95,21 @@ testing {
useJUnit()
dependencies {
implementation project()
implementation "junit:junit:4.13.1"
implementation "org.mockito:mockito-core:${mockitoVersion}"
// https://github.com/mockito/mockito/issues/2231
implementation "org.mockito:mockito-inline:${mockitoVersion}"
implementation "com.google.truth:truth:1.1.5"

implementation "org.eclipse.jetty.http2:http2-client:${jettyVersion}"
implementation "org.eclipse.jetty.http2:http2-http-client-transport:${jettyVersion}"
implementation "junit:junit"
implementation "org.mockito:mockito-core"
implementation "org.mockito:mockito-inline"
implementation "net.bytebuddy:byte-buddy"
implementation "com.google.truth:truth"
implementation "com.google.http-client:google-http-client-apache-v2"

implementation "org.eclipse.jetty.http2:http2-client"
implementation "org.eclipse.jetty.http2:http2-http-client-transport"

if (project.hasProperty("useNativeJdkAlpnProcessor")) {
implementation "org.eclipse.jetty:jetty-alpn-java-client:${jettyVersion}"
} else {
implementation "org.eclipse.jetty:jetty-alpn-openjdk8-client:${jettyVersion}"
}

// https://github.com/googleapis/google-http-java-client/issues/167#issuecomment-571987053
implementation "com.google.http-client:google-http-client-apache-v2:1.38.1"
}

targets {
Expand All @@ -118,23 +133,18 @@ testing {
useJUnit()
dependencies {
implementation project()
implementation "junit:junit:4.13.1"
implementation "org.mockito:mockito-core:${mockitoVersion}"
// https://github.com/mockito/mockito/issues/2231
implementation "org.mockito:mockito-inline:${mockitoVersion}"
implementation "com.google.truth:truth:1.1.5"

implementation "org.eclipse.jetty.http2:http2-client:${jettyVersion}"
implementation "org.eclipse.jetty.http2:http2-http-client-transport:${jettyVersion}"
implementation "junit:junit"
implementation "org.mockito:mockito-core"
implementation "org.mockito:mockito-inline"
implementation "net.bytebuddy:byte-buddy"
implementation "com.google.truth:truth"
implementation "com.google.http-client:google-http-client-apache-v2"

if (project.hasProperty("useNativeJdkAlpnProcessor")) {
implementation "org.eclipse.jetty:jetty-alpn-java-client:${jettyVersion}"
} else {
implementation "org.eclipse.jetty:jetty-alpn-openjdk8-client:${jettyVersion}"
}

// https://github.com/googleapis/google-http-java-client/issues/167#issuecomment-571987053
implementation "com.google.http-client:google-http-client-apache-v2:1.38.1"
}

targets {
Expand Down
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ log4j2Version=2.17.1
xmlUnitVersion=2.8.4
jettyVersion=9.4.53.v20231009
snakeYamlVersion=2.2
mockitoVersion=3.12.4
googleHttpClient=1.38.1
mockitoVersion=4.11.0
googleTruthVersion=1.1.5
junitVersion=4.13.2

# Explicitly adding a recent Byte Buddy to Mockito for the compatibility with JDK 21 and Mockito 4.x.x
byteBuddyVersion=1.14.2

stubbyProjectName=stubby4j
stubbyProjectGroup=io.github.azagniotov
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
Expand Down

0 comments on commit d5fe569

Please sign in to comment.