Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Merdes authored and Matthias Merdes committed Nov 18, 2016
1 parent 6066569 commit 7b25a68
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>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.
*
* <p>However, if you intend to develop a <em>new</em> extension for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<? extends TestRule> adapteeClass;

Expand All @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
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;

@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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

Expand Down

0 comments on commit 7b25a68

Please sign in to comment.