diff --git a/CODING_STYLE.txt b/CODING_STYLE.txt new file mode 100644 index 000000000000..d9600afdf5a6 --- /dev/null +++ b/CODING_STYLE.txt @@ -0,0 +1,3 @@ +JUnit project uses the Google Java Style (http://google-styleguide.googlecode.com/svn/trunk/javaguide.html) for all new +code (under org.junit.*). Legacy code (under junit.*) used the legacy guide specified in LEGACY_CODING_STYLE.txt in the +project root. diff --git a/CODING_STYLE b/LEGACY_CODING_STYLE.txt similarity index 100% rename from CODING_STYLE rename to LEGACY_CODING_STYLE.txt diff --git a/src/main/java/org/junit/experimental/ParallelComputer.java b/src/main/java/org/junit/experimental/ParallelComputer.java index 96271e7defd4..97da0f759f48 100644 --- a/src/main/java/org/junit/experimental/ParallelComputer.java +++ b/src/main/java/org/junit/experimental/ParallelComputer.java @@ -12,13 +12,13 @@ import org.junit.runners.model.RunnerScheduler; public class ParallelComputer extends Computer { - private final boolean fClasses; + private final boolean classes; - private final boolean fMethods; + private final boolean methods; public ParallelComputer(boolean classes, boolean methods) { - fClasses = classes; - fMethods = methods; + this.classes = classes; + this.methods = methods; } public static Computer classes() { @@ -55,13 +55,13 @@ public void finished() { public Runner getSuite(RunnerBuilder builder, java.lang.Class[] classes) throws InitializationError { Runner suite = super.getSuite(builder, classes); - return fClasses ? parallelize(suite) : suite; + return this.classes ? parallelize(suite) : suite; } @Override protected Runner getRunner(RunnerBuilder builder, Class testClass) throws Throwable { Runner runner = super.getRunner(builder, testClass); - return fMethods ? parallelize(runner) : runner; + return methods ? parallelize(runner) : runner; } } diff --git a/src/main/java/org/junit/experimental/categories/Categories.java b/src/main/java/org/junit/experimental/categories/Categories.java index c6c18d996761..b41e701e58bc 100644 --- a/src/main/java/org/junit/experimental/categories/Categories.java +++ b/src/main/java/org/junit/experimental/categories/Categories.java @@ -115,10 +115,10 @@ public class Categories extends Suite { } public static class CategoryFilter extends Filter { - private final Set> fIncluded; - private final Set> fExcluded; - private final boolean fIncludedAny; - private final boolean fExcludedAny; + private final Set> included; + private final Set> excluded; + private final boolean includedAny; + private final boolean excludedAny; public static CategoryFilter include(boolean matchAny, Class... categories) { if (hasNull(categories)) { @@ -157,10 +157,10 @@ public static CategoryFilter categoryFilter(boolean matchAnyInclusions, Set> includes, boolean matchAnyExcludes, Set> excludes) { - fIncludedAny= matchAnyIncludes; - fExcludedAny= matchAnyExcludes; - fIncluded= copyAndRefine(includes); - fExcluded= copyAndRefine(excludes); + includedAny = matchAnyIncludes; + excludedAny = matchAnyExcludes; + included = copyAndRefine(includes); + excluded = copyAndRefine(excludes); } /** @@ -186,9 +186,9 @@ public String describe() { */ @Override public String toString() { StringBuilder description= new StringBuilder("categories ") - .append(fIncluded.isEmpty() ? "[all]" : fIncluded); - if (!fExcluded.isEmpty()) { - description.append(" - ").append(fExcluded); + .append(included.isEmpty() ? "[all]" : included); + if (!excluded.isEmpty()) { + description.append(" - ").append(excluded); } return description.toString(); } @@ -213,29 +213,29 @@ private boolean hasCorrectCategoryAnnotation(Description description) { // If a child has no categories, immediately return. if (childCategories.isEmpty()) { - return fIncluded.isEmpty(); + return included.isEmpty(); } - if (!fExcluded.isEmpty()) { - if (fExcludedAny) { - if (matchesAnyParentCategories(childCategories, fExcluded)) { + if (!excluded.isEmpty()) { + if (excludedAny) { + if (matchesAnyParentCategories(childCategories, excluded)) { return false; } } else { - if (matchesAllParentCategories(childCategories, fExcluded)) { + if (matchesAllParentCategories(childCategories, excluded)) { return false; } } } - if (fIncluded.isEmpty()) { + if (included.isEmpty()) { // Couldn't be excluded, and with no suite's included categories treated as should run. return true; } else { - if (fIncludedAny) { - return matchesAnyParentCategories(childCategories, fIncluded); + if (includedAny) { + return matchesAnyParentCategories(childCategories, included); } else { - return matchesAllParentCategories(childCategories, fIncluded); + return matchesAllParentCategories(childCategories, included); } } } diff --git a/src/main/java/org/junit/experimental/max/MaxCore.java b/src/main/java/org/junit/experimental/max/MaxCore.java index 8e55a9dc3f66..625cade5b1ea 100644 --- a/src/main/java/org/junit/experimental/max/MaxCore.java +++ b/src/main/java/org/junit/experimental/max/MaxCore.java @@ -49,10 +49,10 @@ public static MaxCore storedLocally(File storedResults) { return new MaxCore(storedResults); } - private final MaxHistory fHistory; + private final MaxHistory history; private MaxCore(File storedResults) { - fHistory = MaxHistory.forFolder(storedResults); + history = MaxHistory.forFolder(storedResults); } /** @@ -85,7 +85,7 @@ public Result run(Request request) { * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Request request, JUnitCore core) { - core.addListener(fHistory.listener()); + core.addListener(history.listener()); return core.run(sortRequest(request).getRunner()); } @@ -98,7 +98,7 @@ public Request sortRequest(Request request) { return request; } List leaves = findLeaves(request); - Collections.sort(leaves, fHistory.testComparator()); + Collections.sort(leaves, history.testComparator()); return constructLeafRequest(leaves); } diff --git a/src/main/java/org/junit/experimental/max/MaxHistory.java b/src/main/java/org/junit/experimental/max/MaxHistory.java index 94d20c6cf610..92bd70ee0625 100644 --- a/src/main/java/org/junit/experimental/max/MaxHistory.java +++ b/src/main/java/org/junit/experimental/max/MaxHistory.java @@ -61,41 +61,41 @@ private static MaxHistory readHistory(File storedResults) } } - private final Map fDurations = new HashMap(); + private final Map durations = new HashMap(); - private final Map fFailureTimestamps = new HashMap(); + private final Map failureTimestamps = new HashMap(); - private final File fHistoryStore; + private final File historyStore; private MaxHistory(File storedResults) { - fHistoryStore = storedResults; + historyStore = storedResults; } private void save() throws IOException { ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream( - fHistoryStore)); + historyStore)); stream.writeObject(this); stream.close(); } Long getFailureTimestamp(Description key) { - return fFailureTimestamps.get(key.toString()); + return failureTimestamps.get(key.toString()); } void putTestFailureTimestamp(Description key, long end) { - fFailureTimestamps.put(key.toString(), end); + failureTimestamps.put(key.toString(), end); } boolean isNewTest(Description key) { - return !fDurations.containsKey(key.toString()); + return !durations.containsKey(key.toString()); } Long getTestDuration(Description key) { - return fDurations.get(key.toString()); + return durations.get(key.toString()); } void putTestDuration(Description description, long duration) { - fDurations.put(description.toString(), duration); + durations.put(description.toString(), duration); } private final class RememberingListener extends RunListener { diff --git a/src/main/java/org/junit/experimental/theories/Theories.java b/src/main/java/org/junit/experimental/theories/Theories.java index 7fe02327f534..6c80cc10f38d 100644 --- a/src/main/java/org/junit/experimental/theories/Theories.java +++ b/src/main/java/org/junit/experimental/theories/Theories.java @@ -118,27 +118,27 @@ public Statement methodBlock(final FrameworkMethod method) { public static class TheoryAnchor extends Statement { private int successes = 0; - private FrameworkMethod fTestMethod; - private TestClass fTestClass; + private final FrameworkMethod testMethod; + private final TestClass testClass; private List fInvalidParameters = new ArrayList(); - public TheoryAnchor(FrameworkMethod method, TestClass testClass) { - fTestMethod = method; - fTestClass = testClass; + public TheoryAnchor(FrameworkMethod testMethod, TestClass testClass) { + this.testMethod = testMethod; + this.testClass = testClass; } private TestClass getTestClass() { - return fTestClass; + return testClass; } @Override public void evaluate() throws Throwable { runWithAssignment(Assignments.allUnassigned( - fTestMethod.getMethod(), getTestClass())); + testMethod.getMethod(), getTestClass())); //if this test method is not annotated with Theory, then no successes is a valid case - boolean hasTheoryAnnotation = fTestMethod.getAnnotation(Theory.class) != null; + boolean hasTheoryAnnotation = testMethod.getAnnotation(Theory.class) != null; if (successes == 0 && hasTheoryAnnotation) { Assert .fail("Never found parameters that satisfied method assumptions. Violated assumptions: " @@ -207,7 +207,7 @@ public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(params); } - }.methodBlock(fTestMethod).evaluate(); + }.methodBlock(testMethod).evaluate(); } private Statement methodCompletesWithParameters( @@ -235,12 +235,12 @@ protected void reportParameterizedError(Throwable e, Object... params) if (params.length == 0) { throw e; } - throw new ParameterizedAssertionError(e, fTestMethod.getName(), + throw new ParameterizedAssertionError(e, testMethod.getName(), params); } private boolean nullsOk() { - Theory annotation = fTestMethod.getMethod().getAnnotation( + Theory annotation = testMethod.getMethod().getAnnotation( Theory.class); if (annotation == null) { return false; diff --git a/src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java b/src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java index 2e1a89f4b2cf..f15fb288e4a6 100644 --- a/src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java +++ b/src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java @@ -22,16 +22,16 @@ */ public class AllMembersSupplier extends ParameterSupplier { static class MethodParameterValue extends PotentialAssignment { - private final FrameworkMethod fMethod; + private final FrameworkMethod method; private MethodParameterValue(FrameworkMethod dataPointMethod) { - fMethod = dataPointMethod; + method = dataPointMethod; } @Override public Object getValue() throws CouldNotGenerateValueException { try { - return fMethod.invokeExplosively(null); + return method.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); @@ -39,7 +39,7 @@ public Object getValue() throws CouldNotGenerateValueException { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable throwable) { - DataPoint annotation = fMethod.getAnnotation(DataPoint.class); + DataPoint annotation = method.getAnnotation(DataPoint.class); Assume.assumeTrue(annotation == null || !isAssignableToAnyOf(annotation.ignoredExceptions(), throwable)); throw new CouldNotGenerateValueException(throwable); @@ -48,17 +48,17 @@ public Object getValue() throws CouldNotGenerateValueException { @Override public String getDescription() throws CouldNotGenerateValueException { - return fMethod.getName(); + return method.getName(); } } - private final TestClass fClass; + private final TestClass clazz; /** * Constructs a new supplier for {@code type} */ public AllMembersSupplier(TestClass type) { - fClass = type; + clazz = type; } @Override @@ -172,11 +172,11 @@ private static boolean isAssignableToAnyOf(Class[] typeArray, Object target) } protected Collection getDataPointsMethods(ParameterSignature sig) { - return fClass.getAnnotatedMethods(DataPoints.class); + return clazz.getAnnotatedMethods(DataPoints.class); } protected Collection getSingleDataPointFields(ParameterSignature sig) { - List fields = fClass.getAnnotatedFields(DataPoint.class); + List fields = clazz.getAnnotatedFields(DataPoint.class); Collection validFields = new ArrayList(); for (FrameworkField frameworkField : fields) { @@ -187,7 +187,7 @@ protected Collection getSingleDataPointFields(ParameterSignature sig) { } protected Collection getDataPointsFields(ParameterSignature sig) { - List fields = fClass.getAnnotatedFields(DataPoints.class); + List fields = clazz.getAnnotatedFields(DataPoints.class); Collection validFields = new ArrayList(); for (FrameworkField frameworkField : fields) { @@ -198,7 +198,7 @@ protected Collection getDataPointsFields(ParameterSignature sig) { } protected Collection getSingleDataPointMethods(ParameterSignature sig) { - return fClass.getAnnotatedMethods(DataPoint.class); + return clazz.getAnnotatedMethods(DataPoint.class); } } \ No newline at end of file diff --git a/src/main/java/org/junit/experimental/theories/internal/Assignments.java b/src/main/java/org/junit/experimental/theories/internal/Assignments.java index ee6c3a9ef1f9..a94c8a5e00b1 100644 --- a/src/main/java/org/junit/experimental/theories/internal/Assignments.java +++ b/src/main/java/org/junit/experimental/theories/internal/Assignments.java @@ -19,17 +19,17 @@ * parameters */ public class Assignments { - private List fAssigned; + private final List assigned; - private final List fUnassigned; + private final List unassigned; - private final TestClass fClass; + private final TestClass clazz; private Assignments(List assigned, - List unassigned, TestClass testClass) { - fUnassigned = unassigned; - fAssigned = assigned; - fClass = testClass; + List unassigned, TestClass clazz) { + this.unassigned = unassigned; + this.assigned = assigned; + this.clazz = clazz; } /** @@ -47,27 +47,27 @@ public static Assignments allUnassigned(Method testMethod, } public boolean isComplete() { - return fUnassigned.size() == 0; + return unassigned.size() == 0; } public ParameterSignature nextUnassigned() { - return fUnassigned.get(0); + return unassigned.get(0); } public Assignments assignNext(PotentialAssignment source) { List assigned = new ArrayList( - fAssigned); + this.assigned); assigned.add(source); - return new Assignments(assigned, fUnassigned.subList(1, - fUnassigned.size()), fClass); + return new Assignments(assigned, unassigned.subList(1, + unassigned.size()), clazz); } public Object[] getActualValues(int start, int stop) throws CouldNotGenerateValueException { Object[] values = new Object[stop - start]; for (int i = start; i < stop; i++) { - values[i - start] = fAssigned.get(i).getValue(); + values[i - start] = assigned.get(i).getValue(); } return values; } @@ -104,7 +104,7 @@ private ParameterSupplier getSupplier(ParameterSignature unassigned) if (annotation != null) { return buildParameterSupplierFromClass(annotation.value()); } else { - return new AllMembersSupplier(fClass); + return new AllMembersSupplier(clazz); } } @@ -116,7 +116,7 @@ private ParameterSupplier buildParameterSupplierFromClass( Class[] parameterTypes = constructor.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(TestClass.class)) { - return (ParameterSupplier) constructor.newInstance(fClass); + return (ParameterSupplier) constructor.newInstance(clazz); } } @@ -129,25 +129,25 @@ public Object[] getConstructorArguments() } public Object[] getMethodArguments() throws CouldNotGenerateValueException { - return getActualValues(getConstructorParameterCount(), fAssigned.size()); + return getActualValues(getConstructorParameterCount(), assigned.size()); } public Object[] getAllArguments() throws CouldNotGenerateValueException { - return getActualValues(0, fAssigned.size()); + return getActualValues(0, assigned.size()); } private int getConstructorParameterCount() { List signatures = ParameterSignature - .signatures(fClass.getOnlyConstructor()); + .signatures(clazz.getOnlyConstructor()); int constructorParameterCount = signatures.size(); return constructorParameterCount; } public Object[] getArgumentStrings(boolean nullsOk) throws CouldNotGenerateValueException { - Object[] values = new Object[fAssigned.size()]; + Object[] values = new Object[assigned.size()]; for (int i = 0; i < values.length; i++) { - values[i] = fAssigned.get(i).getDescription(); + values[i] = assigned.get(i).getDescription(); } return values; } diff --git a/src/main/java/org/junit/internal/ArrayComparisonFailure.java b/src/main/java/org/junit/internal/ArrayComparisonFailure.java index 1f2336cbb686..b524e0b53226 100644 --- a/src/main/java/org/junit/internal/ArrayComparisonFailure.java +++ b/src/main/java/org/junit/internal/ArrayComparisonFailure.java @@ -14,8 +14,8 @@ public class ArrayComparisonFailure extends AssertionError { private static final long serialVersionUID = 1L; - private List fIndices = new ArrayList(); - private final String fMessage; + private final List indices = new ArrayList(); + private final String message; /** * Construct a new ArrayComparisonFailure with an error text and the array's @@ -26,23 +26,23 @@ public class ArrayComparisonFailure extends AssertionError { * @see Assert#assertArrayEquals(String, Object[], Object[]) */ public ArrayComparisonFailure(String message, AssertionError cause, int index) { - fMessage = message; + this.message = message; initCause(cause); addDimension(index); } public void addDimension(int index) { - fIndices.add(0, index); + indices.add(0, index); } @Override public String getMessage() { StringBuilder sb = new StringBuilder(); - if (fMessage != null) { - sb.append(fMessage); + if (message != null) { + sb.append(message); } sb.append("arrays first differed at element "); - for (int each : fIndices) { + for (int each : indices) { sb.append("["); sb.append(each); sb.append("]"); diff --git a/src/main/java/org/junit/internal/AssumptionViolatedException.java b/src/main/java/org/junit/internal/AssumptionViolatedException.java index 8134aa631fdc..b1e364faf4c0 100644 --- a/src/main/java/org/junit/internal/AssumptionViolatedException.java +++ b/src/main/java/org/junit/internal/AssumptionViolatedException.java @@ -18,19 +18,19 @@ public class AssumptionViolatedException extends RuntimeException implements SelfDescribing { private static final long serialVersionUID = 2L; - private final String fAssumption; + private final String assumption; - private final boolean fValueMatcher; - private final Object fValue; + private final boolean valueMatcher; + private final Object value; - private final Matcher fMatcher; + private final Matcher matcher; public AssumptionViolatedException(String assumption, boolean valueMatcher, Object value, Matcher matcher) { super(value instanceof Throwable ? (Throwable) value : null); - fAssumption = assumption; - fValue = value; - fMatcher = matcher; - fValueMatcher = valueMatcher; + this.assumption = assumption; + this.value = value; + this.matcher = matcher; + this.valueMatcher = valueMatcher; } /** @@ -69,21 +69,21 @@ public String getMessage() { } public void describeTo(Description description) { - if (fAssumption != null) { - description.appendText(fAssumption); + if (assumption != null) { + description.appendText(assumption); } - if (fValueMatcher) { - if (fAssumption != null) { + if (valueMatcher) { + if (assumption != null) { description.appendText(": "); } description.appendText("got: "); - description.appendValue(fValue); + description.appendValue(value); - if (fMatcher != null) { + if (matcher != null) { description.appendText(", expected: "); - description.appendDescriptionOf(fMatcher); + description.appendDescriptionOf(matcher); } } } diff --git a/src/main/java/org/junit/internal/TextListener.java b/src/main/java/org/junit/internal/TextListener.java index 7bfe2d89b592..9aa56c75f5ec 100644 --- a/src/main/java/org/junit/internal/TextListener.java +++ b/src/main/java/org/junit/internal/TextListener.java @@ -11,14 +11,14 @@ public class TextListener extends RunListener { - private final PrintStream fWriter; + private final PrintStream writer; public TextListener(JUnitSystem system) { this(system.out()); } public TextListener(PrintStream writer) { - this.fWriter = writer; + this.writer = writer; } @Override @@ -30,17 +30,17 @@ public void testRunFinished(Result result) { @Override public void testStarted(Description description) { - fWriter.append('.'); + writer.append('.'); } @Override public void testFailure(Failure failure) { - fWriter.append('E'); + writer.append('E'); } @Override public void testIgnored(Description description) { - fWriter.append('I'); + writer.append('I'); } /* @@ -48,7 +48,7 @@ public void testIgnored(Description description) { */ private PrintStream getWriter() { - return fWriter; + return writer; } protected void printHeader(long runTime) { diff --git a/src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java b/src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java index de2125a582bc..d86ec950f655 100644 --- a/src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java +++ b/src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java @@ -7,10 +7,10 @@ import org.junit.runners.model.RunnerBuilder; public class AllDefaultPossibilitiesBuilder extends RunnerBuilder { - private final boolean fCanUseSuiteMethod; + private final boolean canUseSuiteMethod; public AllDefaultPossibilitiesBuilder(boolean canUseSuiteMethod) { - fCanUseSuiteMethod = canUseSuiteMethod; + this.canUseSuiteMethod = canUseSuiteMethod; } @Override @@ -48,7 +48,7 @@ protected IgnoredBuilder ignoredBuilder() { } protected RunnerBuilder suiteMethodBuilder() { - if (fCanUseSuiteMethod) { + if (canUseSuiteMethod) { return new SuiteMethodBuilder(); } return new NullBuilder(); diff --git a/src/main/java/org/junit/internal/builders/AnnotatedBuilder.java b/src/main/java/org/junit/internal/builders/AnnotatedBuilder.java index da3948b51a31..04d7a683652f 100644 --- a/src/main/java/org/junit/internal/builders/AnnotatedBuilder.java +++ b/src/main/java/org/junit/internal/builders/AnnotatedBuilder.java @@ -71,10 +71,10 @@ public class AnnotatedBuilder extends RunnerBuilder { private static final String CONSTRUCTOR_ERROR_FORMAT = "Custom runner class %s should have a public constructor with signature %s(Class testClass)"; - private final RunnerBuilder fSuiteBuilder; + private final RunnerBuilder suiteBuilder; public AnnotatedBuilder(RunnerBuilder suiteBuilder) { - fSuiteBuilder = suiteBuilder; + this.suiteBuilder = suiteBuilder; } @Override @@ -105,7 +105,7 @@ public Runner buildRunner(Class runnerClass, } catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, - RunnerBuilder.class).newInstance(testClass, fSuiteBuilder); + RunnerBuilder.class).newInstance(testClass, suiteBuilder); } catch (NoSuchMethodException e2) { String simpleName = runnerClass.getSimpleName(); throw new InitializationError(String.format( diff --git a/src/main/java/org/junit/internal/builders/IgnoredClassRunner.java b/src/main/java/org/junit/internal/builders/IgnoredClassRunner.java index d579012cf5fb..7c8926b7fb79 100644 --- a/src/main/java/org/junit/internal/builders/IgnoredClassRunner.java +++ b/src/main/java/org/junit/internal/builders/IgnoredClassRunner.java @@ -5,10 +5,10 @@ import org.junit.runner.notification.RunNotifier; public class IgnoredClassRunner extends Runner { - private final Class fTestClass; + private final Class clazz; public IgnoredClassRunner(Class testClass) { - fTestClass = testClass; + clazz = testClass; } @Override @@ -18,6 +18,6 @@ public void run(RunNotifier notifier) { @Override public Description getDescription() { - return Description.createSuiteDescription(fTestClass); + return Description.createSuiteDescription(clazz); } } \ No newline at end of file diff --git a/src/main/java/org/junit/internal/matchers/StacktracePrintingMatcher.java b/src/main/java/org/junit/internal/matchers/StacktracePrintingMatcher.java index 83589e47d951..5d45ba3d03af 100644 --- a/src/main/java/org/junit/internal/matchers/StacktracePrintingMatcher.java +++ b/src/main/java/org/junit/internal/matchers/StacktracePrintingMatcher.java @@ -14,24 +14,24 @@ public class StacktracePrintingMatcher extends org.hamcrest.TypeSafeMatcher { - private final Matcher fThrowableMatcher; + private final Matcher throwableMatcher; public StacktracePrintingMatcher(Matcher throwableMatcher) { - fThrowableMatcher = throwableMatcher; + this.throwableMatcher = throwableMatcher; } public void describeTo(Description description) { - fThrowableMatcher.describeTo(description); + throwableMatcher.describeTo(description); } @Override protected boolean matchesSafely(T item) { - return fThrowableMatcher.matches(item); + return throwableMatcher.matches(item); } @Override protected void describeMismatchSafely(T item, Description description) { - fThrowableMatcher.describeMismatch(item, description); + throwableMatcher.describeMismatch(item, description); description.appendText("\nStacktrace was: "); description.appendText(readStacktrace(item)); } diff --git a/src/main/java/org/junit/internal/matchers/ThrowableCauseMatcher.java b/src/main/java/org/junit/internal/matchers/ThrowableCauseMatcher.java index d4e1dec60b29..ecf349d70888 100644 --- a/src/main/java/org/junit/internal/matchers/ThrowableCauseMatcher.java +++ b/src/main/java/org/junit/internal/matchers/ThrowableCauseMatcher.java @@ -8,26 +8,26 @@ public class ThrowableCauseMatcher extends TypeSafeMatcher { - private final Matcher fMatcher; + private final Matcher matcher; public ThrowableCauseMatcher(Matcher matcher) { - fMatcher = matcher; + this.matcher = matcher; } public void describeTo(Description description) { description.appendText("exception with cause "); - description.appendDescriptionOf(fMatcher); + description.appendDescriptionOf(matcher); } @Override protected boolean matchesSafely(T item) { - return fMatcher.matches(item.getCause()); + return matcher.matches(item.getCause()); } @Override protected void describeMismatchSafely(T item, Description description) { description.appendText("cause "); - fMatcher.describeMismatch(item.getCause(), description); + matcher.describeMismatch(item.getCause(), description); } @Factory diff --git a/src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java b/src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java index 26436dc75b79..74386a862115 100644 --- a/src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java +++ b/src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java @@ -8,26 +8,26 @@ public class ThrowableMessageMatcher extends TypeSafeMatcher { - private final Matcher fMatcher; + private final Matcher matcher; public ThrowableMessageMatcher(Matcher matcher) { - fMatcher = matcher; + this.matcher = matcher; } public void describeTo(Description description) { description.appendText("exception with message "); - description.appendDescriptionOf(fMatcher); + description.appendDescriptionOf(matcher); } @Override protected boolean matchesSafely(T item) { - return fMatcher.matches(item.getMessage()); + return matcher.matches(item.getMessage()); } @Override protected void describeMismatchSafely(T item, Description description) { description.appendText("message "); - fMatcher.describeMismatch(item.getMessage(), description); + matcher.describeMismatch(item.getMessage(), description); } @Factory diff --git a/src/main/java/org/junit/internal/requests/ClassRequest.java b/src/main/java/org/junit/internal/requests/ClassRequest.java index af136e71ebc1..30a60fd0d8bc 100644 --- a/src/main/java/org/junit/internal/requests/ClassRequest.java +++ b/src/main/java/org/junit/internal/requests/ClassRequest.java @@ -5,14 +5,14 @@ import org.junit.runner.Runner; public class ClassRequest extends Request { - private final Object fRunnerLock = new Object(); - private final Class fTestClass; - private final boolean fCanUseSuiteMethod; - private volatile Runner fRunner; + private final Object runnerLock = new Object(); + private final Class testClass; + private final boolean canUseSuiteMethod; + private volatile Runner runner; public ClassRequest(Class testClass, boolean canUseSuiteMethod) { - fTestClass = testClass; - fCanUseSuiteMethod = canUseSuiteMethod; + this.testClass = testClass; + this.canUseSuiteMethod = canUseSuiteMethod; } public ClassRequest(Class testClass) { @@ -21,13 +21,13 @@ public ClassRequest(Class testClass) { @Override public Runner getRunner() { - if (fRunner == null) { - synchronized (fRunnerLock) { - if (fRunner == null) { - fRunner = new AllDefaultPossibilitiesBuilder(fCanUseSuiteMethod).safeRunnerForClass(fTestClass); + if (runner == null) { + synchronized (runnerLock) { + if (runner == null) { + runner = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod).safeRunnerForClass(testClass); } } } - return fRunner; + return runner; } } \ No newline at end of file diff --git a/src/main/java/org/junit/internal/requests/FilterRequest.java b/src/main/java/org/junit/internal/requests/FilterRequest.java index b5826bd4bfbe..4be7fb7f1e85 100644 --- a/src/main/java/org/junit/internal/requests/FilterRequest.java +++ b/src/main/java/org/junit/internal/requests/FilterRequest.java @@ -10,31 +10,31 @@ * A filtered {@link Request}. */ public final class FilterRequest extends Request { - private final Request fRequest; - private final Filter fFilter; + private final Request request; + private final Filter filter; /** * Creates a filtered Request * - * @param classRequest a {@link Request} describing your Tests + * @param request a {@link Request} describing your Tests * @param filter {@link Filter} to apply to the Tests described in - * classRequest + * request */ - public FilterRequest(Request classRequest, Filter filter) { - fRequest = classRequest; - fFilter = filter; + public FilterRequest(Request request, Filter filter) { + this.request = request; + this.filter = filter; } @Override public Runner getRunner() { try { - Runner runner = fRequest.getRunner(); - fFilter.apply(runner); + Runner runner = request.getRunner(); + filter.apply(runner); return runner; } catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String - .format("No tests found matching %s from %s", fFilter - .describe(), fRequest.toString()))); + .format("No tests found matching %s from %s", filter + .describe(), request.toString()))); } } } \ No newline at end of file diff --git a/src/main/java/org/junit/internal/requests/SortingRequest.java b/src/main/java/org/junit/internal/requests/SortingRequest.java index f4628d31f3f4..77061da27d5c 100644 --- a/src/main/java/org/junit/internal/requests/SortingRequest.java +++ b/src/main/java/org/junit/internal/requests/SortingRequest.java @@ -8,18 +8,18 @@ import org.junit.runner.manipulation.Sorter; public class SortingRequest extends Request { - private final Request fRequest; - private final Comparator fComparator; + private final Request request; + private final Comparator comparator; public SortingRequest(Request request, Comparator comparator) { - fRequest = request; - fComparator = comparator; + this.request = request; + this.comparator = comparator; } @Override public Runner getRunner() { - Runner runner = fRequest.getRunner(); - new Sorter(fComparator).apply(runner); + Runner runner = request.getRunner(); + new Sorter(comparator).apply(runner); return runner; } } diff --git a/src/main/java/org/junit/internal/runners/ErrorReportingRunner.java b/src/main/java/org/junit/internal/runners/ErrorReportingRunner.java index 9c255fac3975..1d32bebe1f09 100644 --- a/src/main/java/org/junit/internal/runners/ErrorReportingRunner.java +++ b/src/main/java/org/junit/internal/runners/ErrorReportingRunner.java @@ -11,22 +11,22 @@ import org.junit.runners.model.InitializationError; public class ErrorReportingRunner extends Runner { - private final List fCauses; + private final List causes; - private final Class fTestClass; + private final Class testClass; public ErrorReportingRunner(Class testClass, Throwable cause) { if (testClass == null) { throw new NullPointerException("Test class cannot be null"); } - fTestClass = testClass; - fCauses = getCauses(cause); + this.testClass = testClass; + causes = getCauses(cause); } @Override public Description getDescription() { - Description description = Description.createSuiteDescription(fTestClass); - for (Throwable each : fCauses) { + Description description = Description.createSuiteDescription(testClass); + for (Throwable each : causes) { description.addChild(describeCause(each)); } return description; @@ -34,7 +34,7 @@ public Description getDescription() { @Override public void run(RunNotifier notifier) { - for (Throwable each : fCauses) { + for (Throwable each : causes) { runCause(each, notifier); } } @@ -55,7 +55,7 @@ private List getCauses(Throwable cause) { } private Description describeCause(Throwable child) { - return Description.createTestDescription(fTestClass, + return Description.createTestDescription(testClass, "initializationError"); } diff --git a/src/main/java/org/junit/internal/runners/InitializationError.java b/src/main/java/org/junit/internal/runners/InitializationError.java index 91ddfa7ffcc1..5cfa14328ca1 100644 --- a/src/main/java/org/junit/internal/runners/InitializationError.java +++ b/src/main/java/org/junit/internal/runners/InitializationError.java @@ -11,10 +11,10 @@ @Deprecated public class InitializationError extends Exception { private static final long serialVersionUID = 1L; - private final List fErrors; + private final List errors; public InitializationError(List errors) { - fErrors = errors; + this.errors = errors; } public InitializationError(Throwable... errors) { @@ -26,6 +26,6 @@ public InitializationError(String string) { } public List getCauses() { - return fErrors; + return errors; } } diff --git a/src/main/java/org/junit/internal/runners/JUnit38ClassRunner.java b/src/main/java/org/junit/internal/runners/JUnit38ClassRunner.java index b71677b139cf..631fcf2e5904 100644 --- a/src/main/java/org/junit/internal/runners/JUnit38ClassRunner.java +++ b/src/main/java/org/junit/internal/runners/JUnit38ClassRunner.java @@ -23,24 +23,24 @@ public class JUnit38ClassRunner extends Runner implements Filterable, Sortable { private static final class OldTestClassAdaptingListener implements TestListener { - private final RunNotifier fNotifier; + private final RunNotifier notifier; private OldTestClassAdaptingListener(RunNotifier notifier) { - fNotifier = notifier; + this.notifier = notifier; } public void endTest(Test test) { - fNotifier.fireTestFinished(asDescription(test)); + notifier.fireTestFinished(asDescription(test)); } public void startTest(Test test) { - fNotifier.fireTestStarted(asDescription(test)); + notifier.fireTestStarted(asDescription(test)); } // Implement junit.framework.TestListener public void addError(Test test, Throwable e) { Failure failure = new Failure(asDescription(test), e); - fNotifier.fireTestFailure(failure); + notifier.fireTestFailure(failure); } private Description asDescription(Test test) { @@ -68,7 +68,7 @@ public void addFailure(Test test, AssertionFailedError t) { } } - private volatile Test fTest; + private volatile Test test; public JUnit38ClassRunner(Class klass) { this(new TestSuite(klass.asSubclass(TestCase.class))); @@ -171,10 +171,10 @@ public void sort(Sorter sorter) { } private void setTest(Test test) { - fTest = test; + this.test = test; } private Test getTest() { - return fTest; + return test; } } diff --git a/src/main/java/org/junit/internal/runners/model/EachTestNotifier.java b/src/main/java/org/junit/internal/runners/model/EachTestNotifier.java index cb31c19e4729..e094809fdf91 100644 --- a/src/main/java/org/junit/internal/runners/model/EachTestNotifier.java +++ b/src/main/java/org/junit/internal/runners/model/EachTestNotifier.java @@ -7,21 +7,20 @@ import org.junit.runners.model.MultipleFailureException; public class EachTestNotifier { - private final RunNotifier fNotifier; + private final RunNotifier notifier; - private final Description fDescription; + private final Description description; public EachTestNotifier(RunNotifier notifier, Description description) { - fNotifier = notifier; - fDescription = description; + this.notifier = notifier; + this.description = description; } public void addFailure(Throwable targetException) { if (targetException instanceof MultipleFailureException) { addMultipleFailureException((MultipleFailureException) targetException); } else { - fNotifier - .fireTestFailure(new Failure(fDescription, targetException)); + notifier.fireTestFailure(new Failure(description, targetException)); } } @@ -32,18 +31,18 @@ private void addMultipleFailureException(MultipleFailureException mfe) { } public void addFailedAssumption(AssumptionViolatedException e) { - fNotifier.fireTestAssumptionFailed(new Failure(fDescription, e)); + notifier.fireTestAssumptionFailed(new Failure(description, e)); } public void fireTestFinished() { - fNotifier.fireTestFinished(fDescription); + notifier.fireTestFinished(description); } public void fireTestStarted() { - fNotifier.fireTestStarted(fDescription); + notifier.fireTestStarted(description); } public void fireTestIgnored() { - fNotifier.fireTestIgnored(fDescription); + notifier.fireTestIgnored(description); } } \ No newline at end of file diff --git a/src/main/java/org/junit/internal/runners/rules/RuleFieldValidator.java b/src/main/java/org/junit/internal/runners/rules/RuleFieldValidator.java index 11e9d88c061a..08e00c230430 100644 --- a/src/main/java/org/junit/internal/runners/rules/RuleFieldValidator.java +++ b/src/main/java/org/junit/internal/runners/rules/RuleFieldValidator.java @@ -42,16 +42,16 @@ public enum RuleFieldValidator { */ RULE_METHOD_VALIDATOR(Rule.class, true, false); - private final Class fAnnotation; + private final Class annotation; - private final boolean fStaticMembers; - private final boolean fMethods; + private final boolean staticMembers; + private final boolean methods; private RuleFieldValidator(Class annotation, - boolean methods, boolean fStaticMembers) { - this.fAnnotation = annotation; - this.fStaticMembers = fStaticMembers; - this.fMethods = methods; + boolean methods, boolean staticMembers) { + this.annotation = annotation; + this.staticMembers = staticMembers; + this.methods = methods; } /** @@ -62,8 +62,8 @@ private RuleFieldValidator(Class annotation, * @param errors the list of errors. */ public void validate(TestClass target, List errors) { - List> members = fMethods ? target.getAnnotatedMethods(fAnnotation) - : target.getAnnotatedFields(fAnnotation); + List> members = methods ? target.getAnnotatedMethods(annotation) + : target.getAnnotatedFields(annotation); for (FrameworkMember each : members) { validateMember(each, errors); @@ -78,16 +78,16 @@ private void validateMember(FrameworkMember member, List errors) { } private void validatePublicClass(FrameworkMember member, List errors) { - if (fStaticMembers && !isDeclaringClassPublic(member)) { + if (staticMembers && !isDeclaringClassPublic(member)) { addError(errors, member, " must be declared in a public class."); } } private void validateStatic(FrameworkMember member, List errors) { - if (fStaticMembers && !member.isStatic()) { + if (staticMembers && !member.isStatic()) { addError(errors, member, "must be static."); } - if (!fStaticMembers && member.isStatic()) { + if (!staticMembers && member.isStatic()) { addError(errors, member, "must not be static or it has to be annotated with @ClassRule."); } } @@ -101,7 +101,7 @@ private void validatePublic(FrameworkMember member, List errors) { private void validateTestRuleOrMethodRule(FrameworkMember member, List errors) { if (!isMethodRule(member) && !isTestRule(member)) { - addError(errors, member, fMethods ? + addError(errors, member, methods ? "must return an implementation of MethodRule or TestRule." : "must implement MethodRule or TestRule."); } @@ -121,7 +121,7 @@ private boolean isMethodRule(FrameworkMember member) { private void addError(List errors, FrameworkMember member, String suffix) { - String message = "The @" + fAnnotation.getSimpleName() + " '" + String message = "The @" + annotation.getSimpleName() + " '" + member.getName() + "' " + suffix; errors.add(new Exception(message)); } diff --git a/src/main/java/org/junit/internal/runners/statements/ExpectException.java b/src/main/java/org/junit/internal/runners/statements/ExpectException.java index b4b7172a67b9..d0636bd78bbb 100644 --- a/src/main/java/org/junit/internal/runners/statements/ExpectException.java +++ b/src/main/java/org/junit/internal/runners/statements/ExpectException.java @@ -4,33 +4,33 @@ import org.junit.runners.model.Statement; public class ExpectException extends Statement { - private Statement fNext; - private final Class fExpected; + private final Statement next; + private final Class expected; public ExpectException(Statement next, Class expected) { - fNext = next; - fExpected = expected; + this.next = next; + this.expected = expected; } @Override public void evaluate() throws Exception { boolean complete = false; try { - fNext.evaluate(); + next.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { - if (!fExpected.isAssignableFrom(e.getClass())) { + if (!expected.isAssignableFrom(e.getClass())) { String message = "Unexpected exception, expected<" - + fExpected.getName() + "> but was<" + + expected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) { throw new AssertionError("Expected exception: " - + fExpected.getName()); + + expected.getName()); } } } \ No newline at end of file diff --git a/src/main/java/org/junit/internal/runners/statements/Fail.java b/src/main/java/org/junit/internal/runners/statements/Fail.java index 5d6c0fe44d0e..e55875c14659 100644 --- a/src/main/java/org/junit/internal/runners/statements/Fail.java +++ b/src/main/java/org/junit/internal/runners/statements/Fail.java @@ -3,14 +3,14 @@ import org.junit.runners.model.Statement; public class Fail extends Statement { - private final Throwable fError; + private final Throwable error; public Fail(Throwable e) { - fError = e; + error = e; } @Override public void evaluate() throws Throwable { - throw fError; + throw error; } } diff --git a/src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java b/src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java index 090588d9d432..e92913374e28 100644 --- a/src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java +++ b/src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java @@ -14,11 +14,11 @@ import org.junit.runners.model.TestTimedOutException; public class FailOnTimeout extends Statement { - private final Statement fOriginalStatement; - private final TimeUnit fTimeUnit; - private final long fTimeout; - private final boolean fLookForStuckThread; - private volatile ThreadGroup fThreadGroup = null; + private final Statement originalStatement; + private final TimeUnit timeUnit; + private final long timeout; + private final boolean lookForStuckThread; + private volatile ThreadGroup threadGroup = null; public FailOnTimeout(Statement originalStatement, long millis) { this(originalStatement, millis, TimeUnit.MILLISECONDS); @@ -29,17 +29,17 @@ public FailOnTimeout(Statement originalStatement, long timeout, TimeUnit unit) { } public FailOnTimeout(Statement originalStatement, long timeout, TimeUnit unit, boolean lookForStuckThread) { - fOriginalStatement = originalStatement; - fTimeout = timeout; - fTimeUnit = unit; - fLookForStuckThread = lookForStuckThread; + this.originalStatement = originalStatement; + this.timeout = timeout; + timeUnit = unit; + this.lookForStuckThread = lookForStuckThread; } @Override public void evaluate() throws Throwable { FutureTask task = new FutureTask(new CallableStatement()); - fThreadGroup = new ThreadGroup("FailOnTimeoutGroup"); - Thread thread = new Thread(fThreadGroup, task, "Time-limited test"); + threadGroup = new ThreadGroup("FailOnTimeoutGroup"); + Thread thread = new Thread(threadGroup, task, "Time-limited test"); thread.setDaemon(true); thread.start(); Throwable throwable = getResult(task, thread); @@ -55,8 +55,8 @@ public void evaluate() throws Throwable { */ private Throwable getResult(FutureTask task, Thread thread) { try { - if (fTimeout > 0) { - return task.get(fTimeout, fTimeUnit); + if (timeout > 0) { + return task.get(timeout, timeUnit); } else { return task.get(); } @@ -72,8 +72,8 @@ private Throwable getResult(FutureTask task, Thread thread) { private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); - final Thread stuckThread = fLookForStuckThread ? getStuckThread(thread) : null; - Exception currThreadException = new TestTimedOutException(fTimeout, fTimeUnit); + final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null; + Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); @@ -115,12 +115,14 @@ private StackTraceElement[] getStackTrace(Thread thread) { * to {@code mainThread}. */ private Thread getStuckThread (Thread mainThread) { - if (fThreadGroup == null) + if (threadGroup == null){ return null; - Thread[] threadsInGroup = getThreadArray(fThreadGroup); - if (threadsInGroup == null) + } + Thread[] threadsInGroup = getThreadArray(threadGroup); + if (threadsInGroup == null){ return null; - + } + // Now that we have all the threads in the test's thread group: Assume that // any thread we're "stuck" in is RUNNABLE. Look for all RUNNABLE threads. // If just one, we return that (unless it equals threadMain). If there's more @@ -204,7 +206,7 @@ private long cpuTime (Thread thr) { private class CallableStatement implements Callable { public Throwable call() throws Exception { try { - fOriginalStatement.evaluate(); + originalStatement.evaluate(); } catch (Exception e) { throw e; } catch (Throwable e) { diff --git a/src/main/java/org/junit/internal/runners/statements/InvokeMethod.java b/src/main/java/org/junit/internal/runners/statements/InvokeMethod.java index 2896c64eb31b..68c0545b1422 100644 --- a/src/main/java/org/junit/internal/runners/statements/InvokeMethod.java +++ b/src/main/java/org/junit/internal/runners/statements/InvokeMethod.java @@ -4,16 +4,16 @@ import org.junit.runners.model.Statement; public class InvokeMethod extends Statement { - private final FrameworkMethod fTestMethod; - private Object fTarget; + private final FrameworkMethod testMethod; + private final Object target; public InvokeMethod(FrameworkMethod testMethod, Object target) { - fTestMethod = testMethod; - fTarget = target; + this.testMethod = testMethod; + this.target = target; } @Override public void evaluate() throws Throwable { - fTestMethod.invokeExplosively(fTarget); + testMethod.invokeExplosively(target); } } \ No newline at end of file diff --git a/src/main/java/org/junit/internal/runners/statements/RunAfters.java b/src/main/java/org/junit/internal/runners/statements/RunAfters.java index f4c559af4bea..7512a7d61f40 100644 --- a/src/main/java/org/junit/internal/runners/statements/RunAfters.java +++ b/src/main/java/org/junit/internal/runners/statements/RunAfters.java @@ -8,29 +8,29 @@ import org.junit.runners.model.Statement; public class RunAfters extends Statement { - private final Statement fNext; + private final Statement next; - private final Object fTarget; + private final Object target; - private final List fAfters; + private final List afters; public RunAfters(Statement next, List afters, Object target) { - fNext = next; - fAfters = afters; - fTarget = target; + this.next = next; + this.afters = afters; + this.target = target; } @Override public void evaluate() throws Throwable { List errors = new ArrayList(); try { - fNext.evaluate(); + next.evaluate(); } catch (Throwable e) { errors.add(e); } finally { - for (FrameworkMethod each : fAfters) { + for (FrameworkMethod each : afters) { try { - each.invokeExplosively(fTarget); + each.invokeExplosively(target); } catch (Throwable e) { errors.add(e); } diff --git a/src/main/java/org/junit/internal/runners/statements/RunBefores.java b/src/main/java/org/junit/internal/runners/statements/RunBefores.java index 60fbb39b78ea..238fbe7d07a5 100644 --- a/src/main/java/org/junit/internal/runners/statements/RunBefores.java +++ b/src/main/java/org/junit/internal/runners/statements/RunBefores.java @@ -6,23 +6,23 @@ import org.junit.runners.model.Statement; public class RunBefores extends Statement { - private final Statement fNext; + private final Statement next; - private final Object fTarget; + private final Object target; - private final List fBefores; + private final List befores; public RunBefores(Statement next, List befores, Object target) { - fNext = next; - fBefores = befores; - fTarget = target; + this.next = next; + this.befores = befores; + this.target = target; } @Override public void evaluate() throws Throwable { - for (FrameworkMethod before : fBefores) { - before.invokeExplosively(fTarget); + for (FrameworkMethod before : befores) { + before.invokeExplosively(target); } - fNext.evaluate(); + next.evaluate(); } } \ No newline at end of file diff --git a/src/main/java/org/junit/rules/ExpectedException.java b/src/main/java/org/junit/rules/ExpectedException.java index 4272e624b8b7..4d61712803a0 100644 --- a/src/main/java/org/junit/rules/ExpectedException.java +++ b/src/main/java/org/junit/rules/ExpectedException.java @@ -112,7 +112,7 @@ public static ExpectedException none() { return new ExpectedException(); } - private final ExpectedExceptionMatcherBuilder fMatcherBuilder = new ExpectedExceptionMatcherBuilder(); + private final ExpectedExceptionMatcherBuilder matcherBuilder = new ExpectedExceptionMatcherBuilder(); private String missingExceptionMessage= "Expected test to throw %s"; @@ -170,7 +170,7 @@ public Statement apply(Statement base, * } */ public void expect(Matcher matcher) { - fMatcherBuilder.add(matcher); + matcherBuilder.add(matcher); } /** @@ -227,16 +227,16 @@ public void expectCause(Matcher expectedCause) { } private class ExpectedExceptionStatement extends Statement { - private final Statement fNext; + private final Statement next; public ExpectedExceptionStatement(Statement base) { - fNext = base; + next = base; } @Override public void evaluate() throws Throwable { try { - fNext.evaluate(); + next.evaluate(); } catch (Throwable e) { handleException(e); return; @@ -249,14 +249,14 @@ public void evaluate() throws Throwable { private void handleException(Throwable e) throws Throwable { if (isAnyExceptionExpected()) { - assertThat(e, fMatcherBuilder.build()); + assertThat(e, matcherBuilder.build()); } else { throw e; } } private boolean isAnyExceptionExpected() { - return fMatcherBuilder.expectsThrowable(); + return matcherBuilder.expectsThrowable(); } private void failDueToMissingException() throws AssertionError { @@ -264,7 +264,7 @@ private void failDueToMissingException() throws AssertionError { } private String missingExceptionMessage() { - String expectation= StringDescription.toString(fMatcherBuilder.build()); + String expectation= StringDescription.toString(matcherBuilder.build()); return format(missingExceptionMessage, expectation); } } diff --git a/src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java b/src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java index f083a4d3a10c..e7d94c483f4a 100644 --- a/src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java +++ b/src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java @@ -13,14 +13,14 @@ */ class ExpectedExceptionMatcherBuilder { - private final List> fMatchers = new ArrayList>(); + private final List> matchers = new ArrayList>(); void add(Matcher matcher) { - fMatchers.add(matcher); + matchers.add(matcher); } boolean expectsThrowable() { - return !fMatchers.isEmpty(); + return !matchers.isEmpty(); } Matcher build() { @@ -28,15 +28,15 @@ Matcher build() { } private Matcher allOfTheMatchers() { - if (fMatchers.size() == 1) { - return cast(fMatchers.get(0)); + if (matchers.size() == 1) { + return cast(matchers.get(0)); } return allOf(castedMatchers()); } @SuppressWarnings({"unchecked", "rawtypes"}) private List> castedMatchers() { - return new ArrayList>((List) fMatchers); + return new ArrayList>((List) matchers); } @SuppressWarnings("unchecked") diff --git a/src/main/java/org/junit/rules/Stopwatch.java b/src/main/java/org/junit/rules/Stopwatch.java index 71d08e1a5278..fb9388fc1cf5 100644 --- a/src/main/java/org/junit/rules/Stopwatch.java +++ b/src/main/java/org/junit/rules/Stopwatch.java @@ -75,15 +75,15 @@ * @since 4.12 */ public class Stopwatch extends TestWatcher { - private long fStartNanos; - private long fEndNanos; + private long startNanos; + private long endNanos; /** * @param unit time unit for returned runtime * @return runtime measured during the test */ public long runtime(TimeUnit unit) { - return unit.convert(currentNanoTime() - fStartNanos, TimeUnit.NANOSECONDS); + return unit.convert(currentNanoTime() - startNanos, TimeUnit.NANOSECONDS); } /** @@ -135,15 +135,15 @@ public static long toSeconds(long nanos) { } private long getNanos() { - return fEndNanos - fStartNanos; + return endNanos - startNanos; } private void starting() { - fStartNanos= currentNanoTime(); + startNanos = currentNanoTime(); } private void stopping() { - fEndNanos= currentNanoTime(); + endNanos = currentNanoTime(); } private long currentNanoTime() { diff --git a/src/main/java/org/junit/rules/TestName.java b/src/main/java/org/junit/rules/TestName.java index 00d7c29657a2..bf726023bf68 100644 --- a/src/main/java/org/junit/rules/TestName.java +++ b/src/main/java/org/junit/rules/TestName.java @@ -25,17 +25,17 @@ * @since 4.7 */ public class TestName extends TestWatcher { - private String fName; + private String name; @Override protected void starting(Description d) { - fName = d.getMethodName(); + name = d.getMethodName(); } /** * @return the name of the currently-running test method */ public String getMethodName() { - return fName; + return name; } } diff --git a/src/main/java/org/junit/rules/Timeout.java b/src/main/java/org/junit/rules/Timeout.java index 2a6b33045bc3..2ec3b564467f 100644 --- a/src/main/java/org/junit/rules/Timeout.java +++ b/src/main/java/org/junit/rules/Timeout.java @@ -38,9 +38,9 @@ * @since 4.7 */ public class Timeout implements TestRule { - private final long fTimeout; - private final TimeUnit fTimeUnit; - private final boolean fLookForStuckThread; + private final long timeout; + private final TimeUnit timeUnit; + private final boolean lookForStuckThread; /** * Create a {@code Timeout} instance with the timeout specified @@ -61,31 +61,31 @@ public Timeout(int millis) { /** * Create a {@code Timeout} instance with the timeout specified - * at the unit of granularity of the provided {@code TimeUnit}. + * at the timeUnit of granularity of the provided {@code TimeUnit}. * * @param timeout the maximum time to allow the test to run * before it should timeout - * @param unit the time unit for the {@code timeout} + * @param timeUnit the time unit for the {@code timeout} * @since 4.12 */ - public Timeout(long timeout, TimeUnit unit) { - fTimeout = timeout; - fTimeUnit = unit; - fLookForStuckThread = false; + public Timeout(long timeout, TimeUnit timeUnit) { + this.timeout = timeout; + this.timeUnit = timeUnit; + lookForStuckThread = false; } /** * Create a {@code Timeout} instance with the same fields as {@code t} - * except for {@code fLookForStuckThread}. + * except for {@code lookForStuckThread}. * * @param t the {@code Timeout} instance to copy * @param lookForStuckThread whether to look for a stuck thread * @since 4.12 */ protected Timeout(Timeout t, boolean lookForStuckThread) { - fTimeout = t.fTimeout; - fTimeUnit = t.fTimeUnit; - fLookForStuckThread = lookForStuckThread; + timeout = t.timeout; + timeUnit = t.timeUnit; + this.lookForStuckThread = lookForStuckThread; } /** @@ -118,6 +118,6 @@ public Timeout lookingForStuckThread(boolean enable) { } public Statement apply(Statement base, Description description) { - return new FailOnTimeout(base, fTimeout, fTimeUnit, fLookForStuckThread); + return new FailOnTimeout(base, timeout, timeUnit, lookForStuckThread); } } diff --git a/src/main/java/org/junit/runner/Description.java b/src/main/java/org/junit/runner/Description.java index 9cea7af0d0a9..77b32e15df3e 100644 --- a/src/main/java/org/junit/runner/Description.java +++ b/src/main/java/org/junit/runner/Description.java @@ -136,17 +136,17 @@ public static Description createSuiteDescription(Class testClass) { */ public static final Description TEST_MECHANISM = new Description(null, "Test mechanism"); - private final Collection fChildren = new ConcurrentLinkedQueue(); - private final String fDisplayName; - private final Serializable fUniqueId; - private final Annotation[] fAnnotations; - private volatile /* write-once */ Class fTestClass; + private final Collection children = new ConcurrentLinkedQueue(); + private final String displayName; + private final Serializable uniqueId; + private final Annotation[] annotations; + private volatile /* write-once */ Class testClass; private Description(Class clazz, String displayName, Annotation... annotations) { this(clazz, displayName, displayName, annotations); } - private Description(Class clazz, String displayName, Serializable uniqueId, Annotation... annotations) { + private Description(Class testClass, String displayName, Serializable uniqueId, Annotation... annotations) { if ((displayName == null) || (displayName.length() == 0)) { throw new IllegalArgumentException( "The display name must not be empty."); @@ -155,17 +155,17 @@ private Description(Class clazz, String displayName, Serializable uniqueId, A throw new IllegalArgumentException( "The unique id must not be null."); } - fTestClass = clazz; - fDisplayName = displayName; - fUniqueId = uniqueId; - fAnnotations = annotations; + this.testClass = testClass; + this.displayName = displayName; + this.uniqueId = uniqueId; + this.annotations = annotations; } /** * @return a user-understandable label */ public String getDisplayName() { - return fDisplayName; + return displayName; } /** @@ -174,7 +174,7 @@ public String getDisplayName() { * @param description the soon-to-be child. */ public void addChild(Description description) { - fChildren.add(description); + children.add(description); } /** @@ -182,7 +182,7 @@ public void addChild(Description description) { * Returns an empty list if there are no children. */ public ArrayList getChildren() { - return new ArrayList(fChildren); + return new ArrayList(children); } /** @@ -196,7 +196,7 @@ public boolean isSuite() { * @return true if the receiver is an atomic test */ public boolean isTest() { - return fChildren.isEmpty(); + return children.isEmpty(); } /** @@ -207,7 +207,7 @@ public int testCount() { return 1; } int result = 0; - for (Description child : fChildren) { + for (Description child : children) { result += child.testCount(); } return result; @@ -215,7 +215,7 @@ public int testCount() { @Override public int hashCode() { - return fUniqueId.hashCode(); + return uniqueId.hashCode(); } @Override @@ -224,7 +224,7 @@ public boolean equals(Object obj) { return false; } Description d = (Description) obj; - return fUniqueId.equals(d.fUniqueId); + return uniqueId.equals(d.uniqueId); } @Override @@ -244,7 +244,7 @@ public boolean isEmpty() { * children will be added back) */ public Description childlessCopy() { - return new Description(fTestClass, fDisplayName, fAnnotations); + return new Description(testClass, displayName, annotations); } /** @@ -252,7 +252,7 @@ public Description childlessCopy() { * or null if none exists */ public T getAnnotation(Class annotationType) { - for (Annotation each : fAnnotations) { + for (Annotation each : annotations) { if (each.annotationType().equals(annotationType)) { return annotationType.cast(each); } @@ -264,7 +264,7 @@ public T getAnnotation(Class annotationType) { * @return all of the annotations attached to this description node */ public Collection getAnnotations() { - return Arrays.asList(fAnnotations); + return Arrays.asList(annotations); } /** @@ -272,16 +272,16 @@ public Collection getAnnotations() { * the class of the test instance. */ public Class getTestClass() { - if (fTestClass != null) { - return fTestClass; + if (testClass != null) { + return testClass; } String name = getClassName(); if (name == null) { return null; } try { - fTestClass = Class.forName(name, false, getClass().getClassLoader()); - return fTestClass; + testClass = Class.forName(name, false, getClass().getClassLoader()); + return testClass; } catch (ClassNotFoundException e) { return null; } @@ -292,7 +292,7 @@ public Class getTestClass() { * the name of the class of the test instance */ public String getClassName() { - return fTestClass != null ? fTestClass.getName() : methodAndClassNamePatternGroupOrDefault(2, toString()); + return testClass != null ? testClass.getName() : methodAndClassNamePatternGroupOrDefault(2, toString()); } /** diff --git a/src/main/java/org/junit/runner/JUnitCore.java b/src/main/java/org/junit/runner/JUnitCore.java index 260641009c47..c1479e004d5d 100644 --- a/src/main/java/org/junit/runner/JUnitCore.java +++ b/src/main/java/org/junit/runner/JUnitCore.java @@ -22,7 +22,7 @@ * @since 4.0 */ public class JUnitCore { - private final RunNotifier fNotifier = new RunNotifier(); + private final RunNotifier notifier = new RunNotifier(); /** * Run the tests contained in the classes named in the args. @@ -131,11 +131,11 @@ public Result run(junit.framework.Test test) { public Result run(Runner runner) { Result result = new Result(); RunListener listener = result.createListener(); - fNotifier.addFirstListener(listener); + notifier.addFirstListener(listener); try { - fNotifier.fireTestRunStarted(runner.getDescription()); - runner.run(fNotifier); - fNotifier.fireTestRunFinished(result); + notifier.fireTestRunStarted(runner.getDescription()); + runner.run(notifier); + notifier.fireTestRunFinished(result); } finally { removeListener(listener); } @@ -149,7 +149,7 @@ public Result run(Runner runner) { * @see org.junit.runner.notification.RunListener */ public void addListener(RunListener listener) { - fNotifier.addListener(listener); + notifier.addListener(listener); } /** @@ -158,7 +158,7 @@ public void addListener(RunListener listener) { * @param listener the listener to remove */ public void removeListener(RunListener listener) { - fNotifier.removeListener(listener); + notifier.removeListener(listener); } static Computer defaultComputer() { diff --git a/src/main/java/org/junit/runner/Result.java b/src/main/java/org/junit/runner/Result.java index 1acdbbd1f51d..8d4f10c8819a 100644 --- a/src/main/java/org/junit/runner/Result.java +++ b/src/main/java/org/junit/runner/Result.java @@ -17,45 +17,45 @@ */ public class Result implements Serializable { private static final long serialVersionUID = 2L; - private final AtomicInteger fCount = new AtomicInteger(); - private final AtomicInteger fIgnoreCount = new AtomicInteger(); - private final CopyOnWriteArrayList fFailures = new CopyOnWriteArrayList(); - private final AtomicLong fRunTime = new AtomicLong(); - private final AtomicLong fStartTime = new AtomicLong(); + private final AtomicInteger count = new AtomicInteger(); + private final AtomicInteger ignoreCount = new AtomicInteger(); + private final CopyOnWriteArrayList failures = new CopyOnWriteArrayList(); + private final AtomicLong runTime = new AtomicLong(); + private final AtomicLong startTime = new AtomicLong(); /** * @return the number of tests run */ public int getRunCount() { - return fCount.get(); + return count.get(); } /** * @return the number of tests that failed during the run */ public int getFailureCount() { - return fFailures.size(); + return failures.size(); } /** * @return the number of milliseconds it took to run the entire suite to run */ public long getRunTime() { - return fRunTime.get(); + return runTime.get(); } /** * @return the {@link Failure}s describing tests that failed and the problems they encountered */ public List getFailures() { - return fFailures; + return failures; } /** * @return the number of tests ignored during the run */ public int getIgnoreCount() { - return fIgnoreCount.get(); + return ignoreCount.get(); } /** @@ -69,28 +69,28 @@ public boolean wasSuccessful() { private class Listener extends RunListener { @Override public void testRunStarted(Description description) throws Exception { - fStartTime.set(System.currentTimeMillis()); + startTime.set(System.currentTimeMillis()); } @Override public void testRunFinished(Result result) throws Exception { long endTime = System.currentTimeMillis(); - fRunTime.addAndGet(endTime - fStartTime.get()); + runTime.addAndGet(endTime - startTime.get()); } @Override public void testFinished(Description description) throws Exception { - fCount.getAndIncrement(); + count.getAndIncrement(); } @Override public void testFailure(Failure failure) throws Exception { - fFailures.add(failure); + failures.add(failure); } @Override public void testIgnored(Description description) throws Exception { - fIgnoreCount.getAndIncrement(); + ignoreCount.getAndIncrement(); } @Override diff --git a/src/main/java/org/junit/runner/manipulation/Sorter.java b/src/main/java/org/junit/runner/manipulation/Sorter.java index 0bf5534acd34..20192d0c96e8 100644 --- a/src/main/java/org/junit/runner/manipulation/Sorter.java +++ b/src/main/java/org/junit/runner/manipulation/Sorter.java @@ -20,7 +20,7 @@ public int compare(Description o1, Description o2) { } }); - private final Comparator fComparator; + private final Comparator comparator; /** * Creates a Sorter that uses comparator @@ -29,7 +29,7 @@ public int compare(Description o1, Description o2) { * @param comparator the {@link Comparator} to use when sorting tests */ public Sorter(Comparator comparator) { - fComparator = comparator; + this.comparator = comparator; } /** @@ -43,6 +43,6 @@ public void apply(Object object) { } public int compare(Description o1, Description o2) { - return fComparator.compare(o1, o2); + return comparator.compare(o1, o2); } } diff --git a/src/main/java/org/junit/runner/notification/Failure.java b/src/main/java/org/junit/runner/notification/Failure.java index 1a73f53fa473..0aef22860b4b 100644 --- a/src/main/java/org/junit/runner/notification/Failure.java +++ b/src/main/java/org/junit/runner/notification/Failure.java @@ -17,8 +17,8 @@ */ public class Failure implements Serializable { private static final long serialVersionUID = 1L; - private final Description fDescription; - private final Throwable fThrownException; + private final Description description; + private final Throwable thrownException; /** * Constructs a Failure with the given description and exception. @@ -27,22 +27,22 @@ public class Failure implements Serializable { * @param thrownException the exception that was thrown while running the test */ public Failure(Description description, Throwable thrownException) { - fThrownException = thrownException; - fDescription = description; + this.thrownException = thrownException; + this.description = description; } /** * @return a user-understandable label for the test */ public String getTestHeader() { - return fDescription.getDisplayName(); + return description.getDisplayName(); } /** * @return the raw description of the context of the failure. */ public Description getDescription() { - return fDescription; + return description; } /** @@ -50,12 +50,12 @@ public Description getDescription() { */ public Throwable getException() { - return fThrownException; + return thrownException; } @Override public String toString() { - return getTestHeader() + ": " + fThrownException.getMessage(); + return getTestHeader() + ": " + thrownException.getMessage(); } /** diff --git a/src/main/java/org/junit/runner/notification/RunNotifier.java b/src/main/java/org/junit/runner/notification/RunNotifier.java index f91fde943e67..6875f76939ea 100644 --- a/src/main/java/org/junit/runner/notification/RunNotifier.java +++ b/src/main/java/org/junit/runner/notification/RunNotifier.java @@ -19,8 +19,8 @@ * @since 4.0 */ public class RunNotifier { - private final List fListeners = new CopyOnWriteArrayList(); - private volatile boolean fPleaseStop = false; + private final List listeners = new CopyOnWriteArrayList(); + private volatile boolean pleaseStop = false; /** * Internal use only @@ -29,7 +29,7 @@ public void addListener(RunListener listener) { if (listener == null) { throw new NullPointerException("Cannot add a null listener"); } - fListeners.add(wrapIfNotThreadSafe(listener)); + listeners.add(wrapIfNotThreadSafe(listener)); } /** @@ -39,7 +39,7 @@ public void removeListener(RunListener listener) { if (listener == null) { throw new NullPointerException("Cannot remove a null listener"); } - fListeners.remove(wrapIfNotThreadSafe(listener)); + listeners.remove(wrapIfNotThreadSafe(listener)); } /** @@ -53,21 +53,21 @@ RunListener wrapIfNotThreadSafe(RunListener listener) { private abstract class SafeNotifier { - private final List fCurrentListeners; + private final List currentListeners; SafeNotifier() { - this(fListeners); + this(listeners); } SafeNotifier(List currentListeners) { - fCurrentListeners = currentListeners; + this.currentListeners = currentListeners; } void run() { - int capacity = fCurrentListeners.size(); + int capacity = currentListeners.size(); ArrayList safeListeners = new ArrayList(capacity); ArrayList failures = new ArrayList(capacity); - for (RunListener listener : fCurrentListeners) { + for (RunListener listener : currentListeners) { try { notifyListener(listener); safeListeners.add(listener); @@ -112,7 +112,7 @@ protected void notifyListener(RunListener each) throws Exception { * @throws StoppedByUserException thrown if a user has requested that the test run stop */ public void fireTestStarted(final Description description) throws StoppedByUserException { - if (fPleaseStop) { + if (pleaseStop) { throw new StoppedByUserException(); } new SafeNotifier() { @@ -129,7 +129,7 @@ protected void notifyListener(RunListener each) throws Exception { * @param failure the description of the test that failed and the exception thrown */ public void fireTestFailure(Failure failure) { - fireTestFailures(fListeners, asList(failure)); + fireTestFailures(listeners, asList(failure)); } private void fireTestFailures(List listeners, @@ -199,7 +199,7 @@ protected void notifyListener(RunListener each) throws Exception { * to be shared amongst the many runners involved. */ public void pleaseStop() { - fPleaseStop = true; + pleaseStop = true; } /** @@ -209,6 +209,6 @@ public void addFirstListener(RunListener listener) { if (listener == null) { throw new NullPointerException("Cannot add a null listener"); } - fListeners.add(0, wrapIfNotThreadSafe(listener)); + listeners.add(0, wrapIfNotThreadSafe(listener)); } } diff --git a/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java b/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java index 292f5bed2a9a..c53c1ee642c7 100644 --- a/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java +++ b/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java @@ -21,66 +21,66 @@ */ @RunListener.ThreadSafe final class SynchronizedRunListener extends RunListener { - private final RunListener fListener; - private final Object fMonitor; + private final RunListener listener; + private final Object monitor; SynchronizedRunListener(RunListener listener, Object monitor) { - fListener = listener; - fMonitor = monitor; + this.listener = listener; + this.monitor = monitor; } @Override public void testRunStarted(Description description) throws Exception { - synchronized (fMonitor) { - fListener.testRunStarted(description); + synchronized (monitor) { + listener.testRunStarted(description); } } @Override public void testRunFinished(Result result) throws Exception { - synchronized (fMonitor) { - fListener.testRunFinished(result); + synchronized (monitor) { + listener.testRunFinished(result); } } @Override public void testStarted(Description description) throws Exception { - synchronized (fMonitor) { - fListener.testStarted(description); + synchronized (monitor) { + listener.testStarted(description); } } @Override public void testFinished(Description description) throws Exception { - synchronized (fMonitor) { - fListener.testFinished(description); + synchronized (monitor) { + listener.testFinished(description); } } @Override public void testFailure(Failure failure) throws Exception { - synchronized (fMonitor) { - fListener.testFailure(failure); + synchronized (monitor) { + listener.testFailure(failure); } } @Override public void testAssumptionFailure(Failure failure) { - synchronized (fMonitor) { - fListener.testAssumptionFailure(failure); + synchronized (monitor) { + listener.testAssumptionFailure(failure); } } @Override public void testIgnored(Description description) throws Exception { - synchronized (fMonitor) { - fListener.testIgnored(description); + synchronized (monitor) { + listener.testIgnored(description); } } @Override public int hashCode() { - return fListener.hashCode(); + return listener.hashCode(); } @Override @@ -93,11 +93,11 @@ public boolean equals(Object other) { } SynchronizedRunListener that = (SynchronizedRunListener) other; - return fListener.equals(that.fListener); + return listener.equals(that.listener); } @Override public String toString() { - return fListener.toString() + " (with synchronization wrapper)"; + return listener.toString() + " (with synchronization wrapper)"; } } diff --git a/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java b/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java index 08620b48c36d..287aa1a5cd41 100644 --- a/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java +++ b/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java @@ -53,7 +53,7 @@ * @since 4.5 */ public class BlockJUnit4ClassRunner extends ParentRunner { - private final ConcurrentHashMap fMethodDescriptions = new ConcurrentHashMap(); + private final ConcurrentHashMap methodDescriptions = new ConcurrentHashMap(); /** * Creates a BlockJUnit4ClassRunner to run {@code klass} * @@ -88,12 +88,12 @@ protected boolean isIgnored(FrameworkMethod child) { @Override protected Description describeChild(FrameworkMethod method) { - Description description = fMethodDescriptions.get(method); + Description description = methodDescriptions.get(method); if (description == null) { description = Description.createTestDescription(getTestClass().getJavaClass(), testName(method), method.getAnnotations()); - fMethodDescriptions.putIfAbsent(method, description); + methodDescriptions.putIfAbsent(method, description); } return description; diff --git a/src/main/java/org/junit/runners/MethodSorters.java b/src/main/java/org/junit/runners/MethodSorters.java index 4900f8827d6a..5821892f0553 100644 --- a/src/main/java/org/junit/runners/MethodSorters.java +++ b/src/main/java/org/junit/runners/MethodSorters.java @@ -29,13 +29,13 @@ public enum MethodSorters { */ DEFAULT(MethodSorter.DEFAULT); - private final Comparator fComparator; + private final Comparator comparator; private MethodSorters(Comparator comparator) { - this.fComparator = comparator; + this.comparator = comparator; } public Comparator getComparator() { - return fComparator; + return comparator; } } diff --git a/src/main/java/org/junit/runners/Parameterized.java b/src/main/java/org/junit/runners/Parameterized.java index 527482055fe0..a2f0f2d04a92 100644 --- a/src/main/java/org/junit/runners/Parameterized.java +++ b/src/main/java/org/junit/runners/Parameterized.java @@ -232,7 +232,7 @@ public class Parameterized extends Suite { private static final List NO_RUNNERS = Collections.emptyList(); - private final List fRunners; + private final List runners; /** * Only called reflectively. Do not use programmatically. @@ -243,7 +243,7 @@ public Parameterized(Class klass) throws Throwable { klass); Parameters parameters = getParametersMethod().getAnnotation( Parameters.class); - fRunners = Collections.unmodifiableList(createRunnersForParameters( + runners = Collections.unmodifiableList(createRunnersForParameters( allParameters(), parameters.name(), runnerFactory)); } @@ -262,7 +262,7 @@ private ParametersRunnerFactory getParametersRunnerFactory(Class klass) @Override protected List getChildren() { - return fRunners; + return runners; } private TestWithParameters createTestWithNotNormalizedParameters( diff --git a/src/main/java/org/junit/runners/ParentRunner.java b/src/main/java/org/junit/runners/ParentRunner.java index 337383ac30f8..9ffdd7cc788f 100755 --- a/src/main/java/org/junit/runners/ParentRunner.java +++ b/src/main/java/org/junit/runners/ParentRunner.java @@ -60,13 +60,13 @@ public abstract class ParentRunner extends Runner implements Filterable, private static final List VALIDATORS = Arrays.asList( new AnnotationsValidator(), new PublicClassValidator()); - private final Object fChildrenLock = new Object(); - private final TestClass fTestClass; + private final Object childrenLock = new Object(); + private final TestClass testClass; - // Guarded by fChildrenLock - private volatile Collection fFilteredChildren = null; + // Guarded by childrenLock + private volatile Collection filteredChildren = null; - private volatile RunnerScheduler fScheduler = new RunnerScheduler() { + private volatile RunnerScheduler scheduler = new RunnerScheduler() { public void schedule(Runnable childStatement) { childStatement.run(); } @@ -80,7 +80,7 @@ public void finished() { * Constructs a new {@code ParentRunner} that will run {@code @TestClass} */ protected ParentRunner(Class testClass) throws InitializationError { - fTestClass = createTestClass(testClass); + this.testClass = createTestClass(testClass); validate(); } @@ -211,7 +211,7 @@ private boolean areAllChildrenIgnored() { * Exception, stop execution and pass the exception on. */ protected Statement withBeforeClasses(Statement statement) { - List befores = fTestClass + List befores = testClass .getAnnotatedMethods(BeforeClass.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); @@ -225,7 +225,7 @@ protected Statement withBeforeClasses(Statement statement) { * {@link org.junit.runners.model.MultipleFailureException}. */ protected Statement withAfterClasses(Statement statement) { - List afters = fTestClass + List afters = testClass .getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); @@ -251,8 +251,8 @@ private Statement withClassRules(Statement statement) { * each method in the tested class. */ protected List classRules() { - List result = fTestClass.getAnnotatedMethodValues(null, ClassRule.class, TestRule.class); - result.addAll(fTestClass.getAnnotatedFieldValues(null, ClassRule.class, TestRule.class)); + List result = testClass.getAnnotatedMethodValues(null, ClassRule.class, TestRule.class); + result.addAll(testClass.getAnnotatedFieldValues(null, ClassRule.class, TestRule.class)); return result; } @@ -282,17 +282,17 @@ protected boolean isIgnored(T child) { } private void runChildren(final RunNotifier notifier) { - final RunnerScheduler scheduler = fScheduler; + final RunnerScheduler currentScheduler = scheduler; try { for (final T each : getFilteredChildren()) { - scheduler.schedule(new Runnable() { + currentScheduler.schedule(new Runnable() { public void run() { ParentRunner.this.runChild(each, notifier); } }); } } finally { - scheduler.finished(); + currentScheduler.finished(); } } @@ -300,7 +300,7 @@ public void run() { * Returns a name used to describe this Runner */ protected String getName() { - return fTestClass.getName(); + return testClass.getName(); } // @@ -311,7 +311,7 @@ protected String getName() { * Returns a {@link TestClass} object wrapping the class to be executed. */ public final TestClass getTestClass() { - return fTestClass; + return testClass; } /** @@ -337,7 +337,7 @@ protected final void runLeaf(Statement statement, Description description, * description. */ protected Annotation[] getRunnerAnnotations() { - return fTestClass.getAnnotations(); + return testClass.getAnnotations(); } // @@ -375,9 +375,9 @@ public void run(final RunNotifier notifier) { // public void filter(Filter filter) throws NoTestsRemainException { - synchronized (fChildrenLock) { - List filteredChildren = new ArrayList(getFilteredChildren()); - for (Iterator iter = filteredChildren.iterator(); iter.hasNext(); ) { + synchronized (childrenLock) { + List children = new ArrayList(getFilteredChildren()); + for (Iterator iter = children.iterator(); iter.hasNext(); ) { T each = iter.next(); if (shouldRun(filter, each)) { try { @@ -389,21 +389,21 @@ public void filter(Filter filter) throws NoTestsRemainException { iter.remove(); } } - fFilteredChildren = Collections.unmodifiableCollection(filteredChildren); - if (fFilteredChildren.isEmpty()) { + filteredChildren = Collections.unmodifiableCollection(children); + if (filteredChildren.isEmpty()) { throw new NoTestsRemainException(); } } } public void sort(Sorter sorter) { - synchronized (fChildrenLock) { + synchronized (childrenLock) { for (T each : getFilteredChildren()) { sorter.apply(each); } List sortedChildren = new ArrayList(getFilteredChildren()); Collections.sort(sortedChildren, comparator(sorter)); - fFilteredChildren = Collections.unmodifiableCollection(sortedChildren); + filteredChildren = Collections.unmodifiableCollection(sortedChildren); } } @@ -420,14 +420,14 @@ private void validate() throws InitializationError { } private Collection getFilteredChildren() { - if (fFilteredChildren == null) { - synchronized (fChildrenLock) { - if (fFilteredChildren == null) { - fFilteredChildren = Collections.unmodifiableCollection(getChildren()); + if (filteredChildren == null) { + synchronized (childrenLock) { + if (filteredChildren == null) { + filteredChildren = Collections.unmodifiableCollection(getChildren()); } } } - return fFilteredChildren; + return filteredChildren; } private boolean shouldRun(Filter filter, T each) { @@ -447,6 +447,6 @@ public int compare(T o1, T o2) { * of children. Highly experimental feature that may change. */ public void setScheduler(RunnerScheduler scheduler) { - this.fScheduler = scheduler; + this.scheduler = scheduler; } } diff --git a/src/main/java/org/junit/runners/Suite.java b/src/main/java/org/junit/runners/Suite.java index 75819137320a..b37179f4fa0b 100644 --- a/src/main/java/org/junit/runners/Suite.java +++ b/src/main/java/org/junit/runners/Suite.java @@ -58,7 +58,7 @@ private static Class[] getAnnotatedClasses(Class klass) throws Initializat return annotation.value(); } - private final List fRunners; + private final List runners; /** * Called reflectively on classes annotated with @RunWith(Suite.class) @@ -110,12 +110,12 @@ protected Suite(RunnerBuilder builder, Class klass, Class[] suiteClasses) */ protected Suite(Class klass, List runners) throws InitializationError { super(klass); - fRunners = Collections.unmodifiableList(runners); + this.runners = Collections.unmodifiableList(runners); } @Override protected List getChildren() { - return fRunners; + return runners; } @Override diff --git a/src/main/java/org/junit/runners/model/FrameworkField.java b/src/main/java/org/junit/runners/model/FrameworkField.java index f21b95006488..81a350db46c3 100644 --- a/src/main/java/org/junit/runners/model/FrameworkField.java +++ b/src/main/java/org/junit/runners/model/FrameworkField.java @@ -12,14 +12,14 @@ * @since 4.7 */ public class FrameworkField extends FrameworkMember { - private final Field fField; + private final Field field; FrameworkField(Field field) { if (field == null) { throw new NullPointerException( "FrameworkField cannot be created without an underlying field."); } - fField = field; + this.field = field; } @Override @@ -28,7 +28,7 @@ public String getName() { } public Annotation[] getAnnotations() { - return fField.getAnnotations(); + return field.getAnnotations(); } @Override @@ -38,14 +38,14 @@ public boolean isShadowedBy(FrameworkField otherMember) { @Override protected int getModifiers() { - return fField.getModifiers(); + return field.getModifiers(); } /** * @return the underlying java Field */ public Field getField() { - return fField; + return field; } /** @@ -54,23 +54,23 @@ public Field getField() { */ @Override public Class getType() { - return fField.getType(); + return field.getType(); } @Override public Class getDeclaringClass() { - return fField.getDeclaringClass(); + return field.getDeclaringClass(); } /** * Attempts to retrieve the value of this field on {@code target} */ public Object get(Object target) throws IllegalArgumentException, IllegalAccessException { - return fField.get(target); + return field.get(target); } @Override public String toString() { - return fField.toString(); + return field.toString(); } } diff --git a/src/main/java/org/junit/runners/model/FrameworkMethod.java b/src/main/java/org/junit/runners/model/FrameworkMethod.java index 8471a2096527..3580052ed957 100644 --- a/src/main/java/org/junit/runners/model/FrameworkMethod.java +++ b/src/main/java/org/junit/runners/model/FrameworkMethod.java @@ -17,7 +17,7 @@ * @since 4.5 */ public class FrameworkMethod extends FrameworkMember { - private final Method fMethod; + private final Method method; /** * Returns a new {@code FrameworkMethod} for {@code method} @@ -27,14 +27,14 @@ public FrameworkMethod(Method method) { throw new NullPointerException( "FrameworkMethod cannot be created without an underlying method."); } - fMethod = method; + this.method = method; } /** * Returns the underlying Java method */ public Method getMethod() { - return fMethod; + return method; } /** @@ -47,7 +47,7 @@ public Object invokeExplosively(final Object target, final Object... params) return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { - return fMethod.invoke(target, params); + return method.invoke(target, params); } }.run(); } @@ -57,7 +57,7 @@ protected Object runReflectiveCall() throws Throwable { */ @Override public String getName() { - return fMethod.getName(); + return method.getName(); } /** @@ -72,8 +72,8 @@ public String getName() { */ public void validatePublicVoidNoArg(boolean isStatic, List errors) { validatePublicVoid(isStatic, errors); - if (fMethod.getParameterTypes().length != 0) { - errors.add(new Exception("Method " + fMethod.getName() + " should have no parameters")); + if (method.getParameterTypes().length != 0) { + errors.add(new Exception("Method " + method.getName() + " should have no parameters")); } } @@ -90,26 +90,26 @@ public void validatePublicVoidNoArg(boolean isStatic, List errors) { public void validatePublicVoid(boolean isStatic, List errors) { if (isStatic() != isStatic) { String state = isStatic ? "should" : "should not"; - errors.add(new Exception("Method " + fMethod.getName() + "() " + state + " be static")); + errors.add(new Exception("Method " + method.getName() + "() " + state + " be static")); } if (!isPublic()) { - errors.add(new Exception("Method " + fMethod.getName() + "() should be public")); + errors.add(new Exception("Method " + method.getName() + "() should be public")); } - if (fMethod.getReturnType() != Void.TYPE) { - errors.add(new Exception("Method " + fMethod.getName() + "() should be void")); + if (method.getReturnType() != Void.TYPE) { + errors.add(new Exception("Method " + method.getName() + "() should be void")); } } @Override protected int getModifiers() { - return fMethod.getModifiers(); + return method.getModifiers(); } /** * Returns the return type of the method */ public Class getReturnType() { - return fMethod.getReturnType(); + return method.getReturnType(); } /** @@ -125,11 +125,11 @@ public Class getType() { */ @Override public Class getDeclaringClass() { - return fMethod.getDeclaringClass(); + return method.getDeclaringClass(); } public void validateNoTypeParametersOnArgs(List errors) { - new NoGenericTypeParametersValidator(fMethod).validate(errors); + new NoGenericTypeParametersValidator(method).validate(errors); } @Override @@ -153,12 +153,12 @@ public boolean equals(Object obj) { if (!FrameworkMethod.class.isInstance(obj)) { return false; } - return ((FrameworkMethod) obj).fMethod.equals(fMethod); + return ((FrameworkMethod) obj).method.equals(method); } @Override public int hashCode() { - return fMethod.hashCode(); + return method.hashCode(); } /** @@ -173,18 +173,18 @@ public int hashCode() { @Deprecated public boolean producesType(Type type) { return getParameterTypes().length == 0 && type instanceof Class - && ((Class) type).isAssignableFrom(fMethod.getReturnType()); + && ((Class) type).isAssignableFrom(method.getReturnType()); } private Class[] getParameterTypes() { - return fMethod.getParameterTypes(); + return method.getParameterTypes(); } /** * Returns the annotations on this method */ public Annotation[] getAnnotations() { - return fMethod.getAnnotations(); + return method.getAnnotations(); } /** @@ -192,11 +192,11 @@ public Annotation[] getAnnotations() { * one exists. */ public T getAnnotation(Class annotationType) { - return fMethod.getAnnotation(annotationType); + return method.getAnnotation(annotationType); } @Override public String toString() { - return fMethod.toString(); + return method.toString(); } } diff --git a/src/main/java/org/junit/runners/model/InitializationError.java b/src/main/java/org/junit/runners/model/InitializationError.java index f3fb184cb084..088aa5bec29c 100644 --- a/src/main/java/org/junit/runners/model/InitializationError.java +++ b/src/main/java/org/junit/runners/model/InitializationError.java @@ -10,14 +10,14 @@ */ public class InitializationError extends Exception { private static final long serialVersionUID = 1L; - private final List fErrors; + private final List errors; /** * Construct a new {@code InitializationError} with one or more * errors {@code errors} as causes */ public InitializationError(List errors) { - fErrors = errors; + this.errors = errors; } public InitializationError(Throwable error) { @@ -36,6 +36,6 @@ public InitializationError(String string) { * Returns one or more Throwables that led to this initialization error. */ public List getCauses() { - return fErrors; + return errors; } } diff --git a/src/main/java/org/junit/runners/model/MultipleFailureException.java b/src/main/java/org/junit/runners/model/MultipleFailureException.java index 40eb0af87fed..7e1ea7c533e0 100644 --- a/src/main/java/org/junit/runners/model/MultipleFailureException.java +++ b/src/main/java/org/junit/runners/model/MultipleFailureException.java @@ -14,21 +14,21 @@ public class MultipleFailureException extends Exception { private static final long serialVersionUID = 1L; - private final List fErrors; + private final List errors; public MultipleFailureException(List errors) { - fErrors = new ArrayList(errors); + this.errors = new ArrayList(errors); } public List getFailures() { - return Collections.unmodifiableList(fErrors); + return Collections.unmodifiableList(errors); } @Override public String getMessage() { StringBuilder sb = new StringBuilder( - String.format("There were %d errors:", fErrors.size())); - for (Throwable e : fErrors) { + String.format("There were %d errors:", errors.size())); + for (Throwable e : errors) { sb.append(String.format("\n %s(%s)", e.getClass().getName(), e.getMessage())); } return sb.toString(); diff --git a/src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java b/src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java index d73c1a8a9feb..386b7ffabbc7 100644 --- a/src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java +++ b/src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java @@ -9,21 +9,21 @@ import java.util.List; class NoGenericTypeParametersValidator { - private final Method fMethod; + private final Method method; NoGenericTypeParametersValidator(Method method) { - this.fMethod = method; + this.method = method; } void validate(List errors) { - for (Type each : fMethod.getGenericParameterTypes()) { + for (Type each : method.getGenericParameterTypes()) { validateNoTypeParameterOnType(each, errors); } } private void validateNoTypeParameterOnType(Type type, List errors) { if (type instanceof TypeVariable) { - errors.add(new Exception("Method " + fMethod.getName() + errors.add(new Exception("Method " + method.getName() + "() contains unresolved type variable " + type)); } else if (type instanceof ParameterizedType) { validateNoTypeParameterOnParameterizedType((ParameterizedType) type, errors); diff --git a/src/main/java/org/junit/runners/model/TestClass.java b/src/main/java/org/junit/runners/model/TestClass.java index f8ba3ac30e14..1c5ef40749ca 100755 --- a/src/main/java/org/junit/runners/model/TestClass.java +++ b/src/main/java/org/junit/runners/model/TestClass.java @@ -32,19 +32,19 @@ public class TestClass implements Annotatable { private static final FieldComparator FIELD_COMPARATOR = new FieldComparator(); private static final MethodComparator METHOD_COMPARATOR = new MethodComparator(); - private final Class fClass; - private final Map, List> fMethodsForAnnotations; - private final Map, List> fFieldsForAnnotations; + private final Class clazz; + private final Map, List> methodsForAnnotations; + private final Map, List> fieldsForAnnotations; /** - * Creates a {@code TestClass} wrapping {@code klass}. Each time this + * Creates a {@code TestClass} wrapping {@code clazz}. Each time this * constructor executes, the class is scanned for annotations, which can be * an expensive process (we hope in future JDK's it will not be.) Therefore, * try to share instances of {@code TestClass} where possible. */ - public TestClass(Class klass) { - fClass = klass; - if (klass != null && klass.getConstructors().length > 1) { + public TestClass(Class clazz) { + this.clazz = clazz; + if (clazz != null && clazz.getConstructors().length > 1) { throw new IllegalArgumentException( "Test class can only have one constructor"); } @@ -56,12 +56,12 @@ public TestClass(Class klass) { scanAnnotatedMembers(methodsForAnnotations, fieldsForAnnotations); - fMethodsForAnnotations = makeDeeplyUnmodifiable(methodsForAnnotations); - fFieldsForAnnotations = makeDeeplyUnmodifiable(fieldsForAnnotations); + this.methodsForAnnotations = makeDeeplyUnmodifiable(methodsForAnnotations); + this.fieldsForAnnotations = makeDeeplyUnmodifiable(fieldsForAnnotations); } protected void scanAnnotatedMembers(Map, List> methodsForAnnotations, Map, List> fieldsForAnnotations) { - for (Class eachClass : getSuperClasses(fClass)) { + for (Class eachClass : getSuperClasses(clazz)) { for (Method eachMethod : MethodSorter.getDeclaredMethods(eachClass)) { addToAnnotationLists(new FrameworkMethod(eachMethod), methodsForAnnotations); } @@ -112,7 +112,7 @@ protected static > void addToAnnotationLists(T memb * @since 4.12 */ public List getAnnotatedMethods() { - List methods = collectValues(fMethodsForAnnotations); + List methods = collectValues(methodsForAnnotations); Collections.sort(methods, METHOD_COMPARATOR); return methods; } @@ -123,7 +123,7 @@ public List getAnnotatedMethods() { */ public List getAnnotatedMethods( Class annotationClass) { - return Collections.unmodifiableList(getAnnotatedMembers(fMethodsForAnnotations, annotationClass, false)); + return Collections.unmodifiableList(getAnnotatedMembers(methodsForAnnotations, annotationClass, false)); } /** @@ -133,7 +133,7 @@ public List getAnnotatedMethods( * @since 4.12 */ public List getAnnotatedFields() { - return collectValues(fFieldsForAnnotations); + return collectValues(fieldsForAnnotations); } /** @@ -142,7 +142,7 @@ public List getAnnotatedFields() { */ public List getAnnotatedFields( Class annotationClass) { - return Collections.unmodifiableList(getAnnotatedMembers(fFieldsForAnnotations, annotationClass, false)); + return Collections.unmodifiableList(getAnnotatedMembers(fieldsForAnnotations, annotationClass, false)); } private List collectValues(Map> map) { @@ -181,17 +181,17 @@ private static List> getSuperClasses(Class testClass) { * Returns the underlying Java class. */ public Class getJavaClass() { - return fClass; + return clazz; } /** * Returns the class's name. */ public String getName() { - if (fClass == null) { + if (clazz == null) { return "null"; } - return fClass.getName(); + return clazz.getName(); } /** @@ -200,7 +200,7 @@ public String getName() { */ public Constructor getOnlyConstructor() { - Constructor[] constructors = fClass.getConstructors(); + Constructor[] constructors = clazz.getConstructors(); Assert.assertEquals(1, constructors.length); return constructors[0]; } @@ -209,10 +209,10 @@ public Constructor getOnlyConstructor() { * Returns the annotations on this class */ public Annotation[] getAnnotations() { - if (fClass == null) { + if (clazz == null) { return new Annotation[0]; } - return fClass.getAnnotations(); + return clazz.getAnnotations(); } public List getAnnotatedFieldValues(Object test, @@ -250,16 +250,16 @@ public List getAnnotatedMethodValues(Object test, } public boolean isPublic() { - return Modifier.isPublic(fClass.getModifiers()); + return Modifier.isPublic(clazz.getModifiers()); } public boolean isANonStaticInnerClass() { - return fClass.isMemberClass() && !isStatic(fClass.getModifiers()); + return clazz.isMemberClass() && !isStatic(clazz.getModifiers()); } @Override public int hashCode() { - return (fClass == null) ? 0 : fClass.hashCode(); + return (clazz == null) ? 0 : clazz.hashCode(); } @Override @@ -274,7 +274,7 @@ public boolean equals(Object obj) { return false; } TestClass other = (TestClass) obj; - return fClass == other.fClass; + return clazz == other.clazz; } /** diff --git a/src/main/java/org/junit/runners/model/TestTimedOutException.java b/src/main/java/org/junit/runners/model/TestTimedOutException.java index 13a7ad4a80f6..60e1a8aa9001 100644 --- a/src/main/java/org/junit/runners/model/TestTimedOutException.java +++ b/src/main/java/org/junit/runners/model/TestTimedOutException.java @@ -12,8 +12,8 @@ public class TestTimedOutException extends Exception { private static final long serialVersionUID = 31935685163547539L; - private final TimeUnit fTimeUnit; - private final long fTimeout; + private final TimeUnit timeUnit; + private final long timeout; /** * Creates exception with a standard message "test timed out after [timeout] [timeUnit]" @@ -24,21 +24,21 @@ public class TestTimedOutException extends Exception { public TestTimedOutException(long timeout, TimeUnit timeUnit) { super(String.format("test timed out after %d %s", timeout, timeUnit.name().toLowerCase())); - fTimeUnit = timeUnit; - fTimeout = timeout; + this.timeUnit = timeUnit; + this.timeout = timeout; } /** * Gets the time passed before the test was interrupted */ public long getTimeout() { - return fTimeout; + return timeout; } /** * Gets the time unit for the timeout value */ public TimeUnit getTimeUnit() { - return fTimeUnit; + return timeUnit; } } diff --git a/src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParameters.java b/src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParameters.java index e1b47954d19a..1c49f84f0178 100644 --- a/src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParameters.java +++ b/src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParameters.java @@ -18,16 +18,16 @@ */ public class BlockJUnit4ClassRunnerWithParameters extends BlockJUnit4ClassRunner { - private final Object[] fParameters; + private final Object[] parameters; - private final String fName; + private final String name; public BlockJUnit4ClassRunnerWithParameters(TestWithParameters test) throws InitializationError { super(test.getTestClass().getJavaClass()); - fParameters = test.getParameters().toArray( + parameters = test.getParameters().toArray( new Object[test.getParameters().size()]); - fName = test.getName(); + name = test.getName(); } @Override @@ -40,17 +40,17 @@ public Object createTest() throws Exception { } private Object createTestUsingConstructorInjection() throws Exception { - return getTestClass().getOnlyConstructor().newInstance(fParameters); + return getTestClass().getOnlyConstructor().newInstance(parameters); } private Object createTestUsingFieldInjection() throws Exception { List annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); - if (annotatedFieldsByParameter.size() != fParameters.length) { + if (annotatedFieldsByParameter.size() != parameters.length) { throw new Exception( "Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size() - + ", available parameters: " + fParameters.length + + ", available parameters: " + parameters.length + "."); } Object testClassInstance = getTestClass().getJavaClass().newInstance(); @@ -59,13 +59,13 @@ private Object createTestUsingFieldInjection() throws Exception { Parameter annotation = field.getAnnotation(Parameter.class); int index = annotation.value(); try { - field.set(testClassInstance, fParameters[index]); + field.set(testClassInstance, parameters[index]); } catch (IllegalArgumentException iare) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() - + " with the value " + fParameters[index] + + " with the value " + parameters[index] + " that is not the right type (" - + fParameters[index].getClass().getSimpleName() + + parameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").", iare); } @@ -75,7 +75,7 @@ private Object createTestUsingFieldInjection() throws Exception { @Override protected String getName() { - return fName; + return name; } @Override diff --git a/src/main/java/org/junit/runners/parameterized/TestWithParameters.java b/src/main/java/org/junit/runners/parameterized/TestWithParameters.java index 52dae5fa2557..1b86644a2940 100644 --- a/src/main/java/org/junit/runners/parameterized/TestWithParameters.java +++ b/src/main/java/org/junit/runners/parameterized/TestWithParameters.java @@ -15,40 +15,40 @@ * @since 4.12 */ public class TestWithParameters { - private final String fName; + private final String name; - private final TestClass fTestClass; + private final TestClass testClass; - private final List fParameters; + private final List parameters; public TestWithParameters(String name, TestClass testClass, List parameters) { notNull(name, "The name is missing."); notNull(testClass, "The test class is missing."); notNull(parameters, "The parameters are missing."); - fName = name; - fTestClass = testClass; - fParameters = unmodifiableList(new ArrayList(parameters)); + this.name = name; + this.testClass = testClass; + this.parameters = unmodifiableList(new ArrayList(parameters)); } public String getName() { - return fName; + return name; } public TestClass getTestClass() { - return fTestClass; + return testClass; } public List getParameters() { - return fParameters; + return parameters; } @Override public int hashCode() { int prime = 14747; - int result = prime + fName.hashCode(); - result = prime * result + fTestClass.hashCode(); - return prime * result + fParameters.hashCode(); + int result = prime + name.hashCode(); + result = prime * result + testClass.hashCode(); + return prime * result + parameters.hashCode(); } @Override @@ -63,15 +63,15 @@ public boolean equals(Object obj) { return false; } TestWithParameters other = (TestWithParameters) obj; - return fName.equals(other.fName) - && fParameters.equals(other.fParameters) - && fTestClass.equals(other.fTestClass); + return name.equals(other.name) + && parameters.equals(other.parameters) + && testClass.equals(other.testClass); } @Override public String toString() { - return fTestClass.getName() + " '" + fName + "' with parameters " - + fParameters; + return testClass.getName() + " '" + name + "' with parameters " + + parameters; } private static void notNull(Object value, String message) {