Hi, This test, the way it is currently written, expects that whent he client invokes the HTTP HEAD method, that a response-body is returned. This is incorrect. The test currently passes due to Tomcat Bugzilla 5126.
I've modified the test so that no response output is written via a writer and instead will use sendError( int, string ), to send the status of the test. I had to add a new instance variable and setter method to GTest so that the response message could be configured by the servlet-gtest.xml file, and be checked appropriately by the checkResponse() method of GTest. NOTE: The goldenfile ${wgdir}/javax_servlet_http/HttpServletRequest/GetMethod_HEADTest.html should be removed from the repository. Attached are the patches necessary to correct this test. Comments welcome. -rl
Index: GTest.java =================================================================== RCS file: /home/cvspublic/jakarta-watchdog-4.0/src/tools/org/apache/tomcat/task/GTest.java,v retrieving revision 1.3 diff -u -r1.3 GTest.java --- GTest.java 2001/09/28 04:09:56 1.3 +++ GTest.java 2001/11/27 15:19:57 @@ -37,6 +37,7 @@ Hashtable expectHeaders; // Match request line String returnCode=""; + String returnCodeMsg = ""; // Actual response String responseLine; @@ -221,6 +222,10 @@ this.returnCode=s; } + public void setReturnCodeMsg( String s ) { + this.returnCodeMsg = s; + } + public void setHeaders( String s ) { requestHeaders=new Hashtable(); parseHeader( s, requestHeaders ); @@ -309,7 +314,13 @@ // If returnCode doesn't match if( request.indexOf( "HTTP/1." ) > -1) { - boolean match= ( responseLine!=null && responseLine.indexOf(returnCode) > -1); + boolean match = false; + if ( returnCodeMsg == "" ) { + match = ( responseLine != null && responseLine.indexOf( returnCode ) > +-1 ); + } else { + match = ( responseLine != null && responseLine.indexOf( returnCode ) > -1 + && responseLine.indexOf( returnCodeMsg ) > -1 ); + } if( match != testCondition ) { responseStatus = false; System.out.println("ERROR in: " + request);
Index: GetMethod_HEADTestServlet.java =================================================================== RCS file: /home/cvspublic/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetMethod_HEADTestServlet.java,v retrieving revision 1.1 diff -u -r1.1 GetMethod_HEADTestServlet.java --- GetMethod_HEADTestServlet.java 2000/10/16 22:38:56 1.1 +++ GetMethod_HEADTestServlet.java 2001/11/27 14:52:17 @@ -80,20 +80,16 @@ public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - PrintWriter out = response.getWriter(); String method = request.getMethod(); if(method!=null) { if(method.trim().equalsIgnoreCase("HEAD")) { - out.println("GetMethod_HEADTest test PASSED"); + response.sendError( HttpServletResponse.SC_OK, +"GetMethod_HEADTest PASSED"); return; } } - out.println("GetMethod_HEADTest test FAILED"); - out.println( "<BR>getMethod did not return proper method type"); - out.println("Actual Return Value : " + method ); - out.println("Expected Return Value : HEAD " ); + response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, +"GetMethod_HEADTest FAILED" ); } }
Index: servlet-gtest.xml =================================================================== RCS file: /home/cvspublic/jakarta-watchdog-4.0/src/conf/servlet-gtest.xml,v retrieving revision 1.19 diff -u -r1.19 servlet-gtest.xml --- servlet-gtest.xml 2001/07/20 23:07:56 1.19 +++ servlet-gtest.xml 2001/11/27 15:14:13 @@ -739,7 +739,7 @@ <gtest request="HEAD /servlet-tests/GetMethod_HEADTest HTTP/1.0" debug="0" host="${host}" port="${port}" - goldenFile="${wgdir}/javax_servlet_http/HttpServletRequest/GetMethod_HEADTest.html" /> + returnCode="200" returnCodeMsg="GetMethod_HEADTest PASSED" /> <gtest request="POST /servlet-tests/GetMethod_POSTTest HTTP/1.0" debug="0" host="${host}" port="${port}"
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>