Vincent,
Much of the string you are testing is simply HTML structure.  I will test
if it the response I am looking for by seeing if the particular string of
interest occurs in the return.

assertTrue(result.indexOf("A GET request") > -1);

This approach only sorts a response from a set of possible responses.  But
that is frequently what I am looking for.

Regarding the line return issue, the JDOM thread had an extended discussion
of it. The thread title was: XML standard line ending. It was around March
11th. Their searchable archives are located in the website www.jdom.org

Regards,
Bill

Willie (Bill) Armstrong
931.788.6256 - Crossville office
860.961.0998 - Cell
[EMAIL PROTECTED]
mmbtoao - AIM
MysticBill - Yahoo Messenger


----------------------------------------------------------------------------------------

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------




                                                                                       
                                          
                      "Vincent Massol"                                                 
                                          
                      <vmassol                 To:      "'Cactus Developers List'" 
<[EMAIL PROTECTED]>               
                      @pivolis.com>            cc:      "'Cactus Users List'" <[EMAIL 
PROTECTED]>                   
                                               Subject: [Help] Servlet response's 
encoding of new lines, what is the correct     
                      03/24/2004 09:08         behavior?                               
                                          
                      AM                                                               
                                          
                      Please respond                                                   
                                          
                      to "Cactus Users                                                 
                                          
                      List"                                                            
                                          
                                                                                       
                                          
                                                                                       
                                          




Hi,

I need your help. We have one test in the Cactus test suite that tests
servlet response:

    public void testGetResponseAsStringMultiLines() throws IOException
    {
        PrintWriter pw = response.getWriter();

        response.setContentType("text/html");
        pw.println("<html><head/>");
        pw.println("<body>A GET request</body>");
        pw.println("</html>");
    }

    public void endGetResponseAsStringMultiLines(WebResponse
theResponse)
        throws IOException
    {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);

        pw.println("<html><head/>");
        pw.println("<body>A GET request</body>");
        pw.println("</html>");

        String result = theResponse.getText();

        assertEquals(sw.toString(), result);

        pw.close();
    }

The problem is that this test works fine on Orion 1.x, Orion 2.x and
Resin 2.x but it fails on Tomcat 4.1.30, Tomcat 3.x and Resin 3.x.

The container where the test succeeds are those returning Windows eol
characters (\r\n) whereas those that fail return Unix eol (\n).

Is there a way (through some encoding?) to control how the response
stream should encode end of lines?

Note: I've tried using:
response.setContentType("text/html;charset=ISO-8859-1"); (this is the
default). But it doesn't help. I'm really not proficient in encoding and
I'm not sure that encodings specify how eol are built ("\n" vs "\r\n").

Any idea?

Thanks for the help
-Vincent


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to