costin      01/01/28 22:46:19

  Modified:    src/admin/WEB-INF admin.tld web.xml
               src/admin/WEB-INF/classes/tadm GTestTag.java
               src/admin/test test.jsp
  Added:       src/admin/WEB-INF ant.tld
               src/admin/WEB-INF/classes/tadm AntProperty.java AntTEI.java
                        AntTag.java AntTarget.java
               src/admin/WEB-INF/scripts run-test.sh
               src/admin/test sanity-form.jsp
  Log:
  A bit of reorganization of the tester before it becomes more complex.
  
  We use simpler tags - GTestTag is dealing only with GTest-specific properties.
  AntTag is calling ant, and you can set properties using AntProperty.
  
  Tags that deal with ant are separated from tags that deal with general
  administration ( which also need more specialization )
  
  ( BTW, there are quite a few interesting pages we can add - like
  rebuilding a web application from the web page, etc - there is a lot
  of automation that can be done using <ant> tag )
  
  Revision  Changes    Path
  1.8       +34 -70    jakarta-tomcat/src/admin/WEB-INF/admin.tld
  
  Index: admin.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/admin.tld,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- admin.tld 2001/01/23 05:08:37     1.7
  +++ admin.tld 2001/01/29 06:46:17     1.8
  @@ -8,13 +8,13 @@
     <jspversion>1.1</jspversion>
     <shortname>Admin</shortname>
     <uri>http://jakarta.apache.org/taglibs/tomcat_admin-1.0</uri>
  -
  +  
     <info>
       Admin tags
     </info>
  -
  +  
     <!-- ******************** Defined Custom Tags *************************** -->
  -
  +  
     <tag>
       <name>admin</name>
       <tagclass>tadm.TomcatAdmin</tagclass>
  @@ -24,96 +24,60 @@
         make available the "cm" and "ctx" variables.
       </info>
       <attribute>
  -       <name>action</name>
  -       <required>false</required>
  +      <name>action</name>
  +      <required>false</required>
       </attribute>
       <attribute>
  -       <name>ctxPathParam</name>
  -       <required>false</required>
  +      <name>ctxPathParam</name>
  +      <required>false</required>
       </attribute>
       <attribute>
  -       <name>docBaseParam</name>
  -       <required>false</required>
  +      <name>docBaseParam</name>
  +      <required>false</required>
       </attribute>
       <attribute>
  -       <name>docBase</name>
  -       <required>false</required>
  +      <name>docBase</name>
  +      <required>false</required>
       </attribute>
       <attribute>
  -       <name>ctxPath</name>
  -       <required>false</required>
  -       <rtexprvalue>true</rtexprvalue>
  +      <name>ctxPath</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
       </attribute>
       <attribute>
  -       <name>ctxHost</name>
  -       <required>false</required>
  -       <rtexprvalue>true</rtexprvalue>
  +      <name>ctxHost</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
       </attribute>
       <attribute>
  -       <name>value</name>
  -       <required>false</required>
  +      <name>value</name>
  +      <required>false</required>
       </attribute>
     </tag>
  -  
  -  <tag>
  -     <name>iterate</name>
  -     <tagclass>tadm.TomcatIterate</tagclass>
  -        <teiclass>tadm.TomcatIterateTEI</teiclass>
  -     <bodycontent>JSP</bodycontent>
  -     <attribute>
  -         <name>enumeration</name>
  -         <required>false</required>
  -         <rtexprvalue>true</rtexprvalue>
  -     </attribute>
  -     <attribute>
  -         <name>array</name>
  -         <required>false</required>
  -         <rtexprvalue>true</rtexprvalue>
  -     </attribute>
  -     <attribute>
  -         <name>name</name>
  -         <required>true</required>
  -     </attribute>
  -     <attribute>
  -         <name>type</name>
  -         <required>true</required>
  -     </attribute>
  -     
   
  -  </tag>
  -
  -
  +  <!-- this is a "generic" tag, should be moved in a separate tld -->  
     <tag>
  -    <name>gtest</name>
  -    <tagclass>tadm.GTestTag</tagclass>
  -    <teiclass>tadm.GTestTEI</teiclass>
  -    <info>
  -      Run a GTest-based test suite.
  -    </info>
  +    <name>iterate</name>
  +    <tagclass>tadm.TomcatIterate</tagclass>
  +    <teiclass>tadm.TomcatIterateTEI</teiclass>
  +    <bodycontent>JSP</bodycontent>
       <attribute>
  -       <name>testFile</name>
  -       <required>true</required>
  +      <name>enumeration</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
       </attribute>
       <attribute>
  -       <name>testApp</name>
  -       <required>false</required>
  +      <name>array</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
       </attribute>
       <attribute>
  -       <name>target</name>
  -       <required>false</required>
  -       <rtexprvalue>true</rtexprvalue>
  +      <name>name</name>
  +      <required>true</required>
       </attribute>
       <attribute>
  -       <name>debug</name>
  -       <required>false</required>
  -       <rtexprvalue>true</rtexprvalue>
  +      <name>type</name>
  +      <required>true</required>
       </attribute>
  -    <attribute>
  -       <name>outputType</name>
  -       <required>false</required>
  -       <rtexprvalue>true</rtexprvalue>
  -    </attribute>
     </tag>
  -
  -
   </taglib>
  
  
  
  1.6       +31 -25    jakarta-tomcat/src/admin/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/web.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- web.xml   2001/01/24 01:44:33     1.5
  +++ web.xml   2001/01/29 06:46:18     1.6
  @@ -1,29 +1,35 @@
   <?xml version="1.0" encoding="ISO-8859-1"?>
  -<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  +<!DOCTYPE web-app PUBLIC 
  +     "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
       "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
  +
   <web-app>
  -     <description>
  -     Tomcat Admin 
  -  </description>
  -     <taglib>
  -             
