@API(value=Experimental)
public interface ExtensionPointRegistry
ExtensionPoint implementations which can be
populated via an ExtensionRegistrar.
All examples below are implementations of
ExtensionRegistrar.registerExtensions(org.junit.gen5.api.extension.ExtensionPointRegistry).
ExtensionPoint InstanceIf you have an instance of an extension that implements one or more
ExtensionPoint APIs, you can register it as follows.
public void registerExtensions(ExtensionPointRegistry registry) {
CustomExtension customExtension = // instantiate extension
registry.register(customExtension);
}
Similarly, an instance of an extension can be registered with an
explicit ExtensionPointRegistry.Position as follows.
public void registerExtensions(ExtensionPointRegistry registry) {
CustomExtension customExtension = // instantiate extension
registry.register(customExtension, Position.INNERMOST);
}
ExtensionPointIf you would like to implement a single ExtensionPoint API
as a lambda expression, you can register it as follows. Note, however,
that the API must be a functional
interface.
public void registerExtensions(ExtensionPointRegistry registry) {
registry.register((BeforeEachExtensionPoint) context -> { /* ... */ });
}
ExtensionPointIf you would like to implement a single ExtensionPoint API
via a method reference, you can register it as follows. Note, however,
that the API must be a functional
interface.
public void registerExtensions(ExtensionPointRegistry registry) {
registry.register((BeforeEachExtensionPoint) this::beforeEach);
}
void beforeEach(TestExtensionContext context) {
/* ... */
}
ExtensionPoint,
ExtensionRegistrar| Modifier and Type | Interface and Description |
|---|---|
static class |
ExtensionPointRegistry.Position
Position specifies the position in which a registered
ExtensionPoint is applied with regard to all other registered
extension points of the same type. |
| Modifier and Type | Method and Description |
|---|---|
default void |
register(ExtensionPoint extensionPoint)
Register the supplied
ExtensionPoint using the
default position. |
void |
register(ExtensionPoint extensionPoint,
ExtensionPointRegistry.Position position)
Register the supplied
ExtensionPoint using the supplied
ExtensionPointRegistry.Position. |
default void register(ExtensionPoint extensionPoint)
ExtensionPoint using the
default position.
See the class-level Javadoc and user guide for examples.
extensionPoint - the extension point to registerregister(ExtensionPoint, Position)void register(ExtensionPoint extensionPoint, ExtensionPointRegistry.Position position)
ExtensionPoint using the supplied
ExtensionPointRegistry.Position.
See the class-level Javadoc and user guide for examples.
extensionPoint - the extension point to registerposition - the position in which the extension point
should be registeredregister(ExtensionPoint)