Re: Test com.meterware.httpunit.cookies.CookieTest.testCookieAge failing
"Wolfgang Fahl - BITPlan" <[email protected]> Sat, 20 Sep 2008 09:37:19 +0200
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Organization | bitplan GmbH |
| Message-ID | <[email protected]> |
James,
you wrote:
> 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.
Thank you fro looking into this an proposing a solution how to fix the
tests. I'll happily add your proposed changes. I'm assuming the
CookieTest.java testCookieAge() test case fails in your environment with
the latest svn head version of httpunit.
Since it doesn't fail in my environment I'd like to first find out what the
difference between our environment is that leads to this difference in
behaviour.
I'm testing on a Windows XP machine with JDK 1.5 in an Eclipse environment
with the settings as commited to the subversion respository e.g. I'm
working with Nekohtml 0.9.5 as configured in the maven settings.
Yours
Wolfgang
>
>
> 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 );
>
> }
>
> }
>
>
BITPlan - smart solutions
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: http://www.bitplan.de
bitplan GmbH, Willich - HRB 6820 Krefeld, VAT-ID: 10258040548, Geschäftsführer: Wolfgang Fahl
-------------------------------------------------------------------------
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