Skip to content

Commit df00d5e

Browse files
Alex Yurshastefanbirkner
Alex Yursha
authored andcommitted
remove 'f' prefix from field names, add LEGACY_CODING_STYLE, change CODING_STYLE
1 parent 63b1950 commit df00d5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+534
-530
lines changed

CODING_STYLE.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
JUnit project uses the Google Java Style (http://google-styleguide.googlecode.com/svn/trunk/javaguide.html) for all new
2+
code (under org.junit.*). Legacy code (under junit.*) used the legacy guide specified in LEGACY_CODING_STYLE.txt in the
3+
project root.
File renamed without changes.

src/main/java/org/junit/experimental/ParallelComputer.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import org.junit.runners.model.RunnerScheduler;
1313

1414
public class ParallelComputer extends Computer {
15-
private final boolean fClasses;
15+
private final boolean classes;
1616

17-
private final boolean fMethods;
17+
private final boolean methods;
1818

1919
public ParallelComputer(boolean classes, boolean methods) {
20-
fClasses = classes;
21-
fMethods = methods;
20+
this.classes = classes;
21+
this.methods = methods;
2222
}
2323

2424
public static Computer classes() {
@@ -55,13 +55,13 @@ public void finished() {
5555
public Runner getSuite(RunnerBuilder builder, java.lang.Class<?>[] classes)
5656
throws InitializationError {
5757
Runner suite = super.getSuite(builder, classes);
58-
return fClasses ? parallelize(suite) : suite;
58+
return this.classes ? parallelize(suite) : suite;
5959
}
6060

6161
@Override
6262
protected Runner getRunner(RunnerBuilder builder, Class<?> testClass)
6363
throws Throwable {
6464
Runner runner = super.getRunner(builder, testClass);
65-
return fMethods ? parallelize(runner) : runner;
65+
return methods ? parallelize(runner) : runner;
6666
}
6767
}

src/main/java/org/junit/experimental/categories/Categories.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ public class Categories extends Suite {
115115
}
116116

117117
public static class CategoryFilter extends Filter {
118-
private final Set<Class<?>> fIncluded;
119-
private final Set<Class<?>> fExcluded;
120-
private final boolean fIncludedAny;
121-
private final boolean fExcludedAny;
118+
private final Set<Class<?>> included;
119+
private final Set<Class<?>> excluded;
120+
private final boolean includedAny;
121+
private final boolean excludedAny;
122122

123123
public static CategoryFilter include(boolean matchAny, Class<?>... categories) {
124124
if (hasNull(categories)) {
@@ -157,10 +157,10 @@ public static CategoryFilter categoryFilter(boolean matchAnyInclusions, Set<Clas
157157

158158
protected CategoryFilter(boolean matchAnyIncludes, Set<Class<?>> includes,
159159
boolean matchAnyExcludes, Set<Class<?>> excludes) {
160-
fIncludedAny= matchAnyIncludes;
161-
fExcludedAny= matchAnyExcludes;
162-
fIncluded= copyAndRefine(includes);
163-
fExcluded= copyAndRefine(excludes);
160+
includedAny = matchAnyIncludes;
161+
excludedAny = matchAnyExcludes;
162+
included = copyAndRefine(includes);
163+
excluded = copyAndRefine(excludes);
164164
}
165165

166166
/**
@@ -186,9 +186,9 @@ public String describe() {
186186
*/
187187
@Override public String toString() {
188188
StringBuilder description= new StringBuilder("categories ")
189-
.append(fIncluded.isEmpty() ? "[all]" : fIncluded);
190-
if (!fExcluded.isEmpty()) {
191-
description.append(" - ").append(fExcluded);
189+
.append(included.isEmpty() ? "[all]" : included);
190+
if (!excluded.isEmpty()) {
191+
description.append(" - ").append(excluded);
192192
}
193193
return description.toString();
194194
}
@@ -213,29 +213,29 @@ private boolean hasCorrectCategoryAnnotation(Description description) {
213213

214214
// If a child has no categories, immediately return.
215215
if (childCategories.isEmpty()) {
216-
return fIncluded.isEmpty();
216+
return included.isEmpty();
217217
}
218218

219-
if (!fExcluded.isEmpty()) {
220-
if (fExcludedAny) {
221-
if (matchesAnyParentCategories(childCategories, fExcluded)) {
219+
if (!excluded.isEmpty()) {
220+
if (excludedAny) {
221+
if (matchesAnyParentCategories(childCategories, excluded)) {
222222
return false;
223223
}
224224
} else {
225-
if (matchesAllParentCategories(childCategories, fExcluded)) {
225+
if (matchesAllParentCategories(childCategories, excluded)) {
226226
return false;
227227
}
228228
}
229229
}
230230

231-
if (fIncluded.isEmpty()) {
231+
if (included.isEmpty()) {
232232
// Couldn't be excluded, and with no suite's included categories treated as should run.
233233
return true;
234234
} else {
235-
if (fIncludedAny) {
236-
return matchesAnyParentCategories(childCategories, fIncluded);
235+
if (includedAny) {
236+
return matchesAnyParentCategories(childCategories, included);
237237
} else {
238-
return matchesAllParentCategories(childCategories, fIncluded);
238+
return matchesAllParentCategories(childCategories, included);
239239
}
240240
}
241241
}

src/main/java/org/junit/experimental/max/MaxCore.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public static MaxCore storedLocally(File storedResults) {
4949
return new MaxCore(storedResults);
5050
}
5151

52-
private final MaxHistory fHistory;
52+
private final MaxHistory history;
5353

5454
private MaxCore(File storedResults) {
55-
fHistory = MaxHistory.forFolder(storedResults);
55+
history = MaxHistory.forFolder(storedResults);
5656
}
5757

5858
/**
@@ -85,7 +85,7 @@ public Result run(Request request) {
8585
* @return a {@link Result} describing the details of the test run and the failed tests.
8686
*/
8787
public Result run(Request request, JUnitCore core) {
88-
core.addListener(fHistory.listener());
88+
core.addListener(history.listener());
8989
return core.run(sortRequest(request).getRunner());
9090
}
9191

@@ -98,7 +98,7 @@ public Request sortRequest(Request request) {
9898
return request;
9999
}
100100
List<Description> leaves = findLeaves(request);
101-
Collections.sort(leaves, fHistory.testComparator());
101+
Collections.sort(leaves, history.testComparator());
102102
return constructLeafRequest(leaves);
103103
}
104104

src/main/java/org/junit/experimental/max/MaxHistory.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,41 @@ private static MaxHistory readHistory(File storedResults)
6161
}
6262
}
6363

64-
private final Map<String, Long> fDurations = new HashMap<String, Long>();
64+
private final Map<String, Long> durations = new HashMap<String, Long>();
6565

66-
private final Map<String, Long> fFailureTimestamps = new HashMap<String, Long>();
66+
private final Map<String, Long> failureTimestamps = new HashMap<String, Long>();
6767

68-
private final File fHistoryStore;
68+
private final File historyStore;
6969

7070
private MaxHistory(File storedResults) {
71-
fHistoryStore = storedResults;
71+
historyStore = storedResults;
7272
}
7373

7474
private void save() throws IOException {
7575
ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(
76-
fHistoryStore));
76+
historyStore));
7777
stream.writeObject(this);
7878
stream.close();
7979
}
8080

8181
Long getFailureTimestamp(Description key) {
82-
return fFailureTimestamps.get(key.toString());
82+
return failureTimestamps.get(key.toString());
8383
}
8484

8585
void putTestFailureTimestamp(Description key, long end) {
86-
fFailureTimestamps.put(key.toString(), end);
86+
failureTimestamps.put(key.toString(), end);
8787
}
8888

8989
boolean isNewTest(Description key) {
90-
return !fDurations.containsKey(key.toString());
90+
return !durations.containsKey(key.toString());
9191
}
9292

9393
Long getTestDuration(Description key) {
94-
return fDurations.get(key.toString());
94+
return durations.get(key.toString());
9595
}
9696

9797
void putTestDuration(Description description, long duration) {
98-
fDurations.put(description.toString(), duration);
98+
durations.put(description.toString(), duration);
9999
}
100100

101101
private final class RememberingListener extends RunListener {

src/main/java/org/junit/experimental/theories/Theories.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,27 @@ public Statement methodBlock(final FrameworkMethod method) {
118118
public static class TheoryAnchor extends Statement {
119119
private int successes = 0;
120120

121-
private FrameworkMethod fTestMethod;
122-
private TestClass fTestClass;
121+
private final FrameworkMethod testMethod;
122+
private final TestClass testClass;
123123

124124
private List<AssumptionViolatedException> fInvalidParameters = new ArrayList<AssumptionViolatedException>();
125125

126-
public TheoryAnchor(FrameworkMethod method, TestClass testClass) {
127-
fTestMethod = method;
128-
fTestClass = testClass;
126+
public TheoryAnchor(FrameworkMethod testMethod, TestClass testClass) {
127+
this.testMethod = testMethod;
128+
this.testClass = testClass;
129129
}
130130

131131
private TestClass getTestClass() {
132-
return fTestClass;
132+
return testClass;
133133
}
134134

135135
@Override
136136
public void evaluate() throws Throwable {
137137
runWithAssignment(Assignments.allUnassigned(
138-
fTestMethod.getMethod(), getTestClass()));
138+
testMethod.getMethod(), getTestClass()));
139139

140140
//if this test method is not annotated with Theory, then no successes is a valid case
141-
boolean hasTheoryAnnotation = fTestMethod.getAnnotation(Theory.class) != null;
141+
boolean hasTheoryAnnotation = testMethod.getAnnotation(Theory.class) != null;
142142
if (successes == 0 && hasTheoryAnnotation) {
143143
Assert
144144
.fail("Never found parameters that satisfied method assumptions. Violated assumptions: "
@@ -207,7 +207,7 @@ public Object createTest() throws Exception {
207207

208208
return getTestClass().getOnlyConstructor().newInstance(params);
209209
}
210-
}.methodBlock(fTestMethod).evaluate();
210+
}.methodBlock(testMethod).evaluate();
211211
}
212212

213213
private Statement methodCompletesWithParameters(
@@ -235,12 +235,12 @@ protected void reportParameterizedError(Throwable e, Object... params)
235235
if (params.length == 0) {
236236
throw e;
237237
}
238-
throw new ParameterizedAssertionError(e, fTestMethod.getName(),
238+
throw new ParameterizedAssertionError(e, testMethod.getName(),
239239
params);
240240
}
241241

242242
private boolean nullsOk() {
243-
Theory annotation = fTestMethod.getMethod().getAnnotation(
243+
Theory annotation = testMethod.getMethod().getAnnotation(
244244
Theory.class);
245245
if (annotation == null) {
246246
return false;

src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@
2222
*/
2323
public class AllMembersSupplier extends ParameterSupplier {
2424
static class MethodParameterValue extends PotentialAssignment {
25-
private final FrameworkMethod fMethod;
25+
private final FrameworkMethod method;
2626

2727
private MethodParameterValue(FrameworkMethod dataPointMethod) {
28-
fMethod = dataPointMethod;
28+
method = dataPointMethod;
2929
}
3030

3131
@Override
3232
public Object getValue() throws CouldNotGenerateValueException {
3333
try {
34-
return fMethod.invokeExplosively(null);
34+
return method.invokeExplosively(null);
3535
} catch (IllegalArgumentException e) {
3636
throw new RuntimeException(
3737
"unexpected: argument length is checked");
3838
} catch (IllegalAccessException e) {
3939
throw new RuntimeException(
4040
"unexpected: getMethods returned an inaccessible method");
4141
} catch (Throwable throwable) {
42-
DataPoint annotation = fMethod.getAnnotation(DataPoint.class);
42+
DataPoint annotation = method.getAnnotation(DataPoint.class);
4343
Assume.assumeTrue(annotation == null || !isAssignableToAnyOf(annotation.ignoredExceptions(), throwable));
4444

4545
throw new CouldNotGenerateValueException(throwable);
@@ -48,17 +48,17 @@ public Object getValue() throws CouldNotGenerateValueException {
4848

4949
@Override
5050
public String getDescription() throws CouldNotGenerateValueException {
51-
return fMethod.getName();
51+
return method.getName();
5252
}
5353
}
5454

55-
private final TestClass fClass;
55+
private final TestClass clazz;
5656

5757
/**
5858
* Constructs a new supplier for {@code type}
5959
*/
6060
public AllMembersSupplier(TestClass type) {
61-
fClass = type;
61+
clazz = type;
6262
}
6363

6464
@Override
@@ -172,11 +172,11 @@ private static boolean isAssignableToAnyOf(Class<?>[] typeArray, Object target)
172172
}
173173

174174
protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {
175-
return fClass.getAnnotatedMethods(DataPoints.class);
175+
return clazz.getAnnotatedMethods(DataPoints.class);
176176
}
177177

178178
protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) {
179-
List<FrameworkField> fields = fClass.getAnnotatedFields(DataPoint.class);
179+
List<FrameworkField> fields = clazz.getAnnotatedFields(DataPoint.class);
180180
Collection<Field> validFields = new ArrayList<Field>();
181181

182182
for (FrameworkField frameworkField : fields) {
@@ -187,7 +187,7 @@ protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) {
187187
}
188188

189189
protected Collection<Field> getDataPointsFields(ParameterSignature sig) {
190-
List<FrameworkField> fields = fClass.getAnnotatedFields(DataPoints.class);
190+
List<FrameworkField> fields = clazz.getAnnotatedFields(DataPoints.class);
191191
Collection<Field> validFields = new ArrayList<Field>();
192192

193193
for (FrameworkField frameworkField : fields) {
@@ -198,7 +198,7 @@ protected Collection<Field> getDataPointsFields(ParameterSignature sig) {
198198
}
199199

200200
protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) {
201-
return fClass.getAnnotatedMethods(DataPoint.class);
201+
return clazz.getAnnotatedMethods(DataPoint.class);
202202
}
203203

204204
}

0 commit comments

Comments
 (0)