Skip to content

Commit

Permalink
Fix minor style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kcooney committed Apr 16, 2017
1 parent 066e1d6 commit 45064f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/junit/runners/Parameterized.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ protected void collectInitializationErrors(List<Throwable> errors) {
validatePublicStaticVoidMethods(Parameterized.AfterParam.class, errors);
}

private void validatePublicStaticVoidMethods(Class<? extends Annotation> annotation,
List<Throwable> errors) {
final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
private void validatePublicStaticVoidMethods(
Class<? extends Annotation> annotation, List<Throwable> errors) {
List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
for (FrameworkMethod eachTestMethod : methods) {
eachTestMethod.validatePublicVoid(true, errors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ protected void validateFields(List<Throwable> errors) {
}

@Override
protected Statement classBlock(final RunNotifier notifier) {
protected Statement classBlock(RunNotifier notifier) {
Statement statement = childrenInvoker(notifier);
statement = withBeforeParams(statement);
statement = withAfterParams(statement);
return statement;
}

private Statement withBeforeParams(Statement statement) {
final List<FrameworkMethod> befores = getTestClass()
List<FrameworkMethod> befores = getTestClass()
.getAnnotatedMethods(Parameterized.BeforeParam.class);
return befores.isEmpty() ? statement : new RunBeforeParams(statement, befores);
}
Expand All @@ -162,15 +162,16 @@ private class RunBeforeParams extends Statement {
@Override
public void evaluate() throws Throwable {
for (FrameworkMethod before : befores) {
final int paramCount = before.getMethod().getParameterTypes().length;
before.invokeExplosively(null, paramCount == 0 ? (Object[]) null : parameters);
int paramCount = before.getMethod().getParameterTypes().length;
before.invokeExplosively(
null, paramCount == 0 ? (Object[]) null : parameters);
}
next.evaluate();
}
}

private Statement withAfterParams(Statement statement) {
final List<FrameworkMethod> afters = getTestClass()
List<FrameworkMethod> afters = getTestClass()
.getAnnotatedMethods(Parameterized.AfterParam.class);
return afters.isEmpty() ? statement : new RunAfterParams(statement, afters);
}
Expand All @@ -186,16 +187,17 @@ private class RunAfterParams extends Statement {

@Override
public void evaluate() throws Throwable {
final List<Throwable> errors = new ArrayList<Throwable>();
List<Throwable> errors = new ArrayList<Throwable>();
try {
next.evaluate();
} catch (Throwable e) {
errors.add(e);
} finally {
for (FrameworkMethod each : afters) {
try {
final int paramCount = each.getMethod().getParameterTypes().length;
each.invokeExplosively(null, paramCount == 0 ? (Object[]) null : parameters);
int paramCount = each.getMethod().getParameterTypes().length;
each.invokeExplosively(
null, paramCount == 0 ? (Object[]) null : parameters);
} catch (Throwable e) {
errors.add(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void second() {
@Test
public void beforeParamAndAfterParamAreRun() {
fLog = "";
final Result result = JUnitCore.runClasses(BeforeParamAndAfterParam.class);
Result result = JUnitCore.runClasses(BeforeParamAndAfterParam.class);
assertEquals(0, result.getFailureCount());
assertEquals("beforeClass before(A) first(A) second(A) afterParam "
+ "before(B) first(B) second(B) afterParam afterClass ", fLog);
Expand Down Expand Up @@ -341,7 +341,7 @@ public void test() {
@Test
public void beforeParamAndAfterParamValidation() {
fLog = "";
final Result result = JUnitCore.runClasses(BeforeParamAndAfterParamError.class);
Result result = JUnitCore.runClasses(BeforeParamAndAfterParamError.class);
assertEquals(1, result.getFailureCount());
assertThat(result.getFailures().get(0).getMessage(), containsString("beforeParam() should be static"));
assertThat(result.getFailures().get(0).getMessage(), containsString("afterParam() should be public"));
Expand Down Expand Up @@ -581,4 +581,4 @@ public void usesParametersRunnerFactoryThatWasSpecifiedByAnnotationInSuperClass(
UseParameterizedFactoryTest.class,
"Called ExceptionThrowingRunnerFactory.");
}
}
}

0 comments on commit 45064f7

Please sign in to comment.