Login | Register
My pages Projects Community openCollabNet

Discussions > users > bug : HttpTestCase::getResponse

Discussion topic

Back to topic list

bug : HttpTestCase::getResponse

Author christophe blin <cblin at tennaxia dot com>
Full name christophe blin <cblin at tennaxia dot com>
Date 2005-10-19 10:21:46 PDT
Message 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):
        <meta http-equiv="Content-Type" content="text/html;
    no-accents: e e a
    accents: é è à

# imports
from PyHttpTestCase import PyHttpTestCase

# defintition of test class
class MaxQTest(PyHttpTestCase):
    def __init__(self):
        PyHttpTestCase.__init__(self, "")

    def runTest(self):
        print self.responseContains('accents: é è à');
        print self.getResponse().f​ind('accents: é è à');
# Code to load and run the test
test = MaxQTest()

this will print :

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

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)


Tennaxia, www.tennaxia.com,
société de services auprès des entreprises industrielles pour une gestion globale de
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 | 1 of 4 | Next message in topic »


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: