8000 Run CI on Java 17 (#2417) · mockito/mockito@6a50cc4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a50cc4

Browse files
TimvdLipperaphw
andauthored
Run CI on Java 17 (#2417)
Co-authored-by: Rafael Winterhalter <rafael.wth@gmail.com>
1 parent 99f8a62 commit 6a50cc4

File tree

8 files changed

+33
-30
lines changed

8 files changed

+33
-30
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
# Definition of the build matrix
2727
strategy:
2828
matrix:
29-
java: [8, 11, 15]
29+
java: [8, 11, 17]
3030
mock-maker: ['mock-maker-default', 'mock-maker-inline']
3131

3232
# All build steps
@@ -41,7 +41,7 @@ jobs:
4141
- name: 2. Set up Java ${{ matrix.java }}
4242
uses: actions/setup-java@v2
4343
with:
44-
distribution: 'adopt'
44+
distribution: 'zulu'
4545
java-version: ${{ matrix.java }}
4646

4747
- name: 3. Validate Gradle wrapper

gradle/root/coverage.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ task mockitoCoverage(type: JacocoReport) {
1919
apply plugin: "jacoco"
2020

2121
jacoco {
22-
toolVersion = '0.8.6'
22+
toolVersion = '0.8.7'
2323

2424
if (currentProject != rootProject) { //already automatically enhanced in mockito main project as "java" plugin was applied before
2525
applyTo test

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ include("inline",
1818
"junitJupiterParallelTest",
1919
"osgi-test")
2020

21-
if (System.getenv("ANDROID_SDK_ROOT") != null || File(".local.properties").exists()) {
21+
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) && (System.getenv("ANDROID_SDK_ROOT") != null || File(".local.properties").exists())) {
2222
include("androidTest")
2323
} else {
2424
logger.info("Not including android test project due to missing SDK configuration")

src/test/java/org/mockito/internal/creation/bytebuddy/SubclassByteBuddyMockMakerTest.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
*/
55
package org.mockito.internal.creation.bytebuddy;
66

7-
import static org.assertj.core.api.Assertions.assertThat;
8-
9-
import java.lang.annotation.Retention;
10-
import java.lang.annotation.RetentionPolicy;
11-
import java.util.Observable;
12-
import java.util.Observer;
13-
147
import net.bytebuddy.ByteBuddy;
158
import net.bytebuddy.ClassFileVersion;
169
import net.bytebuddy.description.modifier.TypeManifestation;
@@ -19,6 +12,13 @@
1912
import org.mockito.internal.creation.MockSettingsImpl;
2013
import org.mockito.plugins.MockMaker;
2114

15+
import java.lang.annotation.Retention;
16+
import java.lang.annotation.RetentionPolicy;
17+
import java.util.Observable;
18+
import java.util.Observer;
19+
20+
import static org.assertj.core.api.Assertions.assertThat;
21+
2222
public class SubclassByteBuddyMockMakerTest
2323
extends AbstractByteBuddyMockMakerTest<SubclassByteBuddyMockMaker> {
2424

@@ -35,22 +35,16 @@ public void is_type_mockable_excludes_primitive_wrapper_classes() {
3535

3636
@Test
3737
public void is_type_mockable_excludes_sealed_classes() {
38-
// is only supported on Java 17 and later
3938
if (ClassFileVersion.ofThisVm().isAtMost(ClassFileVersion.JAVA_V16)) {
4039
return;
4140
}
42-
DynamicType.Builder<Object> base = new ByteBuddy().subclass(Object.class);
43-
DynamicType.Unloaded<Object> dynamic =
44-
new ByteBuddy()
45-
.subclass(Object.class)
46-
.permittedSubclass(base.toTypeDescription())
47-
.make();
41+
DynamicType.Builder<?> base = new ByteBuddy().subclass(Object.class);
42+
DynamicType.Builder<?> subclass =
43+
new ByteBuddy().subclass(base.toTypeDescription()).merge(TypeManifestation.FINAL);
4844
Class<?> type =
49-
new ByteBuddy()
50-
.subclass(base.toTypeDescription())
51-
.merge(TypeManifestation.FINAL)
45+
base.permittedSubclass(subclass.toTypeDescription())
5246
.make()
53-
.include(dynamic)
47+
.include(subclass.make())
5448
.load(null)
5549
.getLoaded();
5650
MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(type);

src/test/java/org/mockito/internal/util/reflection/GenericMetadataSupportTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ public void can_get_raw_type_from_ParameterizedType() {
116116
public void can_get_type_variables_from_Class() {
117117
assertThat(inferFrom(GenericsNest.class).actualTypeArguments().keySet())
118118
.hasSize(1)
119-
.extracting("name")
119+
.extracting(TypeVariable::getName)
120120
.contains("K");
121121
assertThat(inferFrom(ListOfNumbers.class).actualTypeArguments().keySet()).isEmpty();
122122
assertThat(inferFrom(ListOfAnyNumbers.class).actualTypeArguments().keySet())
123123
.hasSize(1)
124-
.extracting("name")
124+
.extracting(TypeVariable::getName)
125125
.contains("N");
126126
assertThat(inferFrom(Map.class).actualTypeArguments().keySet())
127127
.hasSize(2)
128-
.extracting("name")
128+
.extracting(TypeVariable::getName)
129129
.contains("K", "V");
130130
assertThat(inferFrom(Serializable.class).actualTypeArguments().keySet()).isEmpty();
131131
assertThat(inferFrom(StringList.class).actualTypeArguments().keySet()).isEmpty();
@@ -153,21 +153,21 @@ public void can_get_type_variables_from_ParameterizedType() {
153153
.actualTypeArguments()
154154
.keySet())
155155
.hasSize(2)
156-
.extracting("name")
156+
.extracting(TypeVariable::getName)
157157
.contains("K", "V");
158158
assertThat(
159159
inferFrom(ListOfAnyNumbers.class.getGenericInterfaces()[0])
160160
.actualTypeArguments()
161161
.keySet())
162162
.hasSize(1)
163-
.extracting("name")
163+
.extracting(TypeVariable::getName)
164164
.contains("E");
165165
assertThat(
166166
inferFrom(Integer.class.getGenericInterfaces()[0])
167167
.actualTypeArguments()
168168
.keySet())
169169
.hasSize(1)
170-
.extracting("name")
170+
.extracting(TypeVariable::getName)
171171
.contains("T");
172172
assertThat(
173173
inferFrom(StringBuilder.class.getGenericInterfaces()[0])

src/test/java/org/mockitousage/serialization/AcrossClassLoaderSerializationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.List;
1212
import java.util.concurrent.Callable;
1313

14+
import net.bytebuddy.ClassFileVersion;
1415
import org.junit.Before;
1516
import org.junit.Test;
1617
import org.mockito.Mockito;
@@ -31,6 +32,10 @@ public void reproduce_CCE_by_creating_a_mock_with_IMethods_before() throws Excep
3132
@Test
3233
public void check_that_mock_can_be_serialized_in_a_classloader_and_deserialized_in_another()
3334
throws Exception {
35+
// No longer supported starting with JDK 16+
36+
if (!ClassFileVersion.ofThisVm().isAtMost(ClassFileVersion.JAVA_V16)) {
37+
return;
38+
}
3439
byte[] bytes = create_mock_and_serialize_it_in_class_loader_A();
3540

3641
Object the_deserialized_mock = read_stream_and_deserialize_it_in_class_loader_B(bytes);

src/test/java/org/mockitoutil/SimpleSerializationUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
import static org.junit.Assert.assertNotNull;
88

9-
import java.io.*;
9+
import java.io.ByteArrayInputStream;
10+
import java.io.ByteArrayOutputStream;
11+
import java.io.IOException;
12+
import java.io.InputStream;
13+
import java.io.ObjectInputStream;
14+
import java.io.ObjectOutputStream;
1015

1116
public abstract class SimpleSerializationUtil {
1217

subprojects/memory-test/memory-test.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ tasks.javadoc.enabled = false
1515

1616
test {
1717
maxHeapSize = "128m"
18-
jvmArgs = ["-XX:MaxPermSize=128m"]
1918
}

0 commit comments

Comments
 (0)
0