diff --git a/src/main/java/org/junit/Assert.java b/src/main/java/org/junit/Assert.java
index d7deb06bb33e..c775035f2d32 100755
--- a/src/main/java/org/junit/Assert.java
+++ b/src/main/java/org/junit/Assert.java
@@ -36,7 +36,7 @@ protected Assert() {
* okay)
* @param condition condition to be checked
*/
- static public void assertTrue(String message, boolean condition) {
+ public static void assertTrue(String message, boolean condition) {
if (!condition) {
fail(message);
}
@@ -48,7 +48,7 @@ static public void assertTrue(String message, boolean condition) {
*
* @param condition condition to be checked
*/
- static public void assertTrue(boolean condition) {
+ public static void assertTrue(boolean condition) {
assertTrue(null, condition);
}
@@ -60,7 +60,7 @@ static public void assertTrue(boolean condition) {
* okay)
* @param condition condition to be checked
*/
- static public void assertFalse(String message, boolean condition) {
+ public static void assertFalse(String message, boolean condition) {
assertTrue(message, !condition);
}
@@ -70,7 +70,7 @@ static public void assertFalse(String message, boolean condition) {
*
* @param condition condition to be checked
*/
- static public void assertFalse(boolean condition) {
+ public static void assertFalse(boolean condition) {
assertFalse(null, condition);
}
@@ -81,7 +81,7 @@ static public void assertFalse(boolean condition) {
* okay)
* @see AssertionError
*/
- static public void fail(String message) {
+ public static void fail(String message) {
if (message == null) {
throw new AssertionError();
}
@@ -91,7 +91,7 @@ static public void fail(String message) {
/**
* Fails a test with no message.
*/
- static public void fail() {
+ public static void fail() {
fail(null);
}
@@ -106,11 +106,12 @@ static public void fail() {
* @param expected expected value
* @param actual actual value
*/
- static public void assertEquals(String message, Object expected,
+ public static void assertEquals(String message, Object expected,
Object actual) {
if (equalsRegardingNull(expected, actual)) {
return;
- } else if (expected instanceof String && actual instanceof String) {
+ }
+ if (expected instanceof String && actual instanceof String) {
String cleanMessage = message == null ? "" : message;
throw new ComparisonFailure(cleanMessage, (String) expected,
(String) actual);
@@ -140,7 +141,7 @@ private static boolean isEquals(Object expected, Object actual) {
* @param expected expected value
* @param actual the value to check against expected
*/
- static public void assertEquals(Object expected, Object actual) {
+ public static void assertEquals(Object expected, Object actual) {
assertEquals(null, expected, actual);
}
@@ -155,7 +156,7 @@ static public void assertEquals(Object expected, Object actual) {
* @param unexpected unexpected value to check
* @param actual the value to check against unexpected
*/
- static public void assertNotEquals(String message, Object unexpected,
+ public static void assertNotEquals(String message, Object unexpected,
Object actual) {
if (equalsRegardingNull(unexpected, actual)) {
failEquals(message, actual);
@@ -171,7 +172,7 @@ static public void assertNotEquals(String message, Object unexpected,
* @param unexpected unexpected value to check
* @param actual the value to check against unexpected
*/
- static public void assertNotEquals(Object unexpected, Object actual) {
+ public static void assertNotEquals(Object unexpected, Object actual) {
assertNotEquals(null, unexpected, actual);
}
@@ -194,7 +195,7 @@ private static void failEquals(String message, Object actual) {
* @param unexpected unexpected value to check
* @param actual the value to check against unexpected
*/
- static public void assertNotEquals(String message, long unexpected, long actual) {
+ public static void assertNotEquals(String message, long unexpected, long actual) {
if (unexpected == actual) {
failEquals(message, Long.valueOf(actual));
}
@@ -207,7 +208,7 @@ static public void assertNotEquals(String message, long unexpected, long actual)
* @param unexpected unexpected value to check
* @param actual the value to check against unexpected
*/
- static public void assertNotEquals(long unexpected, long actual) {
+ public static void assertNotEquals(long unexpected, long actual) {
assertNotEquals(null, unexpected, actual);
}
@@ -226,7 +227,7 @@ static public void assertNotEquals(long unexpected, long actual) {
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertNotEquals(String message, double unexpected,
+ public static void assertNotEquals(String message, double unexpected,
double actual, double delta) {
if (!doubleIsDifferent(unexpected, actual, delta)) {
failEquals(message, Double.valueOf(actual));
@@ -245,7 +246,7 @@ static public void assertNotEquals(String message, double unexpected,
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertNotEquals(double unexpected, double actual, double delta) {
+ public static void assertNotEquals(double unexpected, double actual, double delta) {
assertNotEquals(null, unexpected, actual, delta);
}
@@ -261,7 +262,7 @@ static public void assertNotEquals(double unexpected, double actual, double delt
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertNotEquals(float unexpected, float actual, float delta) {
+ public static void assertNotEquals(float unexpected, float actual, float delta) {
assertNotEquals(null, unexpected, actual, delta);
}
@@ -547,7 +548,7 @@ private static void internalArrayEquals(String message, Object expecteds,
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertEquals(String message, double expected,
+ public static void assertEquals(String message, double expected,
double actual, double delta) {
if (doubleIsDifferent(expected, actual, delta)) {
failNotEquals(message, Double.valueOf(expected), Double.valueOf(actual));
@@ -569,7 +570,7 @@ static public void assertEquals(String message, double expected,
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertEquals(String message, float expected,
+ public static void assertEquals(String message, float expected,
float actual, float delta) {
if (floatIsDifferent(expected, actual, delta)) {
failNotEquals(message, Float.valueOf(expected), Float.valueOf(actual));
@@ -591,14 +592,14 @@ static public void assertEquals(String message, float expected,
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertNotEquals(String message, float unexpected,
+ public static void assertNotEquals(String message, float unexpected,
float actual, float delta) {
if (!floatIsDifferent(unexpected, actual, delta)) {
- failEquals(message, Float.valueOf(actual));
+ failEquals(message, actual);
}
}
- static private boolean doubleIsDifferent(double d1, double d2, double delta) {
+ private static boolean doubleIsDifferent(double d1, double d2, double delta) {
if (Double.compare(d1, d2) == 0) {
return false;
}
@@ -609,7 +610,7 @@ static private boolean doubleIsDifferent(double d1, double d2, double delta) {
return true;
}
- static private boolean floatIsDifferent(float f1, float f2, float delta) {
+ private static boolean floatIsDifferent(float f1, float f2, float delta) {
if (Float.compare(f1, f2) == 0) {
return false;
}
@@ -627,7 +628,7 @@ static private boolean floatIsDifferent(float f1, float f2, float delta) {
* @param expected expected long value.
* @param actual actual long value
*/
- static public void assertEquals(long expected, long actual) {
+ public static void assertEquals(long expected, long actual) {
assertEquals(null, expected, actual);
}
@@ -640,7 +641,7 @@ static public void assertEquals(long expected, long actual) {
* @param expected long expected value.
* @param actual long actual value
*/
- static public void assertEquals(String message, long expected, long actual) {
+ public static void assertEquals(String message, long expected, long actual) {
if (expected != actual) {
failNotEquals(message, Long.valueOf(expected), Long.valueOf(actual));
}
@@ -652,7 +653,7 @@ static public void assertEquals(String message, long expected, long actual) {
* instead
*/
@Deprecated
- static public void assertEquals(double expected, double actual) {
+ public static void assertEquals(double expected, double actual) {
assertEquals(null, expected, actual);
}
@@ -662,7 +663,7 @@ static public void assertEquals(double expected, double actual) {
* instead
*/
@Deprecated
- static public void assertEquals(String message, double expected,
+ public static void assertEquals(String message, double expected,
double actual) {
fail("Use assertEquals(expected, actual, delta) to compare floating-point numbers");
}
@@ -679,7 +680,7 @@ static public void assertEquals(String message, double expected,
* actual
for which both numbers are still
* considered equal.
*/
- static public void assertEquals(double expected, double actual, double delta) {
+ public static void assertEquals(double expected, double actual, double delta) {
assertEquals(null, expected, actual, delta);
}
@@ -695,8 +696,7 @@ static public void assertEquals(double expected, double actual, double delta) {
* actual
for which both numbers are still
* considered equal.
*/
-
- static public void assertEquals(float expected, float actual, float delta) {
+ public static void assertEquals(float expected, float actual, float delta) {
assertEquals(null, expected, actual, delta);
}
@@ -708,7 +708,7 @@ static public void assertEquals(float expected, float actual, float delta) {
* okay)
* @param object Object to check or null
*/
- static public void assertNotNull(String message, Object object) {
+ public static void assertNotNull(String message, Object object) {
assertTrue(message, object != null);
}
@@ -718,7 +718,7 @@ static public void assertNotNull(String message, Object object) {
*
* @param object Object to check or null
*/
- static public void assertNotNull(Object object) {
+ public static void assertNotNull(Object object) {
assertNotNull(null, object);
}
@@ -730,7 +730,7 @@ static public void assertNotNull(Object object) {
* okay)
* @param object Object to check or null
*/
- static public void assertNull(String message, Object object) {
+ public static void assertNull(String message, Object object) {
if (object == null) {
return;
}
@@ -743,11 +743,11 @@ static public void assertNull(String message, Object object) {
*
* @param object Object to check or null
*/
- static public void assertNull(Object object) {
+ public static void assertNull(Object object) {
assertNull(null, object);
}
- static private void failNotNull(String message, Object actual) {
+ private static void failNotNull(String message, Object actual) {
String formatted = "";
if (message != null) {
formatted = message + " ";
@@ -764,7 +764,7 @@ static private void failNotNull(String message, Object actual) {
* @param expected the expected object
* @param actual the object to compare to expected
*/
- static public void assertSame(String message, Object expected, Object actual) {
+ public static void assertSame(String message, Object expected, Object actual) {
if (expected == actual) {
return;
}
@@ -778,7 +778,7 @@ static public void assertSame(String message, Object expected, Object actual) {
* @param expected the expected object
* @param actual the object to compare to expected
*/
- static public void assertSame(Object expected, Object actual) {
+ public static void assertSame(Object expected, Object actual) {
assertSame(null, expected, actual);
}
@@ -792,7 +792,7 @@ static public void assertSame(Object expected, Object actual) {
* @param unexpected the object you don't expect
* @param actual the object to compare to unexpected
*/
- static public void assertNotSame(String message, Object unexpected,
+ public static void assertNotSame(String message, Object unexpected,
Object actual) {
if (unexpected == actual) {
failSame(message);
@@ -807,11 +807,11 @@ static public void assertNotSame(String message, Object unexpected,
* @param unexpected the object you don't expect
* @param actual the object to compare to unexpected
*/
- static public void assertNotSame(Object unexpected, Object actual) {
+ public static void assertNotSame(Object unexpected, Object actual) {
assertNotSame(null, unexpected, actual);
}
- static private void failSame(String message) {
+ private static void failSame(String message) {
String formatted = "";
if (message != null) {
formatted = message + " ";
@@ -819,7 +819,7 @@ static private void failSame(String message) {
fail(formatted + "expected not same");
}
- static private void failNotSame(String message, Object expected,
+ private static void failNotSame(String message, Object expected,
Object actual) {
String formatted = "";
if (message != null) {
@@ -829,14 +829,14 @@ static private void failNotSame(String message, Object expected,
+ ">");
}
- static private void failNotEquals(String message, Object expected,
+ private static void failNotEquals(String message, Object expected,
Object actual) {
fail(format(message, expected, actual));
}
static String format(String message, Object expected, Object actual) {
String formatted = "";
- if (message != null && !message.equals("")) {
+ if (message != null && !"".equals(message)) {
formatted = message + " ";
}
String expectedString = String.valueOf(expected);
diff --git a/src/main/java/org/junit/Assume.java b/src/main/java/org/junit/Assume.java
index b7687f7c1ffa..69fac45cad67 100644
--- a/src/main/java/org/junit/Assume.java
+++ b/src/main/java/org/junit/Assume.java
@@ -34,6 +34,15 @@
* @since 4.4
*/
public class Assume {
+
+ /**
+ * Do not instantiate.
+ * @deprecated since 4.13.
+ */
+ @Deprecated
+ public Assume() {
+ }
+
/**
* If called with an expression evaluating to {@code false}, the test will halt and be ignored.
*/
diff --git a/src/main/java/org/junit/experimental/results/ResultMatchers.java b/src/main/java/org/junit/experimental/results/ResultMatchers.java
index cf58f1bc499a..98778a9f924e 100644
--- a/src/main/java/org/junit/experimental/results/ResultMatchers.java
+++ b/src/main/java/org/junit/experimental/results/ResultMatchers.java
@@ -14,6 +14,15 @@
*
*/
public class ResultMatchers {
+
+ /**
+ * Do not instantiate.
+ * @deprecated will be private soon.
+ */
+ @Deprecated
+ public ResultMatchers() {
+ }
+
/**
* Matches if the tests are all successful
*/
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 a94c8a5e00b1..6626797ef089 100644
--- a/src/main/java/org/junit/experimental/theories/internal/Assignments.java
+++ b/src/main/java/org/junit/experimental/theories/internal/Assignments.java
@@ -47,7 +47,7 @@ public static Assignments allUnassigned(Method testMethod,
}
public boolean isComplete() {
- return unassigned.size() == 0;
+ return unassigned.isEmpty();
}
public ParameterSignature nextUnassigned() {
@@ -55,11 +55,10 @@ public ParameterSignature nextUnassigned() {
}
public Assignments assignNext(PotentialAssignment source) {
- List assigned = new ArrayList(
- this.assigned);
- assigned.add(source);
+ List potentialAssignments = new ArrayList(assigned);
+ potentialAssignments.add(source);
- return new Assignments(assigned, unassigned.subList(1,
+ return new Assignments(potentialAssignments, unassigned.subList(1,
unassigned.size()), clazz);
}
@@ -77,7 +76,7 @@ public List potentialsForNextUnassigned()
ParameterSignature unassigned = nextUnassigned();
List assignments = getSupplier(unassigned).getValueSources(unassigned);
- if (assignments.size() == 0) {
+ if (assignments.isEmpty()) {
assignments = generateAssignmentsFromTypeAlone(unassigned);
}
diff --git a/src/main/java/org/junit/internal/Classes.java b/src/main/java/org/junit/internal/Classes.java
index 154603d2e4f6..beca4453ae2f 100644
--- a/src/main/java/org/junit/internal/Classes.java
+++ b/src/main/java/org/junit/internal/Classes.java
@@ -6,6 +6,15 @@
* Miscellaneous functions dealing with classes.
*/
public class Classes {
+
+ /**
+ * Do not instantiate.
+ * @deprecated will be private soon.
+ */
+ @Deprecated
+ public Classes() {
+ }
+
/**
* Returns Class.forName for {@code className} using the current thread's class loader.
*
diff --git a/src/main/java/org/junit/internal/TextListener.java b/src/main/java/org/junit/internal/TextListener.java
index 9aa56c75f5ec..a75e80d50618 100644
--- a/src/main/java/org/junit/internal/TextListener.java
+++ b/src/main/java/org/junit/internal/TextListener.java
@@ -58,7 +58,7 @@ protected void printHeader(long runTime) {
protected void printFailures(Result result) {
List failures = result.getFailures();
- if (failures.size() == 0) {
+ if (failures.isEmpty()) {
return;
}
if (failures.size() == 1) {
diff --git a/src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java b/src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java
index 4e2cc1264d09..fb25982bbd4d 100644
--- a/src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java
+++ b/src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java
@@ -40,7 +40,7 @@ private static Class> findExpectedType(Class> fromClass) {
}
private static boolean isMatchesSafelyMethod(Method method) {
- return method.getName().equals("matchesSafely")
+ return "matchesSafely".equals(method.getName())
&& method.getParameterTypes().length == 1
&& !method.isSynthetic();
}
diff --git a/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java b/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java
index 8c3cef6c9d91..822f8dc47bfa 100644
--- a/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java
+++ b/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java
@@ -5,6 +5,7 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import org.junit.After;
@@ -56,7 +57,7 @@
*/
public class BlockJUnit4ClassRunner extends ParentRunner {
- private final ConcurrentHashMap methodDescriptions = new ConcurrentHashMap();
+ private final ConcurrentMap methodDescriptions = new ConcurrentHashMap();
/**
* Creates a BlockJUnit4ClassRunner to run {@code testClass}
@@ -189,6 +190,7 @@ private boolean hasOneConstructor() {
* Adds to {@code errors} for each method annotated with {@code @Test},
* {@code @Before}, or {@code @After} that is not a public, void instance
* method with no arguments.
+ * @deprecated
*/
@Deprecated
protected void validateInstanceMethods(List errors) {
@@ -196,7 +198,7 @@ protected void validateInstanceMethods(List errors) {
validatePublicVoidNoArgMethods(Before.class, false, errors);
validateTestMethods(errors);
- if (computeTestMethods().size() == 0) {
+ if (computeTestMethods().isEmpty()) {
errors.add(new Exception("No runnable methods"));
}
}
@@ -326,6 +328,7 @@ protected Statement possiblyExpectingExceptions(FrameworkMethod method,
* Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation
* has the {@code timeout} attribute, throw an exception if {@code next}
* takes more than the specified number of milliseconds.
+ * @deprecated
*/
@Deprecated
protected Statement withPotentialTimeout(FrameworkMethod method,
@@ -379,12 +382,13 @@ private Statement withRules(FrameworkMethod method, Object target,
private Statement withMethodRules(FrameworkMethod method, List testRules,
Object target, Statement result) {
+ Statement withMethodRules = result;
for (org.junit.rules.MethodRule each : getMethodRules(target)) {
- if (!testRules.contains(each)) {
- result = each.apply(result, method, target);
+ if (!(each instanceof TestRule && testRules.contains(each))) {
+ withMethodRules = each.apply(withMethodRules, method, target);
}
}
- return result;
+ return withMethodRules;
}
private List getMethodRules(Object target) {