From 7b25a68580a85821109822c738a2dc3543e79b46 Mon Sep 17 00:00:00 2001 From: Matthias Merdes Date: Fri, 18 Nov 2016 17:06:41 +0100 Subject: [PATCH] Polishing #433 --- .../jupiter/migrationsupport/rules/VerifierSupport.java | 8 ++------ .../rules/adapter/AbstractTestRuleAdapter.java | 8 +++++--- .../migrationsupport/rules/member/RuleAnnotatedField.java | 8 +++++--- .../LauncherBasedEnableRuleMigrationSupportTests.java | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/VerifierSupport.java b/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/VerifierSupport.java index 78716aeb3cd1..3818956a327c 100644 --- a/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/VerifierSupport.java +++ b/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/VerifierSupport.java @@ -24,17 +24,13 @@ import org.junit.rules.TestRule; import org.junit.rules.Verifier; -//TODO: doku auf verifier umstellen -//TODO: doku auf verifier umstellen -//TODO: doku auf verifier umstellen - /** * This {@code Extension} provides native support for subclasses of - * the {@code ExternalResource} rule from JUnit 4. + * the {@code Verifier} rule from JUnit 4. * {@code Rule}-annotated fields as well as methods are supported. *

By using this class-level extension on a test class such - * {@code ExternalResource} implementations in legacy code bases + * {@code Verifier} implementations in legacy code bases * can be left unchanged including the JUnit 4 rule import statements. * *

However, if you intend to develop a new extension for diff --git a/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/adapter/AbstractTestRuleAdapter.java b/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/adapter/AbstractTestRuleAdapter.java index 57754b216d91..cde0fc9be097 100644 --- a/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/adapter/AbstractTestRuleAdapter.java +++ b/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/adapter/AbstractTestRuleAdapter.java @@ -13,6 +13,7 @@ import static org.junit.platform.commons.meta.API.Usage.Internal; import java.lang.reflect.Method; +import java.util.logging.Logger; import org.junit.jupiter.migrationsupport.rules.member.RuleAnnotatedMember; import org.junit.platform.commons.meta.API; @@ -22,6 +23,8 @@ @API(Internal) public abstract class AbstractTestRuleAdapter implements GenericBeforeAndAfterAdvice { + private static final Logger LOG = Logger.getLogger(AbstractTestRuleAdapter.class.getName()); + protected final TestRule target; protected final Class adapteeClass; @@ -43,9 +46,8 @@ protected void executeMethod(String name) { method.setAccessible(true); ReflectionUtils.invokeMethod(method, target); } - catch (NoSuchMethodException | SecurityException e) { - // TODO: decide whether this should be logged - e.printStackTrace(); + catch (NoSuchMethodException | SecurityException exception) { + LOG.warning(exception.getMessage()); } } diff --git a/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/member/RuleAnnotatedField.java b/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/member/RuleAnnotatedField.java index 9db7dd801286..e0ea33d702a6 100644 --- a/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/member/RuleAnnotatedField.java +++ b/junit-jupiter-migration-support/src/main/java/org/junit/jupiter/migrationsupport/rules/member/RuleAnnotatedField.java @@ -13,6 +13,7 @@ import static org.junit.platform.commons.meta.API.Usage.Internal; import java.lang.reflect.Field; +import java.util.logging.Logger; import org.junit.platform.commons.meta.API; import org.junit.rules.TestRule; @@ -20,14 +21,15 @@ @API(Internal) public class RuleAnnotatedField extends AbstractRuleAnnotatedMember { + private static final Logger LOG = Logger.getLogger(RuleAnnotatedField.class.getName()); + public RuleAnnotatedField(Object testInstance, Field testRuleField) { try { testRuleField.setAccessible(true); this.testRuleInstance = (TestRule) testRuleField.get(testInstance); } - catch (IllegalAccessException e) { - // TODO: decide whether this should be logged - e.printStackTrace(); + catch (IllegalAccessException exception) { + LOG.warning(exception.getMessage()); } } diff --git a/junit-jupiter-migration-support/src/test/java/org/junit/jupiter/migrationsupport/rules/LauncherBasedEnableRuleMigrationSupportTests.java b/junit-jupiter-migration-support/src/test/java/org/junit/jupiter/migrationsupport/rules/LauncherBasedEnableRuleMigrationSupportTests.java index 516241797404..1a7573f867fb 100644 --- a/junit-jupiter-migration-support/src/test/java/org/junit/jupiter/migrationsupport/rules/LauncherBasedEnableRuleMigrationSupportTests.java +++ b/junit-jupiter-migration-support/src/test/java/org/junit/jupiter/migrationsupport/rules/LauncherBasedEnableRuleMigrationSupportTests.java @@ -61,18 +61,18 @@ public void verifierSupportForErrorCollectorFieldFailsTheTest() { private final JupiterTestEngine engine = new JupiterTestEngine(); - protected ExecutionEventRecorder executeTestsForClass(Class testClass) { + private ExecutionEventRecorder executeTestsForClass(Class testClass) { return executeTests(request().selectors(selectClass(testClass)).build()); } - protected ExecutionEventRecorder executeTests(LauncherDiscoveryRequest request) { + private ExecutionEventRecorder executeTests(LauncherDiscoveryRequest request) { TestDescriptor testDescriptor = discoverTests(request); ExecutionEventRecorder eventRecorder = new ExecutionEventRecorder(); engine.execute(new ExecutionRequest(testDescriptor, eventRecorder, request.getConfigurationParameters())); return eventRecorder; } - protected TestDescriptor discoverTests(LauncherDiscoveryRequest request) { + private TestDescriptor discoverTests(LauncherDiscoveryRequest request) { return engine.discover(request, UniqueId.forEngine(engine.getId())); }