Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removef "f" prefixes from field names #1191

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
the project, requires only release versions of dependencies of other artifacts.
-->
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<version>1.4</version>
<executions>
<execution>
<id>enforce-versions</id>
Expand Down Expand Up @@ -211,7 +211,7 @@
java compiler plugin forked in extra process
-->
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${jdkVersion}</source>
Expand All @@ -232,7 +232,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.13</version>
<version>1.14</version>
<executions>
<execution>
<id>signature-check</id>
Expand All @@ -256,7 +256,7 @@
our junit suite "AllTests" after the sources are compiled.
-->
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<version>2.18.1</version>
<configuration>
<test>org/junit/tests/AllTests.java</test>
<useSystemClassLoader>true</useSystemClassLoader>
Expand All @@ -278,7 +278,7 @@
in jar archive target/junit-*-javadoc.jar.
-->
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<version>2.10.3</version>
<configuration>
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
<show>protected</show>
Expand Down Expand Up @@ -311,7 +311,7 @@
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
<useReleaseProfile>false</useReleaseProfile>
Expand All @@ -337,7 +337,7 @@
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<version>2.6</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
Expand All @@ -354,7 +354,7 @@
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<version>2.8</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
<!-- waiting for MPIR-267 -->
Expand All @@ -381,7 +381,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<version>2.10.3</version>
<configuration>
<destDir>javadoc/latest</destDir>
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
Expand Down Expand Up @@ -440,7 +440,7 @@
(&ndash;&ndash; stands for double dash)
-->
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>1.6</version>
<executions>
<execution>
<id>gpg-sign</id>
Expand Down Expand Up @@ -540,7 +540,7 @@
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18</version>
<version>2.18.1</version>
</dependency>
</dependencies>
</plugin>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/junit/ComparisonFailure.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class ComparisonFailure extends AssertionError {
* @see ComparisonCompactor
*/
private static final int MAX_CONTEXT_LENGTH = 20;
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;

/*
* We have to use the f prefix until the next major release to ensure
* serialization compatibility.
* See https://github.com/junit-team/junit/issues/976
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove these comments, too, shouldn't we?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcphilipp Yes. I have removed this comment and all the others that reference the same issue. I have also found another class with an f-prefixed field name and fixed it. Please take a look.

private String fExpected;
private String fActual;
private String expected;
private String actual;

/**
* Constructs a comparison failure.
Expand All @@ -35,8 +35,8 @@ public class ComparisonFailure extends AssertionError {
*/
public ComparisonFailure(String message, String expected, String actual) {
super(message);
this.fExpected = expected;
this.fActual = actual;
this.expected = expected;
this.actual = actual;
}

/**
Expand All @@ -46,7 +46,7 @@ public ComparisonFailure(String message, String expected, String actual) {
*/
@Override
public String getMessage() {
return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
return new ComparisonCompactor(MAX_CONTEXT_LENGTH, expected, actual).compact(super.getMessage());
}

/**
Expand All @@ -55,7 +55,7 @@ public String getMessage() {
* @return the actual string value
*/
public String getActual() {
return fActual;
return actual;
}

/**
Expand All @@ -64,7 +64,7 @@ public String getActual() {
* @return the expected string value
*/
public String getExpected() {
return fExpected;
return expected;
}

private static class ComparisonCompactor {
Expand Down
53 changes: 30 additions & 23 deletions src/main/java/org/junit/experimental/max/MaxHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* </ul>
*/
public class MaxHistory implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;

/**
* Loads a {@link MaxHistory} from {@code file}, or generates a new one that
Expand All @@ -45,60 +45,67 @@ public static MaxHistory forFolder(File file) {
private static MaxHistory readHistory(File storedResults)
throws CouldNotReadCoreException {
try {
FileInputStream file = new FileInputStream(storedResults);
try {
ObjectInputStream stream = new ObjectInputStream(file);
try {
return (MaxHistory) stream.readObject();
} finally {
stream.close();
}
} finally {
file.close();
}
return tryRead(storedResults);
} catch (Exception e) {
throw new CouldNotReadCoreException(e);
}
}

private static MaxHistory tryRead(File storedResults) throws IOException, ClassNotFoundException {
FileInputStream file = new FileInputStream(storedResults);
try {
return readObject(file);
} finally {
file.close();
}
}

private static MaxHistory readObject(FileInputStream file) throws IOException, ClassNotFoundException {
ObjectInputStream stream = new ObjectInputStream(file);
try {
return (MaxHistory) stream.readObject();
} finally {
stream.close();
}
}

/*
* We have to use the f prefix until the next major release to ensure
* serialization compatibility.
* See https://github.com/junit-team/junit/issues/976
*/
private final Map<String, Long> fDurations = new HashMap<String, Long>();
private final Map<String, Long> fFailureTimestamps = new HashMap<String, Long>();
private final File fHistoryStore;
private final Map<String, Long> durations = new HashMap<String, Long>();
private final Map<String, Long> failureTimestamps = new HashMap<String, Long>();
private final File historyStore;

private MaxHistory(File storedResults) {
fHistoryStore = storedResults;
historyStore = storedResults;
}

private void save() throws IOException {
ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(
fHistoryStore));
ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(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 {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/junit/internal/ArrayComparisonFailure.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class ArrayComparisonFailure extends AssertionError {
* serialization compatibility.
* See https://github.com/junit-team/junit/issues/976
*/
private final List<Integer> fIndices = new ArrayList<Integer>();
private final String fMessage;
private final List<Integer> indices = new ArrayList<Integer>();
private final String message;

/**
* Construct a new <code>ArrayComparisonFailure</code> with an error text and the array's
Expand All @@ -31,25 +31,25 @@ public class ArrayComparisonFailure extends AssertionError {
* @see Assert#assertArrayEquals(String, Object[], Object[])
*/
public ArrayComparisonFailure(String message, AssertionError cause, int index) {
this.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 index : indices) {
sb.append("[");
sb.append(each);
sb.append(index);
sb.append("]");
}
sb.append("; ");
Expand Down
51 changes: 29 additions & 22 deletions src/main/java/org/junit/internal/AssumptionViolatedException.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
* @see org.junit.Assume
*/
public class AssumptionViolatedException extends RuntimeException implements SelfDescribing {
private static final long serialVersionUID = 2L;
private static final long serialVersionUID = 3L;

/*
* We have to use the f prefix until the next major release to ensure
* serialization compatibility.
* See https://github.com/junit-team/junit/issues/976
*/
private final String fAssumption;
private final boolean fValueMatcher;
private final Object fValue;
private final Matcher<?> fMatcher;
private final String assumption;
private final boolean hasValue;
private final Object value;
private final Matcher<?> matcher;

/**
* @deprecated Please use {@link org.junit.AssumptionViolatedException} instead.
*/
@Deprecated
public AssumptionViolatedException(String assumption, boolean hasValue, Object value, Matcher<?> matcher) {
this.fAssumption = assumption;
this.fValue = value;
this.fMatcher = matcher;
this.fValueMatcher = hasValue;
this.assumption = assumption;
this.value = value;
this.matcher = matcher;
this.hasValue = hasValue;

if (value instanceof Throwable) {
initCause((Throwable) value);
Expand Down Expand Up @@ -89,23 +89,30 @@ public String getMessage() {
}

public void describeTo(Description description) {
if (fAssumption != null) {
description.appendText(fAssumption);
if (assumption != null) {
description.appendText(assumption);
}

if (fValueMatcher) {
// a value was passed in when this instance was constructed; print it
if (fAssumption != null) {
description.appendText(": ");
}
if (hasValue) {
printValue(description);
printMatcher(description);
}
}

description.appendText("got: ");
description.appendValue(fValue);
private void printValue(Description description) {
// a value was passed in when this instance was constructed; print it
if (assumption != null) {
description.appendText(": ");
}

description.appendText("got: ");
description.appendValue(value);
}

if (fMatcher != null) {
description.appendText(", expected: ");
description.appendDescriptionOf(fMatcher);
}
private void printMatcher(Description description) {
if (matcher != null) {
description.appendText(", expected: ");
description.appendDescriptionOf(matcher);
}
}
}
Loading