<taglib-uri>http://jakarta.apache.org/taglibs/tomcat_admin-1.0</taglib-uri>
  -             <taglib-location>/WEB-INF/admin.tld</taglib-location>
  -     </taglib>
  -     <security-constraint>
  -             <web-resource-collection>
  -                     <web-resource-name>Protected Area</web-resource-name>
  -                     <url-pattern>/contextAdmin/*</url-pattern>
  -                     <http-method>DELETE</http-method>
  -                     <http-method>GET</http-method>
  -                     <http-method>POST</http-method>
  -                     <http-method>PUT</http-method>
  -             </web-resource-collection>
  -             <auth-constraint>
  -                     <role-name>admin</role-name>
  -             </auth-constraint>
  -     </security-constraint>
  -     <login-config>
  -             <auth-method>BASIC</auth-method>
  -             <realm-name>Admin</realm-name>
  -     </login-config>
  +  <description>Tomcat Admin</description>
  +  <taglib>
  +    <taglib-uri>http://jakarta.apache.org/taglibs/tomcat_admin-1.0</taglib-uri>
  +    <taglib-location>/WEB-INF/admin.tld</taglib-location>
  +  </taglib>
  +  <taglib>
  +    <taglib-uri>http://jakarta.apache.org/taglibs/ant-1.0</taglib-uri>
  +    <taglib-location>/WEB-INF/ant.tld</taglib-location>
  +  </taglib>
  +
  +  <security-constraint>
  +    <web-resource-collection>
  +      <web-resource-name>Protected Area</web-resource-name>
  +      <url-pattern>/contextAdmin/*</url-pattern>
  +      <http-method>DELETE</http-method>
  +      <http-method>GET</http-method>
  +      <http-method>POST</http-method>
  +      <http-method>PUT</http-method>
  +    </web-resource-collection>
  +    <auth-constraint>
  +      <role-name>admin</role-name>
  +    </auth-constraint>
  +  </security-constraint>
  +  
  +  <login-config>
  +    <auth-method>BASIC</auth-method>
  +    <realm-name>Admin</realm-name>
  +  </login-config>
   </web-app>
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/ant.tld
  
  Index: ant.tld
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
  
  <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>Ant</shortname>
    <uri>http://jakarta.apache.org/taglibs/ant-1.0</uri>
  
    <info>
      Tags allowing us to run ant. Ant can do a lot of usefull tasks 
      ( run time building, automated testing, etc ).
    </info>
  
    <!-- ******************** Defined Custom Tags *************************** -->
    <tag>
      <name>ant</name>
      <tagclass>tadm.AntTag</tagclass>
      <teiclass>tadm.AntTEI</teiclass>
      <info>Run ant</info>
      <attribute>
         <name>testFile</name>
         <required>true</required>
      </attribute>
      <attribute>
         <name>testApp</name>
         <required>false</required>
      </attribute>
      <attribute>
         <name>target</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>debug</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>outputType</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
  
  
    <tag>
      <name>property</name>
      <tagclass>tadm.AntProperty</tagclass>
      <info>Set a property to GTest and ant. If no value is specificed, 
  a request parameter with the same name will be used</info>
      <attribute>
         <name>name</name>
         <required>true</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>param</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>value</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>location</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>webApp</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
  
    <tag>
      <name>target</name>
      <tagclass>tadm.AntTarget</tagclass>
      <info>Add a target. You can either specify the target name or the 
  name of a request parameter holding the name(s)</info>
      <attribute>
         <name>name</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>param</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
  
    <tag>
      <name>gtest</name>
      <tagclass>tadm.GTestTag</tagclass>
      <teiclass>tadm.GTestTEI</teiclass>
      <info>Make GTest properties available for scripting</info>
    </tag>
  
  </taglib>
  
  
  
  1.9       +9 -152    jakarta-tomcat/src/admin/WEB-INF/classes/tadm/GTestTag.java
  
  Index: GTestTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/classes/tadm/GTestTag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- GTestTag.java     2001/01/28 19:18:36     1.8
  +++ GTestTag.java     2001/01/29 06:46:18     1.9
  @@ -1,6 +1,5 @@
   package tadm;
  -import java.util.Vector;
  -import java.util.Enumeration;
  +import java.util.*;
   import java.io.*;
   import java.net.URL;
   import javax.servlet.http.*;
  @@ -13,33 +12,15 @@
   import org.apache.tomcat.util.test.*;
   
   /**
  - * This tag will run a GTest-based test suite.
  - * 
  + * This tag will make available various properties needed to access
  + * GTest static variables.
    */
   public class GTestTag extends TagSupport {
  -    PageContext pageContext;
  -    String revision;
       
       public GTestTag() {}
   
       public int doStartTag() throws JspException {
        try {
  -         HttpServletRequest req=(HttpServletRequest)pageContext.
  -             getRequest();
  -
  -         ServletContext thisCtx=pageContext.getServletConfig().
  -             getServletContext();
  -
  -         // the admin can get other contexts, we are trusted
  -         ServletContext targetCtx=(testApp==null) ? thisCtx:
  -             thisCtx.getContext( testApp );
  -                                                         
  -         String base=targetCtx.getRealPath("/");
  -         
  -         runTest( base );
  -
  -         pageContext.setAttribute("gtestTestRevision",
  -                                  revision);
            pageContext.setAttribute("gtestTestResults",
                                     GTest.getTestResults());
            pageContext.setAttribute("gtestTestFailures",
  @@ -51,138 +32,14 @@
            pageContext.setAttribute("gtestHttpClients",
                                     HttpClient.getHttpClients());
   
  +                 
  +         // reset test repositories
  +         GTest.resetGTest();
  +         GTest.setDefaultWriter( pageContext.getResponse().getWriter() );
  +
        } catch (Exception ex ) {
            ex.printStackTrace();
  -     }
  -     return EVAL_BODY_INCLUDE;
  -    }
  -
  -    public int doEndTag() throws JspException {
  -     return EVAL_PAGE;
  -    }
  -    
  -    public void setPageContext(PageContext pctx ) {
  -     this.pageContext=pctx;
  -    }
  -
  -    public void setParent( Tag parent ) {
  -     super.setParent( parent);
  -    }
  -
  -    public void release() {
  -    }
  -
  -    //-------------------- Properties --------------------
  -    String testFileName;
  -    String target;
  -    String testApp;
  -    String debug;
  -    String outputType="html";
  -
  -    /** Set the name of the test.xml, relative to the base dir.
  -     *  For example, /WEB-INF/test-tomcat.xml
  -     */
  -    public void setTestFile( String s ) {
  -     testFileName=s;
  -    }
  -
  -    /** Set the target - a subset of tests to be run
  -     */
  -    public void setTarget( String s ) {
  -     //      System.out.println("Setting target " + s );
  -     target=s;
  -    }
  -
  -    /** The application containing the test file
  -     *  ( if not set assume the test file is local to /admin app.
  -     */
  -    public void setTestApp( String s ) {
  -     testApp=s;
  -    }
  -
  -    public void setDebug( String s ) {
  -     debug=s;
  -    }
  -
  -    public void setOutputType( String s ) {
  -     outputType=s;
  -    }
  -    
  -    // -------------------- Implementation methods --------------------
  -    
  -    private void runTest( String base) throws IOException {
  -     PrintWriter out=pageContext.getResponse().getWriter();
  -     try {
  -         out.flush();
  -         //    out.println("Running test " + base + " " + testFileName + " "
  -         //                         + target + "</br>" );
  -         File testFile=new File( base + testFileName);
  -
  -
  -         // reset test repositories
  -         GTest.getTestResults().setSize(0);
  -         GTest.getTestFailures().setSize(0);
  -         GTest.getTestSuccess().setSize(0);
  -         GTest.getTestProperties().clear();
  -         HttpClient.getHttpClients().clear();
  -         
  -         //      // old task
  -         //      org.apache.tomcat.task.GTest.setDefaultWriter( out );
  -         //      org.apache.tomcat.task.GTest.setHtmlMode( true );
  -         // new one
  -         GTest.setDefaultWriter(out);
  -         GTest.setDefaultOutput(outputType); // external formatting
  -         if(debug!=null)
  -             GTest.setDefaultDebug(Integer.valueOf( debug ).intValue());
  -         
  -         Project project=new Project();
  -         
  -         AntServletLogger log=new AntServletLogger();
  -         log.setWriter( out );
  -         project.addBuildListener( log );
  -         
  -         project.init();
  -         project.setUserProperty( "ant.file", testFile.toString());
  -         // XXX
  -         project.setUserProperty( "gdir", base + "/Golden");
  -         project.setUserProperty( "wgdir", base + "/Golden");
  -
  -         String port=pageContext.getRequest().getParameter("port");
  -         if( port!=null)
  -             project.setUserProperty( "port", port);
  -         String proto=pageContext.getRequest().getParameter("server.proto");
  -         if( proto!=null )
  -             project.setUserProperty( "http.protocol", proto);
  -         String host=pageContext.getRequest().getParameter("host");
  -         if( host!=null )
  -             project.setUserProperty( "host", host);
  -         
  -         ProjectHelper.configureProject( project, testFile );
  -
  -         // try to get revision if present
  -         revision = project.getProperty( "revision" );
  -         if (revision  == null)
  -             revision  = "Revision: Unknown";
  -         else {
  -             // clean up a little in case CVS $Revision: 1.8 $ used
  -             revision  = revision .replace('$',' ');
  -             revision .trim();
  -         }
  -         
  -         Vector targets=new Vector();
  -         if( target==null ) target="client";
  -         
  -         targets.addElement( target );
  -         project.executeTargets( targets );
  -         
  -     } catch( Exception ex ) {
  -         ex.printStackTrace(out);
  -         if( ex instanceof BuildException ) {
  -             Throwable ex1=((BuildException)ex).getException();
  -             out.println("Root cause: " );
  -             if( ex1!=null)
  -                 ex1.printStackTrace(out);
  -         }
        }
  +     return SKIP_BODY;
       }
   }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/AntProperty.java
  
  Index: AntProperty.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import org.apache.tools.ant.*;
  import org.apache.tomcat.util.test.*;
  
  /**
   * Child tag to pass ant properties to Ant tag
   * 
   */
  public class AntProperty extends TagSupport {
      
      public AntProperty() {}
  
      public int doStartTag() throws JspException {
        Tag parent=getParent();
        if( parent == null  )
            throw new JspException( "AntProperty used as top-level tag,"+
                                    "must be inside <ant>");
        if( ! (parent instanceof AntTag))
            throw new JspException( "AntProperty must be child of <ant>");
  
        AntTag antTag=(AntTag)parent;
  
        if( value==null && location!= null ) {
            // the property will be set with the absolute path
            // of the "location", relative to this or another
            // (accessible) web application
            HttpServletRequest req=(HttpServletRequest)pageContext.
                getRequest();
            ServletContext thisCtx=pageContext.getServletConfig().
                getServletContext();
            ServletContext targetCtx=(webapp==null) ? thisCtx:
                thisCtx.getContext( webapp );
            value=targetCtx.getRealPath(location);
        }
  
        
        if( value == null ) {
            // if param is used, try it first ( param!= name )
            if( param != null ) {
                value=pageContext.getRequest().getParameter( param );
            } else {
                value=pageContext.getRequest().getParameter( name );
            }
        }
  
        if( value != null )
            antTag.setProperty( name, value );
  
        return SKIP_BODY;
      }
  
      //-------------------- Properties --------------------
      String name;
      String value;
      String param;
  
      public void setName( String s ) {
        name=s;
      }
  
      public void setParam( String s ) {
        param=s;
      }
  
      public void setValue( String s ) {
        value=s;
      }
  
      // -------------------- Special properties --------------------
      String location;
      String webapp;
  
      public void setLocation( String s ) {
        location=s;
      }
  
      /** Set the property with the "base" of the web application
       */
      public void setWebApp( String s ) {
        webapp=s;
      }
  
  
      // -------------------- From ant --------------------
      
  }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/AntTEI.java
  
  Index: AntTEI.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.File;
  import java.net.URL;
  import javax.servlet.http.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.tomcat.core.Request;
  import org.apache.tomcat.core.Context;
  import org.apache.tomcat.core.ContextManager;
  
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  public class AntTEI extends TagExtraInfo {
  
      public VariableInfo[] getVariableInfo(TagData data) {
        return (new VariableInfo[] {
            new VariableInfo("antProperties",
                             "java.util.Properties",
                             true,  VariableInfo.AT_BEGIN),
        });
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/AntTag.java
  
  Index: AntTag.java
  ===================================================================
  package tadm;
  import java.util.*;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import org.apache.tools.ant.*;
  
  /**
   * This tag will run ant tasks
   * 
   */
  public class AntTag extends TagSupport {
      
      public AntTag() {}
  
      public int doStartTag() throws JspException {
        try {
            pageContext.setAttribute("antProperties",
                                     args);
        } catch (Exception ex ) {
            ex.printStackTrace();
        }
        return EVAL_BODY_INCLUDE;
      }
  
      public int doEndTag() throws JspException {
        runTest();
        return EVAL_PAGE;
      }
  
      // -------------------- child tag support --------------------
      Properties args=new Properties();
      Vector targets=new Vector();
      
      public void setProperty( String name, String value ) {
        System.out.println("Adding property " + name + "=" + value );
        args.put(name, value );
      }
  
      public String getProperty( String name ) {
        System.out.println("Getting property " + name  );
        return args.getProperty(name );
      }
  
      public void addTarget( String n ) {
        System.out.println("Adding target " + n );
        targets.addElement( n );
      }
      
      //-------------------- Properties --------------------
  
      String testFileName;
      String target;
      String testApp;
      String debug;
      String outputType="html";
  
      /** Set the name of the test.xml, relative to the base dir.
       *  For example, /WEB-INF/test-tomcat.xml
       */
      public void setTestFile( String s ) {
        testFileName=s;
      }
  
      /** Set the target - a subset of tests to be run
       */
      public void setTarget( String s ) {
        //      System.out.println("Setting target " + s );
        target=s;
      }
  
      /** The application containing the test file
       *  ( if not set assume the test file is local to /admin app.
       */
      public void setTestApp( String s ) {
        testApp=s;
      }
  
      public void setDebug( String s ) {
        debug=s;
      }
  
      public void setOutputType( String s ) {
        outputType=s;
      }
      
      // -------------------- Implementation methods --------------------
      
      private void runTest() throws JspException {
        PrintWriter out=null;
        try {
            out=pageContext.getResponse().getWriter();
            pageContext.getOut().flush();
            out.flush(); // we need a writer for ant
            
            Project project=new Project();
            
            AntServletLogger log=new AntServletLogger();
            log.setWriter( out );
            project.addBuildListener( log );
            
            project.init();
  
            Enumeration argsE=args.propertyNames();
            while( argsE.hasMoreElements() ) {
                String k=(String)argsE.nextElement();
                String v=args.getProperty( k );
                if( k!=null && v!= null )
                    project.setUserProperty( k, v );
            }
  
            String antFileN=args.getProperty("ant.file");
            if( antFileN==null )
                throw new JspException( "ant.file not specified");
            File antF=new File(antFileN);
            ProjectHelper.configureProject( project,
                                           antF );
  
            // pre-execution properties
            Hashtable antProperties=project.getProperties();
            argsE=antProperties.keys();
            while( argsE.hasMoreElements() ) {
                String k=(String)argsE.nextElement();
                String v=(String)antProperties.get( k );
                if( k!=null && v!= null )
                    args.put( k, v ); // includes "revision"
            }
            
            if( targets.size()==0 ) {
                //targets.addElement("client");
            }
  
            project.executeTargets( targets );
  
            // post-execution properties
            antProperties=project.getProperties();
  
            argsE=antProperties.keys();
            while( argsE.hasMoreElements() ) {
                String k=(String)argsE.nextElement();
                String v=(String)antProperties.get( k );
                if( k!=null && v!= null )
                    args.put( k, v ); 
            }
            
        } catch( BuildException ex ) {
            if( out==null ) out=new PrintWriter(System.out);
            ex.printStackTrace(out);
            Throwable ex1=ex.getException();
            out.println("Root cause: " );
            if( ex1!=null)
                ex1.printStackTrace(out);
            out.flush();
            throw new JspException( ex.toString() );
        } catch( IOException ioex ) {
            if( out==null ) out=new PrintWriter(System.out);
            ioex.printStackTrace(out);
            throw new JspException( ioex.toString() );
        }
      }
  }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/classes/tadm/AntTarget.java
  
  Index: AntTarget.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import org.apache.tools.ant.*;
  import org.apache.tomcat.util.test.*;
  
  /**
   * Child tag to add ant targets to Ant taglib.
   * 
   */
  public class AntTarget extends TagSupport {
      
      public AntTarget() {}
  
      public int doStartTag() throws JspException {
        Tag parent=getParent();
        if( parent == null  )
            throw new JspException( "AntTarget used as top-level tag,"+
                                    "must be inside <ant>");
        if( ! (parent instanceof AntTag ))
            throw new JspException( "AntTarget must be child of <ant>");
  
        AntTag antTag=(AntTag)parent;
        if( name == null ) {
            String names[]=pageContext.getRequest().
                getParameterValues( param );
            for( int i=0; i<names.length; i++ ) 
                antTag.addTarget( names[i]);
        } else {
            antTag.addTarget( name );
        }
        return SKIP_BODY;
      }
  
      //-------------------- Properties --------------------
      String name;
      String param;
  
      public void setName( String s ) {
        name=s;
      }
      public void setParam( String s ) {
        param=s;
      }
  }
  
  
  
  1.1                  jakarta-tomcat/src/admin/WEB-INF/scripts/run-test.sh
  
  Index: run-test.sh
  ===================================================================
  #!/bin/sh
  #
  
  # Shell script to run the tomcat sanity test suite 
   
  if [ "$TOMCAT_HOME" = "" ] ; then
      echo You need to set TOMCAT_HOME
      exit
  fi
  
  cp=$CLASSPATH
  
  CLASSPATH=${TOMCAT_HOME}/lib/tomcat_util.jar:$CLASSPATH
  CLASSPATH=${TOMCAT_HOME}/lib/parser.jar:$CLASSPATH
  CLASSPATH=${TOMCAT_HOME}/lib/jaxp.jar:$CLASSPATH
  CLASSPATH=${TOMCAT_HOME}/webapps/admin/WEB-INF/lib/ant.jar:$CLASSPATH
  CLASSPATH=${TOMCAT_HOME}/webapps/admin/WEB-INF/classes:$CLASSPATH
  
  if [ "$cp" != "" ] ; then
      CLASSPATH=${CLASSPATH}:${cp}
  fi
  
  export CLASSPATH
  
  echo Using classpath: ${CLASSPATH}
  echo
  
  ant -Dgdir=${TOMCAT_HOME}/webapps/test/Golden -f 
${TOMCAT_HOME}/webapps/test/WEB-INF/test-tomcat.xml client $*
  
  exit 0
  
  
  
  1.9       +27 -33    jakarta-tomcat/src/admin/test/test.jsp
  
  Index: test.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/test/test.jsp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- test.jsp  2001/01/28 21:46:00     1.8
  +++ test.jsp  2001/01/29 06:46:19     1.9
  @@ -4,37 +4,13 @@
   
   <%@ taglib uri="http://jakarta.apache.org/taglibs/tomcat_admin-1.0" 
              prefix="adm" %>
  +<%@ taglib uri="http://jakarta.apache.org/taglibs/ant-1.0" 
  +           prefix="ant" %>
   
   This page will show the result of executing the sanity test suite. 
   You can see the context log <a href="/test/context_log.txt">here</a>
   
  -<form method="GET" action="test.jsp" >
  -Target:
  -<select name="target" > 
  -  <option>new-style</option>
  -  <option>file-tomcat</option>
  -  <option>dispatch-tomcat</option>
  -  <option>get-tomcat</option>
  -  <option>requestMap</option>
  -  <option>post</option>
  -  <option>jsp-tomcat</option>
  -  <option>wrong_request</option>
  -  <option>unavailable</option>
  -  <option>restricted</option>
  -  <option selected>client</option>
  -</select>
  -<br>
  -
  -Debug: <input type="checkbox" name="debug" value="10"><br>
  -Port: <input type="input" name="port" value="<%= request.getServerPort() %>">
  -<br>
  -Host: <input type="input" name="host" value="<%= request.getServerName() %>">
  -<br>
  -Expected protocol: <input type="input" name="server.proto" 
  -                       value="<%= request.getProtocol() %>">
  - ( use when testing Apache - tomcat3.x returns HTTP/1.0 ) <br>
  -<input type="submit">
  -</form>
  +<%@ include file="sanity-form.jsp" %>
   
   <% // This is an ugly hack to make the logs easily accessible.
      // Keep in mind this is just a way to jump-start testing, not a 
  @@ -48,19 +24,37 @@
   <adm:admin ctxPath="/test" 
           action="setLogger" 
           value="webapps/test/context_log.txt" />
  +
   <!-- trozo 1 -->
  -<adm:gtest testFile="WEB-INF/test-tomcat.xml" 
  -        testApp="/test" 
  -        target='<%= request.getParameter("target") %>' 
  -           debug='<%= request.getParameter("debug") %>' 
  -           outputType='none' />
  +<ant:gtest />
  +
  +<ant:ant testFile="WEB-INF/test-tomcat.xml" 
  +      testApp="/test" >
  +  <ant:target param="target" />
  +  
  +  <ant:property name="ant.file" 
  +             location="/WEB-INF/test-tomcat.xml" 
  +             webApp="/test" />
  +  <ant:property name="gdir" 
  +             location="/Golden" 
  +             webApp="/test" />
  +  <ant:property name="wgdir" 
  +             location="/Golden" 
  +             webApp="/test" />
  +  <ant:property name="debug"  param="debug" />
  +  <ant:property name="outputType" value="none"  />
  +  <ant:property name="port" param="port" />
  +  <ant:property name="http.protocol" param="server.proto" />
  +  <ant:property name="host" param="host" />
  +</ant:ant>
  +
   <!-- trozo 1 -->
   <% // Test completed, display the results ( outType=none means
      // Gtest doesn't generate any output ( but we have to wait untill
      // it's done ), use 'html' for "interactive" results
   %>
   
  -<h1>Test <%= gtestTestRevision %></h1>
  +<h1>Test <%= antProperties.getProperty("revision") %></h1>
   
   <% // -------------------- Failures -------------------- %>
   <h1>FAILED Tests</h1>
  
  
  
  1.1                  jakarta-tomcat/src/admin/test/sanity-form.jsp
  
  Index: sanity-form.jsp
  ===================================================================
  <form method="GET" action="test.jsp" >
  Target:
  <select name="target" > 
    <option>file</option>
    <option>dispatch</option>
    <option>get</option>
    <option>requestMap</option>
    <option>post</option>
    <option>wrong_request</option>
    <option>unavailable</option>
    <option>restricted</option>
    <option>jsp</option>
    <option>special</option>
    <option>tomcat-standalone</option>
    <option>tomcat-apache</option>
    <option selected>client</option>
  </select>
  <br>
  
  Debug: <input type="checkbox" name="debug" value="10"><br>
  Port: <input type="input" name="port" value="<%= request.getServerPort() %>">
  <br>
  Host: <input type="input" name="host" value="<%= request.getServerName() %>">
  <br>
  Expected protocol: <input type="input" name="server.proto" 
                          value="<%= request.getProtocol() %>">
   ( use when testing Apache - tomcat3.x returns HTTP/1.0 ) <br>
  <input type="submit">
  </form>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to