> 2022年8月11日 22:56,Christopher Schultz <ch...@christopherschultz.net> 写道:
> 
> Han,
> 
> On 8/11/22 10:31, Han Li wrote:
>>> 2022年8月11日 21:02,Konstantin Kolinko <knst.koli...@gmail.com> 写道:
>>> 
>>> чт, 11 авг. 2022 г. в 05:21, Han Li <aooo...@gmail.com>:
>>>> 
>>>> 
>>>> 
>>>>> 2022年8月11日 06:52,Konstantin Kolinko <knst.koli...@gmail.com> 写道:
>>>>> 
>>>>> ср, 10 авг. 2022 г. в 13:25, Han Li <aooo...@gmail.com 
>>>>> <mailto:aooo...@gmail.com>>:
>>>>>> 
>>>>>> Mark,
>>>>>> 
>>>>>> Can I make a suggestion related to the ant build script. Can we add two 
>>>>>> properties to set the values of ` -Duser.language` and `-Duser.country`, 
>>>>>> because in the course of my testing I found that some of the unit test 
>>>>>> assertions are in English, but there may be cases where the values are 
>>>>>> converted by sm, e.g. Chinese.
>>>>>> Just like this:
>>>>>> Assert.assertEquals("ok”,x);
>>>>>> The variable x becomes "好" after passing through the StringManager.
>>>>>> 
>>>>>> So this makes it a bit inconvenient for non-English speaking developers 
>>>>>> to test. I avoid this problem by adding a statement to build.xml each 
>>>>>> time I run a test.
>>>>>> <jvmarg value="-Duser.language=en"/>
>>>>>> <jvmarg value="-Duser.country=US"/>
>>>>>> 
>>>>>> So I was wondering if we could dynamically set these two values via 
>>>>>> build.properties
>>>>>> 
>>>>>> Thanks,
>>>>>> 
>>>>>> Han
>>>>> 
>>>>> I think that such tests are just broken and require fixing.
>>>>> 
>>>>> E.g. get an instance of StringManager and read the expected message from 
>>>>> it.
>>>>> 
>>>>> 
>>>>> Maybe we can add -Duser.language=zh -Duser.country=CN to ANT_OPTS in
>>>>> some Buildbot configurations, to be able to detect such tests.
>>>> 
>>>> Sorry, my explanation may be confusing.
>>>> 
>>>> Let me explain why with a concrete unit test. Just like this:
>>>> org.apache.catalina.valves.TestErrorReportValve#testBug53071
>>>> 
>>>> ```
>>>> Assert.assertTrue(res.toString().contains("<p><b>Message</b> " +
>>>> ErrorServlet.ERROR_TEXT + "</p>"));
>>>> ```
>>>> org.apache.catalina.valves.ErrorReportValve#report
>>>> ```
>>>> sb.append("<p><b>");
>>>> sb.append(smClient.getString("errorReportValve.message"));
>>>> sb.append("</b> ");
>>>> ```
>>>> Since the local of my OS is zh-CN, the response contains `<p><b>信息</b> 
>>>> .... ` instead of `<p><b>Message</b>.... ', so I’m trying to avoid this by 
>>>> changing user.language and user.country.
>>>> Unfortunately, I can’t find any way to do this at the moment, so I have to 
>>>> manually modify the build.xml.
>>>> 
>>> 
>>> 1. I think that you could add a request header
>>> 
>>> Accept-Language: en-US
>>> 
>>> using the variant of getUrl() call that accepts a "reqHead" map.
>>> 
>>> In TomcatBaseTest:
>>> public static int getUrl(String path, ByteChunk out, Map<String,
>>> List<String>> reqHead,
>>> Map<String, List<String>> resHead) throws IOException {
>>> 
>> I’ve tried to do this and `en_US` does not work properly, `en` does. For 
>> reasons I think I already know.
<!-- SNIP -->
> 
> Did you try en-US? These are RFC 1766 language tags which use hyphens and not 
> underscores. https://www.rfc-editor.org/rfc/rfc1766 
> <https://www.rfc-editor.org/rfc/rfc1766>
> 
Yes, I'm using en-US, when you asked me I thought I was using en_US, now I'm 
sure it's en-US, it's not working properly. 

Han

>> I will propose a BZ to describe this failure test and a PR to fix it.
> 
> Excellent.
> 
> -chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org 
> <mailto:dev-unsubscr...@tomcat.apache.org>
> For additional commands, e-mail: dev-h...@tomcat.apache.org 
> <mailto:dev-h...@tomcat.apache.org>

Reply via email to