commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject svn commit: r240027 - /jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailTest.java
Date Thu, 25 Aug 2005 09:40:28 GMT
Author: henning
Date: Thu Aug 25 02:40:24 2005
New Revision: 240027

URL: http://svn.apache.org/viewcvs?rev=240027&view=rev
Log:
Gee, do you all have multi-GHz CPUs? This test fails consistently for
me on a slow CPU... Add some fuzzyness to the time compare.


Modified:
    jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailTest.java

Modified: jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailTest.java?rev=240027&r1=240026&r2=240027&view=diff
==============================================================================
--- jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailTest.java (original)
+++ jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailTest.java Thu
Aug 25 02:40:24 2005
@@ -1559,13 +1559,21 @@
     public void testGetSetSentDate()
     {
         // with input date
+
         Date dtTest = Calendar.getInstance().getTime();
         this.email.setSentDate(dtTest);
         assertEquals(dtTest, this.email.getSentDate());
 
         // with null input (this is a fudge :D)
         this.email.setSentDate(null);
-        assertEquals(dtTest, this.email.getSentDate());
+
+        Date sentDate = this.email.getSentDate();
+
+        // Date objects are millisecond specific. If you have a slow processor,
+        // time passes between the generation of dtTest and the new Date() in
+        // getSentDate() and this test fails. Make sure that the difference
+        // is less than a second...
+        assertTrue(Math.abs(sentDate.getTime() - dtTest.getTime()) < 1000);
     }
 
     /** */
@@ -1625,4 +1633,4 @@
         assertEquals(strPassword, this.email.getPopPassword());
     }
 
-}
\ No newline at end of file
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message