Test com.meterware.httpunit.cookies.CookieTest.testCookieAge failing

"James Courtney" <[email protected]> Tue, 19 Aug 2008 14:34:01 -0700
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <002801c90243$4d60be60$e8223b20$@com>
This is tricky to test as getting an exact time match is tough.
Additionally it appears that for the 3rd and 4th elements in the test data
array that the code interpreting the cookie expiration times is giving
priority to the Max-Age value over the expires value.  The test code appears
to be expecting the expires value to be the value used so maybe the cookie
interpretation library changed at some point else this test would always
have failed.

 

Below are the changes I made to CookieTest.java to get the testCookieAge
test to succeed.

 

Jamey

 

@@ -182,11 +185,14 @@

                          "expires=Tue, 29-Mar-2005 19:30:42 GMT",

                          "Expires=Wednesday, 01-Jan-1970 0:0:00 GMT"

                          };

-        long expectedMilliSeconds[] = {System.currentTimeMillis() + 5000 *
1000,

-                                       System.currentTimeMillis() + 3000 *
1000,

+        long now = System.currentTimeMillis();

+        long expectedMilliSeconds[] = {now + 5000 * 1000,

+                                       now + 3000 * 1000,

+                                       //1112124642000l,

+                                       now + 2592000 * 1000,

+                                       //1112124642000l,

+                                       now + 2592000 * 1000,

                                        1112124642000l,

-                                       1112124642000l,

-                                       1112124642000l,

                                        0};

 

         for (int i = 0; i < ages.length; i++) {

@@ -199,7 +205,7 @@

             assertNotNull( cookieName + " not null", cookie );

 

             long expiredTime = cookie.getExpiredTime();

-            assertEquals( cookieName + " expiration", expiredTime,
expectedMilliSeconds[i] );

+            assertTrue( cookieName + " expiration", Math.abs(expiredTime -
expectedMilliSeconds[i]) < 50 );

         }

     }

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop