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

"Wolfgang Fahl" <[email protected]> Mon, 17 Aug 2009 15:15:08 +0200
Newsgroups gmane.comp.web.httpunit.devel
Organization BITPlan GmbH
Message-ID <[email protected]>
James Courtney wrote many month ago about his proposal 
to fix the testCookieAge JUnit test.

The fix is now checked in:
http://httpunit.svn.sourceforge.net/viewvc/httpunit?view=rev&revision=1033

Sorry for this major delay

Wolfgang

> 
> 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 );
>  }
>  }
> 



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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

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