jakarta-watchdog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest GetPathTranslatedTestServlet.java
Date Sat, 27 Jan 2001 00:09:52 GMT
craigmcc    01/01/26 16:09:52

  Modified:    src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest
                        GetPathTranslatedTestServlet.java
  Log:
  Correct several aspects of this test:
  * It is legal for request.getPathTranslated() to return null - for example,
    in a web application that is run directly out of a WAR file.
  * The test expected that the translated path would include the input value
    in it.  While this is common, it cannot be assumed, because containers
    provide mechanisms to define mappings of URLs to arbitrary disk paths.
  * The correct value of request.getPathTranslated() should match the value
    returned by getServletContext().getRealPath(request.getPathInfo())
    [Servlet Specification 2.3 (PFD), Section 4.5] so check for that.
  
  Revision  Changes    Path
  1.2       +28 -15    jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetPathTranslatedTestServlet.java
  
  Index: GetPathTranslatedTestServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetPathTranslatedTestServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetPathTranslatedTestServlet.java	2000/10/16 22:38:56	1.1
  +++ GetPathTranslatedTestServlet.java	2001/01/27 00:09:51	1.2
  @@ -1,6 +1,6 @@
   /*
  - * $Header: /home/cvs/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetPathTranslatedTestServlet.java,v
1.1 2000/10/16 22:38:56 santosh Exp $
  - * $Date: 2000/10/16 22:38:56 $
  + * $Header: /home/cvs/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetPathTranslatedTestServlet.java,v
1.2 2001/01/27 00:09:51 craigmcc Exp $
  + * $Date: 2001/01/27 00:09:51 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -77,19 +77,32 @@
   	public void service (HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
   
   		PrintWriter out = response.getWriter();
  -		//checking for a not null value
  +		//checking for a value that matches expected value
  +                String realTranslated =
  +                    getServletContext().getRealPath(request.getPathInfo());
   		String pathTranslated = request.getPathTranslated();
  -		if( ( pathTranslated !=null) && ( pathTranslated.trim().indexOf("/servlet-tests/javax_servlet")
> -1 ) )
  -		{
  -			out.println("GetPathTranslatedTest test PASSED");
  -		}
  -		else
  -		{
  -			out.println("GetPathTranslatedTest test FAILED");
  -			out.println("getPathTranslated returned incorrect value");
  -			out.println("Actual Returned value -> " + pathTranslated );
  -			out.println("Expected Returned value -> should contain /servlet-tests/jaavx_servlet
"  );
  -		}
  +                if (realTranslated == null) {
  +                    if (pathTranslated == null) {
  +                        out.println("GetPathTranslatedTest test PASSED");
  +                    } else {
  +                        out.println("GetPathTranslatedTest test FAILED");
  +                        out.println("Expected --> " + realTranslated);
  +                        out.println("Received --> " + pathTranslated);
  +                    }
  +                } else {
  +                    if (pathTranslated == null) {
  +                        out.println("GetPathTranslatedTest test FAILED");
  +                        out.println("Expected --> " + realTranslated);
  +                        out.println("Received --> " + pathTranslated);
  +                    } else if (!realTranslated.equals(pathTranslated)) {
  +                        out.println("GetPathTranslatedTest test FAILED");
  +                        out.println("Expected --> " + realTranslated);
  +                        out.println("Received --> " + pathTranslated);
  +                    } else {
  +                        out.println("GetPathTranslatedTest test PASSED");
  +                    }
  +                }
   
  -	}
  +        }
  +
   }
  
  
  

Mime
View raw message