Skip to content

Commit

Permalink
Rename ExtensionRegistry to ExtensionPointRegistry
Browse files Browse the repository at this point in the history
Issue: #112
  • Loading branch information
sbrannen committed Jan 15, 2016
1 parent 41cdb1e commit 7187a52
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 47 deletions.
Expand Up @@ -26,8 +26,8 @@
import org.junit.gen5.api.extension.ContainerExtensionContext;
import org.junit.gen5.api.extension.ExtendWith;
import org.junit.gen5.api.extension.ExtensionPoint.Position;
import org.junit.gen5.api.extension.ExtensionPointRegistry;
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.engine.DiscoveryRequest;
import org.junit.gen5.engine.ExecutionEventRecorder;

Expand Down Expand Up @@ -92,7 +92,7 @@ void firstTest() {
private static class InnermostAndOutermost implements ExtensionRegistrar {

@Override
public void registerExtensions(ExtensionRegistry registry) {
public void registerExtensions(ExtensionPointRegistry registry) {
registry.register(this::innermostBefore, BeforeAllExtensionPoint.class, Position.INNERMOST);
registry.register(this::innermostAfter, AfterAllExtensionPoint.class, Position.INNERMOST);
registry.register(this::outermostBefore, BeforeAllExtensionPoint.class, Position.OUTERMOST);
Expand Down
Expand Up @@ -26,8 +26,8 @@
import org.junit.gen5.api.extension.BeforeEachExtensionPoint;
import org.junit.gen5.api.extension.ExtendWith;
import org.junit.gen5.api.extension.ExtensionPoint.Position;
import org.junit.gen5.api.extension.ExtensionPointRegistry;
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.api.extension.TestExtensionContext;
import org.junit.gen5.engine.DiscoveryRequest;
import org.junit.gen5.engine.ExecutionEventRecorder;
Expand Down Expand Up @@ -137,7 +137,7 @@ void afterInnerMethod() {
private static class InnermostAndOutermost implements ExtensionRegistrar {

@Override
public void registerExtensions(ExtensionRegistry registry) {
public void registerExtensions(ExtensionPointRegistry registry) {
registry.register(this::innermostBefore, BeforeEachExtensionPoint.class, Position.INNERMOST);
registry.register(this::innermostAfter, AfterEachExtensionPoint.class, Position.INNERMOST);
registry.register(this::outermostBefore, BeforeEachExtensionPoint.class, Position.OUTERMOST);
Expand Down
Expand Up @@ -24,8 +24,8 @@
import org.junit.gen5.api.extension.Extension;
import org.junit.gen5.api.extension.ExtensionPoint;
import org.junit.gen5.api.extension.ExtensionPoint.Position;
import org.junit.gen5.api.extension.ExtensionPointRegistry;
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.api.extension.MethodParameterResolver;
import org.junit.gen5.api.extension.TestExecutionCondition;
import org.junit.gen5.engine.junit5.extension.DisabledCondition;
Expand Down Expand Up @@ -228,7 +228,7 @@ public void doMore() {
class MyExtensionRegistrar implements ExtensionRegistrar {

@Override
public void registerExtensions(ExtensionRegistry registry) {
public void registerExtensions(ExtensionPointRegistry registry) {
registry.register(this::doNothing, MyExtensionPoint.class);
registry.register(this::doMore, AnotherExtensionPoint.class);
}
Expand Down
@@ -0,0 +1,49 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.junit.gen5.api.extension;

import org.junit.gen5.api.extension.ExtensionPoint.Position;

/**
* A registry for {@link ExtensionPoint} implementations which can be
* populated via an {@link ExtensionRegistrar}.
*
* @since 5.0
* @see ExtensionPoint
* @see ExtensionRegistrar
*/
public interface ExtensionPointRegistry {

/**
* Register an {@link ExtensionPoint} of the specified type using the
* {@linkplain Position#DEFAULT default position}.
*
* @param extensionPoint the extension point to register
* @param extensionPointType the type of extension point to register
* @see #register(ExtensionPoint, Class, Position)
*/
default <E extends ExtensionPoint> void register(E extensionPoint, Class<E> extensionPointType) {
register(extensionPoint, extensionPointType, Position.DEFAULT);
}

/**
* Register an {@link ExtensionPoint} of the specified type using the
* supplied {@link Position}.
*
* @param extensionPoint the extension point to register
* @param extensionPointType the type of extension point to register
* @param position the position in which the extension point
* should be registered
* @see #register(ExtensionPoint, Class)
*/
<E extends ExtensionPoint> void register(E extensionPoint, Class<E> extensionPointType, Position position);

}
Expand Up @@ -13,7 +13,7 @@
/**
* Interface to be implemented by {@linkplain Extension extensions} that
* wish to programmatically register {@link ExtensionPoint} implementations
* in the {@link ExtensionRegistry} &mdash; for example, if a
* in the {@link ExtensionPointRegistry} &mdash; for example, if a
* {@link ExtensionPoint.Position Position} other than
* {@link ExtensionPoint.Position#DEFAULT DEFAULT} is desired.
*
Expand All @@ -23,6 +23,6 @@
*/
public interface ExtensionRegistrar extends Extension {

void registerExtensions(ExtensionRegistry registry);
void registerExtensions(ExtensionPointRegistry registry);

}

This file was deleted.

Expand Up @@ -22,12 +22,12 @@
import org.junit.gen5.api.extension.Extension;
import org.junit.gen5.api.extension.ExtensionPoint;
import org.junit.gen5.api.extension.ExtensionPoint.Position;
import org.junit.gen5.api.extension.ExtensionPointRegistry;
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.commons.util.ReflectionUtils;
import org.junit.gen5.engine.junit5.extension.*;
import org.junit.gen5.engine.junit5.extension.DisabledCondition;
import org.junit.gen5.engine.junit5.extension.TestInfoParameterResolver;
import org.junit.gen5.engine.junit5.extension.TestReporterParameterResolver;

/**
* A {@code TestExtensionRegistry} holds all registered extensions (i.e.
Expand All @@ -39,7 +39,7 @@
* thereby all its ancestors.
*
* <p>Do not confuse this engine-specific {@code TestExtensionRegistry} with
* the {@link ExtensionRegistry} which is used by an {@link ExtensionRegistrar}.
* the {@link ExtensionPointRegistry} which is used by an {@link ExtensionRegistrar}.
*
* @since 5.0
*/
Expand Down Expand Up @@ -80,7 +80,7 @@ static List<Class<? extends Extension>> getDefaultExtensionTypes() {

private final List<RegisteredExtensionPoint<?>> registeredExtensionPoints = new ArrayList<>();

private final ExtensionRegistry delegatingExtensionRegistry = new DelegatingExtensionRegistry();
private final ExtensionPointRegistry delegatingExtensionPointRegistry = new DelegatingExtensionPointRegistry();

private final Optional<TestExtensionRegistry> parent;

Expand Down Expand Up @@ -190,17 +190,17 @@ void registerExtensionPoint(ExtensionPoint extension, Position position) {
private void registerExtensionPointsFromRegistrar(Extension extension) {
if (extension instanceof ExtensionRegistrar) {
ExtensionRegistrar extensionRegistrar = (ExtensionRegistrar) extension;
extensionRegistrar.registerExtensions(this.delegatingExtensionRegistry);
extensionRegistrar.registerExtensions(this.delegatingExtensionPointRegistry);
}
}

/**
* {@link ExtensionRegistry} which internally delegates to the enclosing
* {@link ExtensionPointRegistry} which internally delegates to the enclosing
* {@link TestExtensionRegistry}: used in order to allow an
* {@link ExtensionRegistrar} to populate a {@link TestExtensionRegistry}
* via the {@code ExtensionRegistry} API.
*/
private class DelegatingExtensionRegistry implements ExtensionRegistry {
private class DelegatingExtensionPointRegistry implements ExtensionPointRegistry {

@Override
public <E extends ExtensionPoint> void register(E extension, Class<E> extensionPointType, Position position) {
Expand Down
Expand Up @@ -15,8 +15,8 @@
import org.junit.gen5.api.extension.AfterEachExtensionPoint;
import org.junit.gen5.api.extension.BeforeEachExtensionPoint;
import org.junit.gen5.api.extension.ExtensionPoint;
import org.junit.gen5.api.extension.ExtensionPointRegistry;
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.api.extension.TestExtensionContext;

/**
Expand All @@ -30,7 +30,7 @@ public class TimingExtension implements ExtensionRegistrar {
private static final String TIMING_KEY_PREFIX = "TIMING:";

@Override
public void registerExtensions(ExtensionRegistry registry) {
public void registerExtensions(ExtensionPointRegistry registry) {
registry.register(this::beforeEach, BeforeEachExtensionPoint.class, ExtensionPoint.Position.INNERMOST);
registry.register(this::afterEach, AfterEachExtensionPoint.class, ExtensionPoint.Position.INNERMOST);
}
Expand Down

0 comments on commit 7187a52

Please sign in to comment.