15
15
16
16
import java .util .Collections ;
17
17
import java .util .LinkedHashSet ;
18
+ import java .util .List ;
18
19
import java .util .Map ;
19
20
import java .util .Optional ;
20
21
import java .util .Set ;
21
22
import java .util .function .Function ;
22
23
23
24
import org .junit .jupiter .api .extension .ExecutableInvoker ;
25
+ import org .junit .jupiter .api .extension .Extension ;
24
26
import org .junit .jupiter .api .extension .ExtensionContext ;
25
27
import org .junit .jupiter .api .extension .ExtensionContext .Store .CloseableResource ;
26
28
import org .junit .jupiter .api .parallel .ExecutionMode ;
27
29
import org .junit .jupiter .engine .config .JupiterConfiguration ;
30
+ import org .junit .jupiter .engine .execution .DefaultExecutableInvoker ;
28
31
import org .junit .jupiter .engine .execution .NamespaceAwareStore ;
32
+ import org .junit .jupiter .engine .extension .ExtensionContextInternal ;
33
+ import org .junit .jupiter .engine .extension .ExtensionRegistry ;
29
34
import org .junit .platform .commons .JUnitException ;
30
35
import org .junit .platform .commons .util .Preconditions ;
31
36
import org .junit .platform .engine .EngineExecutionListener ;
38
43
/**
39
44
* @since 5.0
40
45
*/
41
- abstract class AbstractExtensionContext <T extends TestDescriptor > implements ExtensionContext , AutoCloseable {
46
+ abstract class AbstractExtensionContext <T extends TestDescriptor > implements ExtensionContextInternal , AutoCloseable {
42
47
43
48
private static final NamespacedHierarchicalStore .CloseAction <Namespace > CLOSE_RESOURCES = (__ , ___ , value ) -> {
44
49
if (value instanceof CloseableResource ) {
@@ -53,20 +58,21 @@ abstract class AbstractExtensionContext<T extends TestDescriptor> implements Ext
53
58
private final JupiterConfiguration configuration ;
54
59
private final NamespacedHierarchicalStore <Namespace > valuesStore ;
55
60
private final ExecutableInvoker executableInvoker ;
61
+ private final ExtensionRegistry extensionRegistry ;
56
62
57
63
AbstractExtensionContext (ExtensionContext parent , EngineExecutionListener engineExecutionListener , T testDescriptor ,
58
- JupiterConfiguration configuration ,
59
- Function <ExtensionContext , ExecutableInvoker > executableInvokerFactory ) {
60
- this .executableInvoker = executableInvokerFactory .apply (this );
64
+ JupiterConfiguration configuration , ExtensionRegistry extensionRegistry ) {
61
65
62
66
Preconditions .notNull (testDescriptor , "TestDescriptor must not be null" );
63
67
Preconditions .notNull (configuration , "JupiterConfiguration must not be null" );
64
-
68
+ Preconditions .notNull (extensionRegistry , "ExtensionRegistry must not be null" );
69
+ this .executableInvoker = new DefaultExecutableInvoker (this , extensionRegistry );
65
70
this .parent = parent ;
66
71
this .engineExecutionListener = engineExecutionListener ;
67
72
this .testDescriptor = testDescriptor ;
68
73
this .configuration = configuration ;
69
74
this .valuesStore = createStore (parent );
75
+ this .extensionRegistry = extensionRegistry ;
70
76
71
77
// @formatter:off
72
78
this .tags = testDescriptor .getTags ().stream ()
@@ -152,6 +158,11 @@ public ExecutableInvoker getExecutableInvoker() {
152
158
return executableInvoker ;
153
159
}
154
160
161
+ @ Override
162
+ public <E extends Extension > List <E > getExtensions (Class <E > extensionType ) {
163
+ return extensionRegistry .getExtensions (extensionType );
164
+ }
165
+
155
166
protected abstract Node .ExecutionMode getPlatformExecutionMode ();
156
167
157
168
private ExecutionMode toJupiterExecutionMode (Node .ExecutionMode mode ) {
0 commit comments