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 christophe blin <cblin at tennaxia dot com>
Full name christophe blin <cblin at tennaxia dot com>
Date 2005-10-20 02:03:33 PDT
Message 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
>
>
>
>

--
 
____________________​____________________​____________________​____________________​_______
Tennaxia, www.tennaxia.com,
société de services auprès des entreprises industrielles pour une gestion globale de
l'environnement
____________________​____________________​____________________​____________________​_______
Siège social :
6, rue Léonard de Vinci - 53001 Laval Cedex - Tél : 02 43 49 75 50 - Fax : 02 43 49 75 77
Agence Paris :
19, rue réaumur - 75003 Paris - Tél : 01 42 77 04 19 - Fax : 08 25 19 19 61
Agence Lyon :
Parc du Chater - 63 rue de la garenne - 69340 FRANCHEVILLE - Tél : 04 72 39 98 14 - Fax
: 04 72 39 93 85
Les informations contenues dans ce message envoyées par TENNAXIA sont confidentielles et
sont établies à l'attention exclusive de leurs destinataires. L'accès à ce message
par toute autre personne n'est pas autorisé. Si vous n'êtes pas le destinataire de ce
message, merci de le détruire et d'en avertir l'expéditeur : toute altération, copie,
distribution ou toute action prise ou omise sont interdites et peuvent être illégales.
The information in this message sent by TENNAXIA is confidential and may be legally
privileged. It is intended solely for the addressee(s). Access to this message by anyone
else is unauthorized. If you are not the intended recipient, please delete it and notify
the sender : any disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful.

« Previous message in topic | 3 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: