You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2017/02/27 22:32:52 UTC
[lang] DateUtilsTest asserts (closes #246)
Repository: commons-lang
Updated Branches:
refs/heads/master 44516f77e -> 98fa164cd
DateUtilsTest asserts (closes #246)
Use JUnit's assertFalse for assertions with conditions instead of
re-implementing the logic here by testing the condition and throwing an
AssertionFailureException if the condition is met.
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/98fa164c
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/98fa164c
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/98fa164c
Branch: refs/heads/master
Commit: 98fa164cd88d126d0f137f5bcb4a1d180e0c2fc4
Parents: 44516f7
Author: Allon Mureinik <am...@redhat.com>
Authored: Mon Feb 27 21:35:03 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Mon Feb 27 23:31:35 2017 +0100
----------------------------------------------------------------------
.../org/apache/commons/lang3/time/DateUtilsTest.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/98fa164c/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
index c0e0a80..964c40b 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -43,8 +43,6 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
-import junit.framework.AssertionFailedError;
-
/**
* Unit tests {@link org.apache.commons.lang3.time.DateUtils}.
*/
@@ -1722,9 +1720,8 @@ public class DateUtilsTest {
last.add(Calendar.DATE, 1);
assertCalendarsEquals("", last, cal, 0);
}
- if (count % 7 != 0) {
- throw new AssertionFailedError("There were " + count + " days in this iterator");
- }
+
+ assertFalse("There were " + count + " days in this iterator", count % 7 != 0);
assertCalendarsEquals("", end, cal, 0);
}
@@ -1733,10 +1730,8 @@ public class DateUtilsTest {
* delta is in milliseconds
*/
private static void assertCalendarsEquals(final String message, final Calendar cal1, final Calendar cal2, final long delta) {
- if (Math.abs(cal1.getTime().getTime() - cal2.getTime().getTime()) > delta) {
- throw new AssertionFailedError(
- message + " expected " + cal1.getTime() + " but got " + cal2.getTime());
- }
+ assertFalse(message + " expected " + cal1.getTime() + " but got " + cal2.getTime(),
+ Math.abs(cal1.getTime().getTime() - cal2.getTime().getTime()) > delta);
}
@Test