tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/tester/web ErrorPage06.jsp
Date Thu, 10 May 2001 19:20:33 GMT
craigmcc    01/05/10 12:20:33

  Modified:    tester/src/tester/org/apache/tester ErrorPage06.java
               tester/web ErrorPage06.jsp
  Log:
  Update tests to reflect corrected behavior on RuntimeException thrown by a
  servlet.  Tighten up the tests in the JSP-error-page case to actually
  validate the received values.
  
  Revision  Changes    Path
  1.3       +16 -25    jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage06.java
  
  Index: ErrorPage06.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage06.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ErrorPage06.java	2001/04/26 16:39:13	1.2
  +++ ErrorPage06.java	2001/05/10 19:20:29	1.3
  @@ -67,7 +67,7 @@
    * the ErrorPage05 servlet returns the appropriate exception.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2001/04/26 16:39:13 $
  + * @version $Revision: 1.3 $ $Date: 2001/05/10 19:20:29 $
    */
   
   public class ErrorPage06 extends HttpServlet {
  @@ -81,39 +81,24 @@
           PrintWriter writer = response.getWriter();
   
           // Accumulate all the reasons this request might fail
  -        ServletException exception = null;
  -        Throwable rootCause = null;
           StringBuffer sb = new StringBuffer();
           Object value = null;
   
           value = request.getAttribute("javax.servlet.error.exception");
  +        StaticLogger.write("exception is '" + value + "'");
           if (value == null) {
               sb.append(" exception is missing/");
  -        } else if (!(value instanceof javax.servlet.ServletException)) {
  +        } else if (!(value instanceof java.lang.ArithmeticException)) {
               sb.append(" exception class is ");
               sb.append(value.getClass().getName());
               sb.append("/");
  -        } else {
  -            exception = (ServletException) value;
  -            rootCause = exception.getRootCause();
  -        }
  -
  -        if (rootCause == null) {
  -            sb.append(" rootCause is missing/");
  -        } else if (!(rootCause instanceof java.lang.ArithmeticException)) {
  -            sb.append(" rootCause type is ");
  -            sb.append(rootCause.getClass().getName());
  -            sb.append("/");
  -        } else {
  -            String message = rootCause.getMessage();
  -            if (!"ErrorPage05 Threw ArithmeticException".equals(message)) {
  -                sb.append(" rootCause message is ");
  -                sb.append(message);
  -                sb.append("/");
  -            }
           }
   
           value = request.getAttribute("javax.servlet.error.exception_type");
  +        StaticLogger.write("exception_type is '" + value + "'");
  +        if (value != null)
  +            StaticLogger.write("exception_type class is '" +
  +                               value.getClass().getName() + "'");
           if (value == null)
               sb.append(" exception_type is missing/");
           else if (!(value instanceof Class)) {
  @@ -122,23 +107,28 @@
               sb.append("/");
           } else {
               Class clazz = (Class) value;
  -            if (!"javax.servlet.ServletException".equals(clazz.getName())) {
  -                sb.append(" exception_type class is ");
  -                sb.append(clazz.getName());
  +            String name = clazz.getName();
  +            if (!"java.lang.ArithmeticException".equals(name)) {
  +                sb.append(" exception_type is ");
  +                sb.append(name);
                   sb.append("/");
               }
           }
   
           value = request.getAttribute("javax.servlet.error.message");
  +        StaticLogger.write("message is '" + value + "'");
           if (value == null)
               sb.append(" message is missing/");
           else if (!(value instanceof String)) {
               sb.append(" message class is ");
               sb.append(value.getClass().getName());
               sb.append("/");
  +        } else if (!"ErrorPage05 Threw ArithmeticException".equals(value)) {
  +            sb.append(" message is not correct");
           }
   
           value = request.getAttribute("javax.servlet.error.request_uri");
  +        StaticLogger.write("request_uri is '" + value + "'");
           if (value == null)
               sb.append(" request_uri is missing/");
           else if (!(value instanceof String)) {
  @@ -157,6 +147,7 @@
           }
   
           value = request.getAttribute("javax.servlet.error.servlet_name");
  +        StaticLogger.write("servlet_name is '" + value + "'");
           if (value == null)
               sb.append(" servlet_name is missing/");
           else if (!(value instanceof String)) {
  
  
  
  1.2       +84 -1     jakarta-tomcat-4.0/tester/web/ErrorPage06.jsp
  
  Index: ErrorPage06.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/ErrorPage06.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ErrorPage06.jsp	2001/04/14 00:03:17	1.1
  +++ ErrorPage06.jsp	2001/05/10 19:20:31	1.2
  @@ -1,4 +1,87 @@
  -<%@ page contentType="text/plain" %>ErrorPage06 PASSED - JSP
  +<%@ page contentType="text/plain" %><%
  +
  +        // Accumulate all the reasons this request might fail
  +        StringBuffer sb = new StringBuffer();
  +        Object value = null;
  +
  +        value = request.getAttribute("javax.servlet.error.exception");
  +        if (value == null) {
  +            sb.append(" exception is missing/");
  +        } else if (!(value instanceof java.lang.ArrayIndexOutOfBoundsException)) {
  +            sb.append(" exception class is ");
  +            sb.append(value.getClass().getName());
  +            sb.append("/");
  +        }
  +
  +        value = request.getAttribute("javax.servlet.error.exception_type");
  +        if (value == null)
  +            sb.append(" exception_type is missing/");
  +        else if (!(value instanceof Class)) {
  +            sb.append(" exception_type class is ");
  +            sb.append(value.getClass().getName());
  +            sb.append("/");
  +        } else {
  +            Class clazz = (Class) value;
  +            String name = clazz.getName();
  +            if (!"java.lang.ArrayIndexOutOfBoundsException".equals(name)) {
  +                sb.append(" exception_type is ");
  +                sb.append(name);
  +                sb.append("/");
  +            }
  +        }
  +
  +        value = request.getAttribute("javax.servlet.error.message");
  +        if (value == null)
  +            sb.append(" message is missing/");
  +        else if (!(value instanceof String)) {
  +            sb.append(" message class is ");
  +            sb.append(value.getClass().getName());
  +            sb.append("/");
  +        } else if (!"ErrorPage05 Threw ArrayIndexOutOfBoundsException".equals(value)) {
  +            sb.append(" message is not correct");
  +        }
  +
  +        value = request.getAttribute("javax.servlet.error.request_uri");
  +        if (value == null)
  +            sb.append(" request_uri is missing/");
  +        else if (!(value instanceof String)) {
  +            sb.append(" request_uri class is ");
  +            sb.append(value.getClass().getName());
  +            sb.append("/");
  +        } else {
  +            String request_uri = (String) value;
  +            String test1 = request.getContextPath() + "/ErrorPage05";
  +            String test2 = request.getContextPath() + "/WrappedErrorPage05";
  +            if (!request_uri.equals(test1) && !request_uri.equals(test2)) {
  +                sb.append(" request_uri is ");
  +                sb.append(request_uri);
  +                sb.append("/");
  +            }
  +        }
  +
  +        value = request.getAttribute("javax.servlet.error.servlet_name");
  +        if (value == null)
  +            sb.append(" servlet_name is missing/");
  +        else if (!(value instanceof String)) {
  +            sb.append(" servlet_name class is ");
  +            sb.append(value.getClass().getName());
  +            sb.append("/");
  +        } else {
  +            String servlet_name = (String) value;
  +            if (!"ErrorPage05".equals(servlet_name)) {
  +                sb.append(" servlet_name is ");
  +                sb.append(servlet_name);
  +                sb.append("/");
  +            }
  +        }
  +
  +        // Report ultimate success or failure
  +        if (sb.length() < 1)
  +            out.println("ErrorPage06 PASSED - JSP");
  +        else
  +            out.println("ErrorPage06 FAILED -" + sb.toString());
  +
  +%>
   <%
     Exception e = (Exception)
      request.getAttribute("javax.servlet.error.exception");
  
  
  

Mime
View raw message