Login | Register
My pages Projects Community openCollabNet

Discussions > users > Re: [maxq-users] bug : HttpTestCase::getResponse

maxq
Discussion topic

Back to topic list

Re: [maxq-users] bug : HttpTestCase::getResponse

Author bteissier
Full name teissier
Date 2005-10-20 01:10:49 PDT
Message Hi everybody,
I've been working with Christophe, and as a result of our work, i've
commited a little change in HttpTestCase::getResponse() concerning our
encoding problems.

Bertrand

christophe blin wrote:

> Hi Oliver,
> basically yes you only have to specify the encoding for the conversion
> as a second parameter but it is simpler to use getResponseBodyAsString
> (which already does this).
>
> In order to keep backward compatibility, I suggest a new Method,
> getResponseAsBytes which return the getResponseBody
> My colleague will request a developer account soon in order to commit
> our modifications.
>
> Regards,
> chris
>
> Oliver Bock wrote:
>
>> Hi Christophe,
>>
>> Do you know how to fix this? I seem to remember encountering
>> something like this before. I cannot remember whether I fixed it or
>> not, but I suppose it is a matter of telling Java what encoding the
>> byte[] uses. Which version of MaxQ are you using?
>>
>>
>> Oliver
>>
>> P.S. You would be most welcome to fix this bug in CVS. Just apply
>> for developer role.
>>
>> --
>> christophe blin wrote:
>>
>>> hi,
>>>
>>> in HttpTestCase.java, there is a bug in getResponse().
>>> Because method.getResponseBody returns a byte array and so new
>>> String(getResponseBody()) <--> convert a byte[] into a string which
>>> is not good because of encoding.
>>> let us write an example to demonstrate the bug :
>>> test.html (written in iso-8859-15):
>>> <html>
>>> <head>
>>> <title>Title​</title>
>>> <meta http-equiv="Content-Type" content="text/html;
>>> charset=iso-8859-15">
>>> </head>
>>> <body>
>>> no-accents: e e a
>>> accents: é è à
>>> </body>
>>> </html>
>>>
>>> test.py
>>> # imports
>>> from PyHttpTestCase import PyHttpTestCase
>>>
>>> # defintition of test class
>>> class MaxQTest(PyHttpTestCase):
>>> def __init__(self):
>>> PyHttpTestCase.__init__(self, "")
>>>
>>> def runTest(self):
>>> self.get("http://web-dump/test.php")
>>> print self.responseContains('accents: é è à');
>>> print self.getResponse().f​ind('accents: é è à');
>>> # Code to load and run the test
>>> test = MaxQTest()
>>> test.runTest()
>>>
>>> this will print :
>>> 1
>>> -1
>>>
>>> this is because self.responseContains <--> return
>>> method.getResponsseB​odyAsString().indexO​f(s) != -1 and so this is true
>>> and self.getResponse().find <--> return
>>> method.getResponseBo​dy().indexOf(s) != -1 and so this is wrong
>>>
>>> you could ask why will I need to do self.getResponse().find ? this
>>> is because in fact I use regexp on the response HTML to find my
>>> elements to test.
>>>
>>> note: this problem will not appear on windows. To have the problem
>>> on windows, you should replace iso-8859-15 by utf8 (and of course
>>> encode the test.html in utf8)
>>>
>>> regards
>>> chris
>>>
>>
>> --------------------​--------------------​--------------------​---------
>> To unsubscribe, e-mail: users-unsubscribe@ma​xq.tigris.org
>> For additional commands, e-mail: users-help at maxq dot tigris dot org
>>
>>
>>
>>
>

« Previous message in topic | 4 of 4 | Next message in topic »

Messages

Show all messages in topic

bug : HttpTestCase::getResponse christophe blin <cblin at tennaxia dot com> christophe blin <cblin at tennaxia dot com> 2005-10-19 10:21:46 PDT
     Re: [maxq-users] bug : HttpTestCase::getResponse oliverbock Oliver Bock 2005-10-19 15:34:22 PDT
         Re: [maxq-users] bug : HttpTestCase::getResponse christophe blin <cblin at tennaxia dot com> christophe blin <cblin at tennaxia dot com> 2005-10-20 02:03:33 PDT
             Re: [maxq-users] bug : HttpTestCase::getResponse bteissier teissier 2005-10-20 01:10:49 PDT
Messages per page: