You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2004/04/01 19:50:48 UTC
cvs commit: jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/servlet/unit TestHttpResponse.java
vmassol 2004/04/01 09:50:48
Modified: samples/servlet/src/test-cactus/share/org/apache/cactus/sample/servlet/unit
TestHttpResponse.java
Log:
Do not test end of lines as this depends on container behaviors.
Revision Changes Path
1.4 +15 -24 jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/servlet/unit/TestHttpResponse.java
Index: TestHttpResponse.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/servlet/unit/TestHttpResponse.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestHttpResponse.java 29 Feb 2004 16:36:44 -0000 1.3
+++ TestHttpResponse.java 1 Apr 2004 17:50:48 -0000 1.4
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
-import java.io.StringWriter;
import javax.servlet.http.HttpServletResponse;
@@ -70,50 +69,42 @@
//-------------------------------------------------------------------------
/**
- * Verify that the <code>AsertUtils.getResponseAsString()</code> method
- * works with output text sent on multiple lines.
+ * Verify that the <code>WebResponse.getText()</code> method works.
*
* @exception IOException on test failure
*/
- public void testGetResponseAsStringMultiLines() throws IOException
+ public void testGetResponseAsText() throws IOException
{
PrintWriter pw = response.getWriter();
- response.setContentType("text/html");
- pw.println("<html><head/>");
- pw.println("<body>A GET request</body>");
- pw.println("</html>");
+ // Note: Ideally we could also test multi line to verify that end
+ // of lines are correctly handled. However, the different containers
+ // handle end of lines differently (some return "\r\n" - Windows
+ // style, others return "\n" - Unix style).
+ pw.print("<html><head/><body>A GET request</body></html>");
}
/**
- * Verify that the <code>AsertUtils.getResponseAsString()</code> method
- * works with output text sent on multiple lines.
+ * Verify that the <code>WebResponse.getText()</code> method works.
*
* @param theResponse the response from the server side.
*
* @exception IOException on test failure
*/
- public void endGetResponseAsStringMultiLines(WebResponse theResponse)
+ public void endGetResponseAsText(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 expected = "<html><head/><body>A GET request</body></html>";
+
String result = theResponse.getText();
- assertEquals(sw.toString(), result);
-
- pw.close();
+ assertEquals(expected, result);
}
//-------------------------------------------------------------------------
/**
- * Verify that the <code>getTestAsArray()</code> method
+ * Verify that the <code>getTextAsArray()</code> method
* works with output text sent on multiple lines. We also verify that
* we can call it several times with the same result.
*
@@ -130,7 +121,7 @@
}
/**
- * Verify that the <code>getTestAsArray()</code> method
+ * Verify that the <code>getTextAsArray()</code> method
* works with output text sent on multiple lines. We also verify that
* we can call it several times with the same result.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org