Bug 59657

Summary: junk character(Simplified Chinese) in BeanShell Sampler's 'script' Textbox
Product: JMeter - Now in Github Reporter: harry_no_spot <hppyhjh>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: cs_awater
Priority: P2    
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: junk character(chinese) in beashell sampler
Simple test case with chinese letters in a JSytaxTextArea
still junk chinese letters in a JSytaxTextArea
correct chinese letters with jsyntaxtextarea.font.family property
Enhanced jmeter script to iterate over available chinese fonts
monospaced font is listed as first

Description harry_no_spot 2016-06-02 14:25:05 UTC
Created attachment 33909 [details]
junk character(chinese) in beashell sampler

In Jmeter V2.13 and before, Simplified Chinese character was displayed correctly in BeanShell Sampler. But was displayed junk characters in V3.0, btw, still displayed correctly in 'View Result Tress's Request data.

Plz see the attachement pic and u will see.
Comment 1 Felix Schumacher 2016-06-05 09:35:24 UTC
Created attachment 33911 [details]
Simple test case with chinese letters in a JSytaxTextArea

The attached test case displays correctly with jmeter 3.0 under ubuntu 16.04. Can you test this one on your computer?

I believe, that http://svn.apache.org/viewvc?view=revision&revision=1731546 is responsible for your problem (together with your OS and its choice of a default font).

You can try to set the jmeter property jsyntaxtextarea.font.family to a font that contains the simplified chinese letters. The example in jmeter.properties uses the font family "Hack".
Comment 2 Sebb 2016-06-05 09:55:26 UTC
(In reply to Felix Schumacher from comment #1)

> I believe, that http://svn.apache.org/viewvc?view=revision&revision=1731546
> is responsible for your problem (together with your OS and its choice of a
> default font).

In theory that should not have an effect unless the user overrides one of the property defaults. If it does have an effect, then there may be something wrong with the patch. One way to check this would be to skip the setFont() call if the user has not provided any overrides.
Comment 3 harry_no_spot 2016-06-06 14:11:45 UTC
> The attached test case displays correctly with jmeter 3.0 under ubuntu
> 16.04. Can you test this one on your computer?
> 
> I believe, that http://svn.apache.org/viewvc?view=revision&revision=1731546
> is responsible for your problem (together with your OS and its choice of a
> default font).
> 
> You can try to set the jmeter property jsyntaxtextarea.font.family to a font
> that contains the simplified chinese letters. The example in
> jmeter.properties uses the font family "Hack".

1. I directly opened the attached test case of yours. Still displayed junk character.

2. I changed jmeter.properties of 1 line:
jsyntaxtextarea.font.family=宋体
then reopened the attached test case of yours. displayed OK.

plz see the 2 attachments.
Comment 4 harry_no_spot 2016-06-06 14:14:42 UTC
Created attachment 33918 [details]
still junk chinese letters in a JSytaxTextArea
Comment 5 harry_no_spot 2016-06-06 14:18:53 UTC
Created attachment 33919 [details]
correct chinese letters with jsyntaxtextarea.font.family property
Comment 6 Felix Schumacher 2016-06-06 18:55:34 UTC
Created attachment 33920 [details]
Enhanced jmeter script to iterate over available chinese fonts

Could you test the newly added test script and see, if the font "Monospaced" is listed in the jmeter.log file afterwards?

It should look something like this:
2016/06/06 20:45:37 INFO  - jmeter.threads.JMeterThread: Thread started: Thread-Gruppe 1-1.
2016/06/06 20:45:38 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: 你好,世界!.
2016/06/06 20:45:38 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: java.awt.Font[family=Noto Sans CJK TC Light,name=Noto Sans CJK TC Light,style=plain,size=1].
2016/06/06 20:45:38 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: java.awt.Font[family=Noto Sans Mono CJK SC Regular,name=Noto Sans Mono CJK SC Regular,style=plain,size=1].
2016/06/06 20:45:38 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: java.awt.Font[family=Monospaced,name=Monospaced.bold,style=plain,size=1].
2016/06/06 20:45:38 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: java.awt.Font[family=Noto Sans CJK JP Light,name=Noto Sans CJK JP Light,style=plain,size=1].
...
Comment 7 harry_no_spot 2016-06-07 15:32:34 UTC
(In reply to Felix Schumacher from comment #6)
> Created attachment 33920 [details]
> Enhanced jmeter script to iterate over available chinese fonts
> 
> Could you test the newly added test script and see, if the font "Monospaced"
> is listed in the jmeter.log file afterwards?


Yes. "Monospaced" is listed as the first one. plz check the attached pic.
Comment 8 harry_no_spot 2016-06-07 15:33:51 UTC
Created attachment 33922 [details]
monospaced font is listed as first
Comment 9 Felix Schumacher 2016-06-09 16:40:17 UTC
RSyntaxText chooses "consolas" as the default font for windows (when asked). That font seems to have no support for the chinese characters. The default monospaced font for java seems to have support for the chinese characters. So if we don't set the font, it seems to work.

One can also put "Monospaced" as the desired font in jmeter.properties.

Linux had no problem, since it has no "consolas" font by default and therefore "Monospaced" was chosen as replacement.

I have no Mac, so I don't know, if it had a problem.

Date: Thu Jun  9 16:33:45 2016
New Revision: 1747562

URL: http://svn.apache.org/viewvc?rev=1747562&view=rev
Log:
Only set font in JSyntaxTextArea, when property jsyntaxtextarea.font.family is set.

Bugzilla Id: 59657

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/JSyntaxTextArea.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml
Comment 10 harry_no_spot 2016-07-08 11:54:47 UTC
*** Bug 59827 has been marked as a duplicate of this bug. ***
Comment 11 The ASF infrastructure team 2022-09-24 20:38:04 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3999