Skip to content

Commit 9bba553

Browse files
committed
Add metadata for Mockito 4.8.1
This only works for the 'ProxyMockMaker', which uses JDK proxies to create mocks. This method is only able to mock interfaces.
1 parent e0ab4f6 commit 9bba553

File tree

16 files changed

+358
-0
lines changed

16 files changed

+358
-0
lines changed

metadata/index.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,9 @@
149149
{
150150
"directory": "org.testcontainers/testcontainers",
151151
"module": "org.testcontainers:testcontainers"
152+
},
153+
{
154+
"directory": "org.mockito/mockito-core",
155+
"module": "org.mockito:mockito-core"
152156
}
153157
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"reflect-config.json",
3+
"resource-config.json"
4+
]
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
[
2+
{
3+
"condition": {
4+
"typeReachable": "org.mockito.internal.debugging.Java9PlusLocationImpl$MetadataShim"
5+
},
6+
"name": "java.lang.Object",
7+
"methods": [
8+
{
9+
"name": "toString",
10+
"parameterTypes": []
11+
}
12+
]
13+
},
14+
{
15+
"condition": {
16+
"typeReachable": "org.mockito.internal.debugging.Java9PlusLocationImpl"
17+
},
18+
"name": "java.lang.StackWalker",
19+
"methods": [
20+
{
21+
"name": "getInstance",
22+
"parameterTypes": [
23+
"java.util.Set",
24+
"int"
25+
]
26+
},
27+
{
28+
"name": "walk",
29+
"parameterTypes": [
30+
"java.util.function.Function"
31+
]
32+
}
33+
]
34+
},
35+
{
36+
"condition": {
37+
"typeReachable": "org.mockito.internal.debugging.LocationFactory"
38+
},
39+
"name": "java.lang.StackWalker"
40+
},
41+
{
42+
"condition": {
43+
"typeReachable": "org.mockito.internal.debugging.Java9PlusLocationImpl"
44+
},
45+
"name": "java.lang.StackWalker$Option"
46+
},
47+
{
48+
"condition": {
49+
"typeReachable": "org.mockito.internal.debugging.Java9PlusLocationImpl"
50+
},
51+
"name": "java.lang.StackWalker$StackFrame"
52+
},
53+
{
54+
"condition": {
55+
"typeReachable": "org.mockito.internal.debugging.Java9PlusLocationImpl$MetadataShim"
56+
},
57+
"name": "java.lang.StackWalker$StackFrame",
58+
"methods": [
59+
{
60+
"name": "getClassName",
61+
"parameterTypes": []
62+
},
63+
{
64+
"name": "getFileName",
65+
"parameterTypes": []
66+
},
67+
{
68+
"name": "getLineNumber",
69+
"parameterTypes": []
70+
},
71+
{
72+
"name": "getMethodName",
73+
"parameterTypes": []
74+
}
75+
]
76+
},
77+
{
78+
"condition": {
79+
"typeReachable": "org.mockito.internal.creation.proxy.InvokeDefaultProxy"
80+
},
81+
"name": "java.lang.reflect.InvocationHandler",
82+
"methods": [
83+
{
84+
"name": "invokeDefault",
85+
"parameterTypes": [
86+
"java.lang.Object",
87+
"java.lang.reflect.Method",
88+
"java.lang.Object[]"
89+
]
90+
}
91+
]
92+
},
93+
{
94+
"condition": {
95+
"typeReachable": "org.mockito.internal.util.KotlinInlineClassUtil"
96+
},
97+
"name": "kotlin.jvm.JvmInline"
98+
},
99+
{
100+
"condition": {
101+
"typeReachable": "org.mockito.internal.configuration.ClassPathLoader"
102+
},
103+
"name": "org.mockito.configuration.MockitoConfiguration"
104+
},
105+
{
106+
"condition": {
107+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
108+
},
109+
"name": "org.mockito.internal.configuration.DefaultDoNotMockEnforcer",
110+
"methods": [
111+
{
112+
"name": "<init>",
113+
"parameterTypes": []
114+
}
115+
]
116+
},
117+
{
118+
"condition": {
119+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
120+
},
121+
"name": "org.mockito.internal.configuration.InjectingAnnotationEngine",
122+
"methods": [
123+
{
124+
"name": "<init>",
125+
"parameterTypes": []
126+
}
127+
]
128+
},
129+
{
130+
"condition": {
131+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
132+
},
133+
"name": "org.mockito.internal.configuration.plugins.DefaultPluginSwitch",
134+
"methods": [
135+
{
136+
"name": "<init>",
137+
"parameterTypes": []
138+
}
139+
]
140+
},
141+
{
142+
"condition": {
143+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
144+
},
145+
"name": "org.mockito.internal.creation.instance.DefaultInstantiatorProvider",
146+
"methods": [
147+
{
148+
"name": "<init>",
149+
"parameterTypes": []
150+
}
151+
]
152+
},
153+
{
154+
"condition": {
155+
"typeReachable": "org.mockito.internal.configuration.plugins.PluginInitializer"
156+
},
157+
"name": "org.mockito.internal.creation.proxy.ProxyMockMaker",
158+
"methods": [
159+
{
160+
"name": "<init>",
161+
"parameterTypes": []
162+
}
163+
]
164+
},
165+
{
166+
"condition": {
167+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
168+
},
169+
"name": "org.mockito.internal.exceptions.stacktrace.DefaultStackTraceCleanerProvider",
170+
"methods": [
171+
{
172+
"name": "<init>",
173+
"parameterTypes": []
174+
}
175+
]
176+
},
177+
{
178+
"condition": {
179+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
180+
},
181+
"name": "org.mockito.internal.util.ConsoleMockitoLogger",
182+
"methods": [
183+
{
184+
"name": "<init>",
185+
"parameterTypes": []
186+
}
187+
]
188+
},
189+
{
190+
"condition": {
191+
"typeReachable": "org.mockito.internal.configuration.plugins.DefaultMockitoPlugins"
192+
},
193+
"name": "org.mockito.internal.util.reflection.ReflectionMemberAccessor",
194+
"methods": [
195+
{
196+
"name": "<init>",
197+
"parameterTypes": []
198+
}
199+
]
200+
}
201+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"resources": {
3+
"includes": [
4+
{
5+
"condition": {
6+
"typeReachable": "org.mockito.internal.configuration.plugins.PluginInitializer"
7+
},
8+
"pattern": "\\Qmockito-extensions/org.mockito.plugins.MockMaker\\E"
9+
}
10+
]
11+
},
12+
"bundles": []
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"latest": true,
4+
"metadata-version": "4.8.1",
5+
"module": "org.mockito:mockito-core",
6+
"tested-versions": [
7+
"4.8.1"
8+
]
9+
}
10+
]

