Skip to content

Commit

Permalink
Fix Sonar issues in deprecated RepeatProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
garyrussell committed Aug 23, 2019
1 parent 868979d commit 1fed5a7
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.junit.Before;
import org.junit.internal.runners.statements.RunAfters;
import org.junit.internal.runners.statements.RunBefores;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
Expand All @@ -47,15 +46,15 @@
* A JUnit method @Rule that looks at Spring repeat annotations on methods and executes the test multiple times
* (without re-initializing the test case if necessary). To avoid re-initializing use the {@link #isInitialized()}
* method to protect the @Before and @After methods.
* @deprecated in favor of JUnit 5 {@link RepeatedTest}.
* @deprecated in favor of JUnit 5 {@link org.junit.jupiter.api.RepeatedTest}.
*
* @author Dave Syer
*
*/
@Deprecated
public class RepeatProcessor implements MethodRule {

private static final Log logger = LogFactory.getLog(RepeatProcessor.class);
private static final Log LOGGER = LogFactory.getLog(RepeatProcessor.class);

private final int concurrency;

Expand Down Expand Up @@ -95,7 +94,7 @@ public void evaluate() throws Throwable {
try {
base.evaluate();
}
catch (Throwable t) {
catch (Throwable t) { // NOSONAR
throw new IllegalStateException(
"Failed on iteration: " + i + " of " + repeats + " (started at 0)", t);
}
Expand All @@ -107,7 +106,7 @@ public void evaluate() throws Throwable {
}
};
}
return new Statement() {
return new Statement() { // NOSONAR
@Override
public void evaluate() throws Throwable {
List<Future<Boolean>> results = new ArrayList<Future<Boolean>>();
Expand All @@ -122,7 +121,7 @@ public Boolean call() {
try {
base.evaluate();
}
catch (Throwable t) {
catch (Throwable t) { // NOSONAR
throw new IllegalStateException("Failed on iteration: " + count, t);
}
return true;
Expand All @@ -147,15 +146,15 @@ private void finalizeIfNecessary(Object target) {
List<FrameworkMethod> afters = new TestClass(target.getClass()).getAnnotatedMethods(After.class);
try {
if (!afters.isEmpty()) {
logger.debug("Running @After methods");
LOGGER.debug("Running @After methods");
try {
new RunAfters(new Statement() {
@Override
public void evaluate() {
}
}, afters, target).evaluate();
}
catch (Throwable e) {
catch (Throwable e) { // NOSONAR
fail("Unexpected throwable " + e);
}
}
Expand All @@ -169,15 +168,15 @@ private void initializeIfNecessary(Object target) {
TestClass testClass = new TestClass(target.getClass());
List<FrameworkMethod> befores = testClass.getAnnotatedMethods(Before.class);
if (!befores.isEmpty()) {
logger.debug("Running @Before methods");
LOGGER.debug("Running @Before methods");
try {
new RunBefores(new Statement() {
@Override
public void evaluate() {
}
}, befores, target).evaluate();
}
catch (Throwable e) {
catch (Throwable e) { // NOSONAR
fail("Unexpected throwable " + e);
}
this.initialized = true;
Expand Down

0 comments on commit 1fed5a7

Please sign in to comment.