You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/03/21 21:28:36 UTC

cvs commit: jakarta-tomcat-4.0/tester/src/tester/org/apache/tester Resources05.java

craigmcc    01/03/21 12:28:34

  Modified:    tester/src/bin tester.xml
               tester/src/tester/org/apache/tester Resources05.java
  Log:
  Update the new combined getResource()/openStream() test so that it
  optionally converts the URL returned by getResource() to a string and
  back, emulating what some applications might do.  NOTE:  Tomcat 4.0 still
  passes these tests, both with and without the "-usenaming" switch at
  startup time.
  
  Revision  Changes    Path
  1.23      +27 -0     jakarta-tomcat-4.0/tester/src/bin/tester.xml
  
  Index: tester.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- tester.xml	2001/03/21 19:38:40	1.22
  +++ tester.xml	2001/03/21 20:28:24	1.23
  @@ -377,6 +377,33 @@
            request="${context.path}/Resources05?mode=class&path=/org/apache/tester/Unpacked05.txt"
         outContent="Resources05 PASSED"/>
   
  +    <!-- ========== Positive Combined getResource/Open/Stringify Tests ==== -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +           debug="${debug}"
  +         request="${context.path}/Resources05?mode=context&amp;path=/WEB-INF/web.xml&amp;stringify=true"
  +      outContent="&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +           debug="${debug}"
  +         request="${context.path}/Resources05?mode=context&amp;path=/Forward01.txt&amp;stringify=true"
  +      outContent="Forward01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +           debug="${debug}"
  +         request="${context.path}/Resources05?mode=context&amp;path=/Include01.txt&amp;stringify=true"
  +      outContent="Include01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +           debug="${debug}"
  +         request="${context.path}/Resources05?mode=class&amp;path=/org/apache/tester/Resources05.txt&amp;stringify=true"
  +      outContent="Resources05 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +           debug="${debug}"
  +         request="${context.path}/Resources05?mode=class&amp;path=/org/apache/tester/Unpacked05.txt&amp;stringify=true"
  +      outContent="Resources05 PASSED"/>
  +
     </target>
   
   
  
  
  
  1.2       +16 -2     jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Resources05.java
  
  Index: Resources05.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Resources05.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Resources05.java	2001/03/21 19:38:46	1.1
  +++ Resources05.java	2001/03/21 20:28:31	1.2
  @@ -76,10 +76,13 @@
    *     test, or <code>class</code> for class loader test.  [context]</li>
    * <li><strong>path</strong> - Resource path to the requested resource,
    *     starting with a slash.  [/WEB-INF/web.xml]</li>
  + * <li><strong>stringify</strong> - If set to any arbitrary value, the URL
  + *     returned by getResource() will be converted to a String and then back
  + *     to a URL before being opened.  [not set]</li>
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2001/03/21 19:38:46 $
  + * @version $Revision: 1.2 $ $Date: 2001/03/21 20:28:31 $
    */
   
   public class Resources05 extends HttpServlet {
  @@ -94,6 +97,7 @@
           String path = request.getParameter("path");
           if (path == null)
               path = "/WEB-INF/web.xml";
  +        boolean stringify = (request.getParameter("stringify") != null);
   
           // Prepare for the desired test
           response.setContentType("text/plain");
  @@ -115,8 +119,18 @@
                   ok = false;
               }
           } catch (MalformedURLException e) {
  -            results.append(" MalformedURLException");
  +            results.append(" getResource MalformedURLException");
               ok = false;
  +        }
  +
  +        // Stringify the URL if requested
  +        try {
  +            if (ok) {
  +                String urlString = url.toString();
  +                url = new URL(urlString);
  +            }
  +        } catch (MalformedURLException e) {
  +            results.append(" stringify MalformedURLException");
           }
   
           // Open an input stream and input stream reader on this URL