tests/src/index.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,5 +405,16 @@
405405
]
406406
}
407407
]
408+
},
409+
{
410+
"test-project-path": "org.mockito/mockito-core/4.8.1",
411+
"libraries": [
412+
{
413+
"name": "org.mockito:mockito-core",
414+
"versions": [
415+
"4.8.1"
416+
]
417+
}
418+
]
408419
}
409420
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gradlew.bat
2+
gradlew
3+
gradle/
4+
build/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Mockito
2+
3+
Mockito works in GraalVM when using the `org.mockito.internal.creation.proxy.ProxyMockMaker`, which uses JDK proxies
4+
to mock interfaces, and interfaces only.
5+
6+
Metadata has been collected by using the agent.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
8+
plugins {
9+
id "org.graalvm.internal.tck"
10+
}
11+
12+
String libraryVersion = tck.testedLibraryVersion.get()
13+
14+
dependencies {
15+
testImplementation "org.mockito:mockito-core:$libraryVersion"
16+
testImplementation 'org.assertj:assertj-core:3.22.0'
17+
}
18+
19+
graalvmNative {
20+
agent {
21+
defaultMode = "conditional"
22+
modes {
23+
conditional {
24+
userCodeFilterPath = "user-code-filter.json"
25+
}
26+
}
27+
metadataCopy {
28+
mergeWithExisting = true
29+
inputTaskNames.add("test")
30+
outputDirectories.add("src/test/resources/META-INF/native-image/org.mockito/mockito-core")
31+
}
32+
}
33+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
library.version=4.8.1
2+
metadata.dir=/home/moe/Projects/graalvm-reachability-metadata/metadata/org.mockito/mockito-core/4.8.1
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
8+
pluginManagement {
9+
def tckPath = Objects.requireNonNullElse(
10+
System.getenv("GVM_TCK_TCKDIR"),
11+
"../../../../tck-build-logic"
12+
)
13+
includeBuild(tckPath)
14+
}
15+
16+
plugins {
17+
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT"
18+
}
19+
20+
rootProject.name = 'org.mockito.mockito-core_tests'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
package org_mockito.mockito_core;
8+
9+
import org.junit.jupiter.api.Test;
10+
import org.mockito.Mockito;
11+
12+
import static org.assertj.core.api.Assertions.assertThat;
13+
14+
class MockitoTest {
15+
@Test
16+
void test() {
17+
MyService myService = Mockito.mock(MyService.class);
18+
Mockito.when(myService.getGreeting()).thenReturn("Hello Mockito");
19+
assertThat(myService.getGreeting()).isEqualTo("Hello Mockito");
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
package org_mockito.mockito_core;
8+
9+
public interface MyService {
10+
String getGreeting();
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"interfaces": [
4+
"org_mockito.mockito_core.MyService"
5+
]
6+
}
7+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.mockito.internal.creation.proxy.ProxyMockMaker
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"rules": [
3+
{
4+
"excludeClasses": "**"
5+
},
6+
{
7+
"includeClasses": "org.mockito.**"
8+
}
9+
]
10+
}

0 commit comments

Comments
 (0)