From 89d3b94731296e3d9d5437901f63630f20ab7af8 Mon Sep 17 00:00:00 2001 From: Matthias Merdes Date: Fri, 11 Mar 2016 21:46:35 +0100 Subject: [PATCH] #169: fixed scope --- .../gen5/adapter/UglyExternalResourceAdapter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/junit4-engine/src/main/java/org/junit/gen5/adapter/UglyExternalResourceAdapter.java b/junit4-engine/src/main/java/org/junit/gen5/adapter/UglyExternalResourceAdapter.java index 04ed80f13389..7fbae2c7407a 100644 --- a/junit4-engine/src/main/java/org/junit/gen5/adapter/UglyExternalResourceAdapter.java +++ b/junit4-engine/src/main/java/org/junit/gen5/adapter/UglyExternalResourceAdapter.java @@ -12,28 +12,29 @@ import java.lang.reflect.Method; -import org.junit.gen5.api.extension.AfterAllExtensionPoint; -import org.junit.gen5.api.extension.BeforeAllExtensionPoint; -import org.junit.gen5.api.extension.ContainerExtensionContext; +import org.junit.gen5.api.extension.*; import org.junit.gen5.commons.util.ReflectionUtils; import org.junit.rules.ExternalResource; // very early thoughts - please do not polish yet :) -public class UglyExternalResourceAdapter implements BeforeAllExtensionPoint, AfterAllExtensionPoint { +public class UglyExternalResourceAdapter implements BeforeEachExtensionPoint, AfterEachExtensionPoint { ExternalResource externalResource; @Override - public void beforeAll(ContainerExtensionContext context) throws Exception { + public void beforeEach(TestExtensionContext context) throws Exception { this.findAndInvokeMethod("before"); } @Override - public void afterAll(ContainerExtensionContext context) throws Exception { + public void afterEach(TestExtensionContext context) throws Exception { this.findAndInvokeMethod("after"); } + + + //exception handling? private void findAndInvokeMethod(String name) throws NoSuchMethodException { Method method = this.findMethod(name); @@ -45,4 +46,5 @@ private Method findMethod(String name) throws NoSuchMethodException { return this.externalResource.getClass().getMethod(name); } + }