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 oliverbock
Full name Oliver Bock
Date 2005-10-19 15:34:22 PDT
Message 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
>

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