You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by Alf Høgemark <al...@i100.no> on 2007/04/02 22:10:11 UTC
Character encoding of Jmeter test plan files
Hi
My code observations :
JMeter test plan files (and probably other files written by Jmeter as
well) are written using the default charater encoding of the JRE.
The JMeter test plan files are also loaded using the default charater
encoding of the JRE.
Example from the org.apache.jmeter.gui.action.Save class :
if (SaveService.isSaveTestPlanFormat20()) {
ostream = new FileOutputStream(updateFile);
OldSaveService.saveSubTree(subTree, ostream);
} else {
writer = new FileWriter(updateFile);
SaveService.saveTree(subTree, writer);
}
My Jmeter usage observations :
If I paste some UTF-8 characters into a text field in JMeter, for
example as the value of a HTTP request parameter, and then save the test
plan, and reload it, my
UTF-8 characters are lost.
I have read a little bit about -Dfile.encoding, and on some platforms it
seems like it is not possible to change the default character set encoding.
See for example bug 4163515 at java.sun.com
I see that the Xstream FAQ (http://xstream.codehaus.org/faq.html) has a
question "Why does XStream not write XML in UTF-8?",
where the answer says that a Writer with the correct encoding should be
used.
My question :
Should JMeter test plan files always be written and read as UTF-8,
instead of using default character set encoding of the JRE ?
Or perhaps an option should be specified at save / load time, to allow
the user to choose which encoding to use ?
As it is now, it's not easy for an user to get UTF-8 characters saved
correctly to a test plan. And if the test plan has to be shared with
other people, he would have to tell which encoding was used to save
the file.
This issue came to my attention while working to improve the i18n
support in HTTP Request sampler and HTTP Proxy server.
Regards
Alf Hogemark
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
Re: Character encoding of Jmeter test plan files
Posted by sebb <se...@gmail.com>.
There is no need to change the version number unless the files are no
longer compatible.
S.
On 03/04/07, Alf Høgemark <al...@i100.no> wrote:
> Thanks for the input.
>
> I'll make a bugzilla entry for this, and make a patch with reads and
> writes the files using the encoding specified in the properties file,
> with default value of UTF-8.
> Do we have to change the "version number" for the files being read and
> written after this change ? I.e. the "version" attribute.
>
> Regards
> Alf Hogemark
>
>
> sebb wrote:
> > On 02/04/07, Alf Høgemark <al...@i100.no> wrote:
> >>
> >> Hi
> >>
> >> My code observations :
> >> JMeter test plan files (and probably other files written by Jmeter as
> >> well) are written using the default charater encoding of the JRE.
> >> The JMeter test plan files are also loaded using the default charater
> >> encoding of the JRE.
> >> Example from the org.apache.jmeter.gui.action.Save class :
> >> if (SaveService.isSaveTestPlanFormat20()) {
> >> ostream = new FileOutputStream(updateFile);
> >> OldSaveService.saveSubTree(subTree, ostream);
> >
> > We can probably ignore fixes to the OldSaveService for this.
> >
> >> } else {
> >> writer = new FileWriter(updateFile);
> >> SaveService.saveTree(subTree, writer);
> >> }
> >>
> >> My Jmeter usage observations :
> >> If I paste some UTF-8 characters into a text field in JMeter, for
> >> example as the value of a HTTP request parameter, and then save the test
> >> plan, and reload it, my
> >> UTF-8 characters are lost.
> >>
> >> I have read a little bit about -Dfile.encoding, and on some platforms it
> >> seems like it is not possible to change the default character set
> >> encoding.
> >> See for example bug 4163515 at java.sun.com
> >
> > Also it is a bit awkward.
> >
> >> I see that the Xstream FAQ (http://xstream.codehaus.org/faq.html) has a
> >> question "Why does XStream not write XML in UTF-8?",
> >> where the answer says that a Writer with the correct encoding should be
> >> used.
> >>
> >> My question :
> >> Should JMeter test plan files always be written and read as UTF-8,
> >> instead of using default character set encoding of the JRE ?
> >
> > Sounds good to me.
> >
> >> Or perhaps an option should be specified at save / load time, to allow
> >> the user to choose which encoding to use ?
> >
> > Not sure we need to make it optional, but see below.
> >
> >> As it is now, it's not easy for an user to get UTF-8 characters saved
> >> correctly to a test plan. And if the test plan has to be shared with
> >> other people, he would have to tell which encoding was used to save
> >> the file.
> >
> > Yes, whatever encoding is used (whether fixed or changeable) should be
> > written to the testplans, as is already done for the XML log files,
> > for example:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <testResults version="1.2">
> > ...
> >
> > I think the Java file reader might even be clever enough to recognise
> > this.
> >
> > The simplest might be to add a JMeter property to define the encoding
> > to be used for test plans and XML log files. This should default to
> > UTF-8.
> >
> > If there turns out to be a need for different encodings for test plans
> > and log files, that can always be added later.
> >
> > S.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
Re: Character encoding of Jmeter test plan files
Posted by Alf Høgemark <al...@i100.no>.
Thanks for the input.
I'll make a bugzilla entry for this, and make a patch with reads and
writes the files using the encoding specified in the properties file,
with default value of UTF-8.
Do we have to change the "version number" for the files being read and
written after this change ? I.e. the "version" attribute.
Regards
Alf Hogemark
sebb wrote:
> On 02/04/07, Alf Høgemark <al...@i100.no> wrote:
>>
>> Hi
>>
>> My code observations :
>> JMeter test plan files (and probably other files written by Jmeter as
>> well) are written using the default charater encoding of the JRE.
>> The JMeter test plan files are also loaded using the default charater
>> encoding of the JRE.
>> Example from the org.apache.jmeter.gui.action.Save class :
>> if (SaveService.isSaveTestPlanFormat20()) {
>> ostream = new FileOutputStream(updateFile);
>> OldSaveService.saveSubTree(subTree, ostream);
>
> We can probably ignore fixes to the OldSaveService for this.
>
>> } else {
>> writer = new FileWriter(updateFile);
>> SaveService.saveTree(subTree, writer);
>> }
>>
>> My Jmeter usage observations :
>> If I paste some UTF-8 characters into a text field in JMeter, for
>> example as the value of a HTTP request parameter, and then save the test
>> plan, and reload it, my
>> UTF-8 characters are lost.
>>
>> I have read a little bit about -Dfile.encoding, and on some platforms it
>> seems like it is not possible to change the default character set
>> encoding.
>> See for example bug 4163515 at java.sun.com
>
> Also it is a bit awkward.
>
>> I see that the Xstream FAQ (http://xstream.codehaus.org/faq.html) has a
>> question "Why does XStream not write XML in UTF-8?",
>> where the answer says that a Writer with the correct encoding should be
>> used.
>>
>> My question :
>> Should JMeter test plan files always be written and read as UTF-8,
>> instead of using default character set encoding of the JRE ?
>
> Sounds good to me.
>
>> Or perhaps an option should be specified at save / load time, to allow
>> the user to choose which encoding to use ?
>
> Not sure we need to make it optional, but see below.
>
>> As it is now, it's not easy for an user to get UTF-8 characters saved
>> correctly to a test plan. And if the test plan has to be shared with
>> other people, he would have to tell which encoding was used to save
>> the file.
>
> Yes, whatever encoding is used (whether fixed or changeable) should be
> written to the testplans, as is already done for the XML log files,
> for example:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <testResults version="1.2">
> ...
>
> I think the Java file reader might even be clever enough to recognise
> this.
>
> The simplest might be to add a JMeter property to define the encoding
> to be used for test plans and XML log files. This should default to
> UTF-8.
>
> If there turns out to be a need for different encodings for test plans
> and log files, that can always be added later.
>
> S.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
Re: Character encoding of Jmeter test plan files
Posted by sebb <se...@gmail.com>.
On 02/04/07, Alf Høgemark <al...@i100.no> wrote:
>
> Hi
>
> My code observations :
> JMeter test plan files (and probably other files written by Jmeter as
> well) are written using the default charater encoding of the JRE.
> The JMeter test plan files are also loaded using the default charater
> encoding of the JRE.
> Example from the org.apache.jmeter.gui.action.Save class :
> if (SaveService.isSaveTestPlanFormat20()) {
> ostream = new FileOutputStream(updateFile);
> OldSaveService.saveSubTree(subTree, ostream);
We can probably ignore fixes to the OldSaveService for this.
> } else {
> writer = new FileWriter(updateFile);
> SaveService.saveTree(subTree, writer);
> }
>
> My Jmeter usage observations :
> If I paste some UTF-8 characters into a text field in JMeter, for
> example as the value of a HTTP request parameter, and then save the test
> plan, and reload it, my
> UTF-8 characters are lost.
>
> I have read a little bit about -Dfile.encoding, and on some platforms it
> seems like it is not possible to change the default character set encoding.
> See for example bug 4163515 at java.sun.com
Also it is a bit awkward.
> I see that the Xstream FAQ (http://xstream.codehaus.org/faq.html) has a
> question "Why does XStream not write XML in UTF-8?",
> where the answer says that a Writer with the correct encoding should be
> used.
>
> My question :
> Should JMeter test plan files always be written and read as UTF-8,
> instead of using default character set encoding of the JRE ?
Sounds good to me.
> Or perhaps an option should be specified at save / load time, to allow
> the user to choose which encoding to use ?
Not sure we need to make it optional, but see below.
> As it is now, it's not easy for an user to get UTF-8 characters saved
> correctly to a test plan. And if the test plan has to be shared with
> other people, he would have to tell which encoding was used to save
> the file.
Yes, whatever encoding is used (whether fixed or changeable) should be
written to the testplans, as is already done for the XML log files,
for example:
<?xml version="1.0" encoding="UTF-8"?>
<testResults version="1.2">
...
I think the Java file reader might even be clever enough to recognise this.
The simplest might be to add a JMeter property to define the encoding
to be used for test plans and XML log files. This should default to
UTF-8.
If there turns out to be a need for different encodings for test plans
and log files, that can always be added later.
S.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org