Bug 51847

Summary: [PATCH] Some Junit tests are Locale sensitive and fail if Locale is different from US
Product: JMeter - Now in Github Reporter: benoit.wiart
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: p.mouawad
Priority: P2    
Version: 2.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Fix the bug

Description benoit.wiart 2011-09-19 22:27:59 UTC
Created attachment 27539 [details]
Fix the bug

Date format in org.apache.jmeter.protocol.http.control.TestCacheManager depends on the jvm default locale.

The patch reuse the httpclient dateutil to format the dates, it's already used for parsing.

Benoit WIART
Comment 1 Sebb 2011-09-19 23:13:46 UTC
What Locale does it fail on?

I don't use Locale.US and I've not seen any failures.
Comment 2 benoit.wiart 2011-09-20 06:43:43 UTC
It should also work with other english languages not only US

Expires date is formatted with the jvm default locale (in makeDate) but is parsed with Locale.US in DateUtil in CacheManager
the expires date should follow rfc 1123

For example with Locale fr_FR
Expires is mar., 20 sept. 2011 06:39:16 GMT
Where it should be Tue, 20 Sep 2011 06:39:16 GMT

Below are the failures

1) testExpiresJava(org.apache.jmeter.protocol.http.control.TestCacheManager)junit.framework.AssertionFailedError: Should find valid entry
     [java] 	at org.apache.jmeter.protocol.http.control.TestCacheManager.testExpiresJava(TestCacheManager.java:191)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] 	at org.apache.jorphan.test.AllTests.main(AllTests.java:233)
     [java] 2) testExpiresHttpClient(org.apache.jmeter.protocol.http.control.TestCacheManager)junit.framework.AssertionFailedError: Should find valid entry
     [java] 	at org.apache.jmeter.protocol.http.control.TestCacheManager.testExpiresHttpClient(TestCacheManager.java:213)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] 	at org.apache.jorphan.test.AllTests.main(AllTests.java:233)
     [java] FAILURES!!!
Comment 3 Philippe Mouawad 2011-09-20 08:21:11 UTC
Hello,
I confirm these failures in French Locale.
Fix works for me.

Regards
Philippe
Comment 4 Sebb 2011-09-20 09:21:40 UTC
Thanks for the report and patch.

I was using an English Locale, which is why I did not see the problem.

Fixed, but without using DateUtil.

URL: http://svn.apache.org/viewvc?rev=1173042&view=rev
Log:
Bug 51847 - Some Junit tests are Locale sensitive and fail if Locale is different from US

Modified:
   jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
   jakarta/jmeter/trunk/xdocs/changes.xml
Comment 5 The ASF infrastructure team 2022-09-24 20:37:46 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2549