tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/tests/share/gtest GTest.java
Date Sat, 20 Jan 2001 21:50:24 GMT
costin      01/01/20 13:50:24

  Modified:    .        build.xml
               src/admin/WEB-INF admin.tld
               src/admin/WEB-INF/classes/tadm GTestTag.java
                        TomcatAdmin.java
               src/tests/share/gtest GTest.java
  Added:       src/admin/test test.jsp
  Log:
  The web-based test runner started to work on my machine ( using the
  old GTest, the new one is still not tested ).
  
  Changes:
  - add the old GTest to the /admin ( using build.xml )
  - removed unused lines, cleaned a bit build.xml
  - enhance the adm:admin taglib - it can now change the logger of a Context
  ( it probably need a form and a page for general use, I need it for
  the test app )
  - enhance the adm:gtest taglib - set the default writer of GTest to
  the servlet output writer ( ant messages are handled by AntServletLogger ),
  also show root cause and set html style output.
  - added the simple test.jsp page, to get things running
  
  Revision  Changes    Path
  1.104     +31 -23    jakarta-tomcat/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/build.xml,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- build.xml	2001/01/20 03:43:07	1.103
  +++ build.xml	2001/01/20 21:50:22	1.104
  @@ -296,39 +296,47 @@
       <!-- Examples -->
       <mkdir dir="${tomcat.build}/webapps/examples"/>
       <copy todir="${tomcat.build}/webapps/examples">
  -            <fileset dir="src/examples"/>
  -        </copy>
  +      <fileset dir="src/examples"/>
  +    </copy>
       <javac srcdir="src/examples/WEB-INF/classes" 
  -        optimize="${optimize}" destdir="${tomcat.build}/webapps/examples/WEB-INF/classes"

  -        classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  -    <javac srcdir="src/examples/jsp/plugin/applet" optimize="${optimize}" destdir="${tomcat.build}/webapps/examples/jsp/plugin/applet"/>
  +	   optimize="${optimize}" 
  +	   destdir="${tomcat.build}/webapps/examples/WEB-INF/classes" 
  +	   classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  +    <javac srcdir="src/examples/jsp/plugin/applet" 
  +	   optimize="${optimize}" 
  +	   destdir="${tomcat.build}/webapps/examples/jsp/plugin/applet"/>
   
   
  -    <!-- Tomcat profiling webapp - not ready for check in yet
  -    <mkdir dir="${tomcat.build}/webapps/prof"/>
  -    <copydir src="src/prof" dest="${tomcat.build}/webapps/prof"/>
  -    <javac srcdir="src/prof/WEB-INF/src"
  -      optimize="${optimize}"
  -      destdir="${tomcat.build}/webapps/prof/WEB-INF/classes"
  -      classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  -     -->
         <!-- Root context -->
       <mkdir dir="${tomcat.build}/webapps/ROOT"/>
       <copy todir="${tomcat.build}/webapps/ROOT">
  -            <fileset dir="src/webpages"/>
  -        </copy>
  +      <fileset dir="src/webpages"/>
  +    </copy>
       <copy todir="${tomcat.build}/webapps/ROOT/doc">
  -            <fileset dir="src/doc"/>
  -        </copy>
  -    <javac srcdir="src/webpages/WEB-INF/classes" optimize="${optimize}" destdir="${tomcat.build}/webapps/ROOT/WEB-INF/classes"
classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  -
  +      <fileset dir="src/doc"/>
  +    </copy>
  +    <javac srcdir="src/webpages/WEB-INF/classes" 
  +	   optimize="${optimize}" 
  +	   destdir="${tomcat.build}/webapps/ROOT/WEB-INF/classes" 
  +	   classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  +      
         <!-- admin context -->
       <mkdir dir="${tomcat.build}/webapps/admin"/>
       <copy todir="${tomcat.build}/webapps/admin">
  -            <fileset dir="src/admin"/>
  -        </copy>
  -    <javac srcdir="src/admin/WEB-INF/classes" optimize="${optimize}" destdir="${tomcat.build}/webapps/admin/WEB-INF/classes"
classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  -
  +      <fileset dir="src/admin"/>
  +    </copy>
  +    <copy tofile="${tomcat.build}/webapps/admin/WEB-INF/lib/ant.jar" 
  +	  file="${ant.home}/lib/ant.jar"/>
  +    <!-- temp - the old GTest -->
  +    <javac srcdir="src/tests/share/gtest" 
  +	   optimize="${optimize}" 
  +	   destdir="${tomcat.build}/webapps/admin/WEB-INF/classes" 
  +	   classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  +    <javac srcdir="src/admin/WEB-INF/classes" 
  +	   optimize="${optimize}" 
  +	   destdir="${tomcat.build}/webapps/admin/WEB-INF/classes" 
  +	   classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  +      
     </target>
   
     <!-- ==================== Build the internal test app =================== -->
  
  
  
  1.4       +4 -0      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- admin.tld	2001/01/20 20:14:27	1.3
  +++ admin.tld	2001/01/20 21:50:23	1.4
  @@ -48,6 +48,10 @@
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
       </attribute>
  +    <attribute>
  +       <name>value</name>
  +       <required>false</required>
  +    </attribute>
     </tag>
     
     <tag>
  
  
  
  1.2       +20 -3     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GTestTag.java	2001/01/20 20:14:28	1.1
  +++ GTestTag.java	2001/01/20 21:50:23	1.2
  @@ -10,6 +10,7 @@
   import javax.servlet.jsp.tagext.*;
   
   import org.apache.tools.ant.*;
  +import org.apache.tomcat.util.test.*;
   
   /**
    * This tag will run a GTest-based test suite.
  @@ -85,14 +86,25 @@
       
       // -------------------- Implementation methods --------------------
       
  -    private void runTest( String base) {
  +    private void runTest( String base) throws IOException {
  +	PrintWriter out=pageContext.getResponse().getWriter();
   	try {
  +	    System.out.println("RUN TEST " + base + " " + testFileName + " "
  +			       + target );
   	    File testFile=new File( base + testFileName);
  +
  +
  +	    // old task
  +	    org.apache.tomcat.task.GTest.setDefaultWriter( out );
  +	    org.apache.tomcat.task.GTest.setHtmlMode( true );
  +	    // new one
  +	    GTest.setDefaultWriter(out);
  +	    GTest.setDefaultOutput("html");
   	    
   	    Project project=new Project();
   	    
   	    AntServletLogger log=new AntServletLogger();
  -	    log.setWriter( pageContext.getResponse().getWriter());
  +	    log.setWriter( out );
   	    project.addBuildListener( log );
   	    
   	    project.init();
  @@ -109,7 +121,12 @@
   	    project.executeTargets( targets );
   	    
   	} catch( Exception ex ) {
  -	    ex.printStackTrace();
  +	    ex.printStackTrace(out);
  +	    if( ex instanceof BuildException ) {
  +		Throwable ex1=((BuildException)ex).getException();
  +		System.out.println("Root cause: " );
  +		ex1.printStackTrace(out);
  +	    }
   	}
       }
   }
  
  
  
  1.7       +26 -1     jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatAdmin.java
  
  Index: TomcatAdmin.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/classes/tadm/TomcatAdmin.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TomcatAdmin.java	2000/12/31 15:39:15	1.6
  +++ TomcatAdmin.java	2001/01/20 21:50:23	1.7
  @@ -1,13 +1,14 @@
   package tadm;
   import java.util.Vector;
   import java.util.Enumeration;
  -import java.io.File;
  +import java.io.*;
   import java.net.URL;
   import javax.servlet.http.*;
   
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
   import org.apache.tomcat.core.*;
  +import org.apache.tomcat.util.log.*;
   
   /**
    * A context administration class. Contexts can be
  @@ -22,6 +23,7 @@
       String docBaseParam;
       String action;
       String host;
  +    String value;
       PageContext pageContext;
       
       public TomcatAdmin() {}
  @@ -54,6 +56,8 @@
   	    }
   	    if("removeContext".equals( action ) )
   		removeContext( cm , ctx);
  +	    if("setLogger".equals( action ) )
  +		setLogFile(  ctx, value );
   	    if("addContext".equals( action ) )
   		addContext( cm, host, ctxPath, docBase );
   	} catch (Exception ex ) {
  @@ -112,11 +116,32 @@
   	this.docBase=docBase;
       }
   
  +    public void setValue( String s ) {
  +	this.value=s;
  +    }
  +    
       private void removeContext( ContextManager cm, Context ctx)
   	throws TomcatException
       {
   	System.out.println("Removing " + ctx );
   	cm.removeContext( ctx );
  +    }
  +
  +    private void setLogFile( Context ctx, String dest )
  +	throws TomcatException
  +    {
  +	try {
  +	    QueueLogger logger=new QueueLogger();
  +	    System.out.println("Setting logger " + dest );
  +	    logger.setName( "temp.log");
  +	    logger.setPath( dest );
  +	    logger.open();
  +	    //	Logger.putLogger( logger );
  +	    ctx.setLogger( logger );
  +	    ctx.setServletLogger( logger );
  +	} catch( Exception ex ) {
  +	    ex.printStackTrace();
  +	}
       }
   
       private void addContext( ContextManager cm, String host, String path,
  
  
  
  1.1                  jakarta-tomcat/src/admin/test/test.jsp
  
  Index: test.jsp
  ===================================================================
  <h1>Tomcat Self-test</h1> 
  
  <%@ taglib uri="http://jakarta.apache.org/taglibs/tomcat_admin-1.0" 
             prefix="adm" %>
  
  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>
  
  <% // 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 
     // production-quality test runner.
  %>
  
  <adm:admin ctxPath="/test" 
  	   action="setLogger" 
  	   value="webapps/test/context_log.txt" />
  
  <adm:gtest testFile="WEB-INF/test-tomcat.xml" 
  	   testApp="/test" 
  	   target="file" />
  
  
  
  </pre>
  
  
  1.3       +26 -5     jakarta-tomcat/src/tests/share/gtest/GTest.java
  
  Index: GTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/tests/share/gtest/GTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GTest.java	2001/01/20 20:11:03	1.2
  +++ GTest.java	2001/01/20 21:50:24	1.3
  @@ -56,26 +56,29 @@
    * [Additional notices, if required by prior licensing conditions]
    *
    */ 
  -package org.apache.tomcat.util.task;
  +package org.apache.tomcat.task;
   
   import java.net.*;
   import java.io.*;
   import java.util.*;
   import java.net.*;
  -import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.BuildException;
   
   
   /** Test a web application. Will send a http request and
       verify the response code, compare the response with a golden
       file or find strings.
   */
  -public class GTest extends Task {
  +public class GTest {
       String prefix="http://localhost:8080/test";
       String host="localhost";
       int port=8080;
       int debug=0;
   
  +    static PrintWriter defaultWriter=new PrintWriter(System.out);
  +    static boolean htmlMode=false;
  +
  +    PrintWriter out=defaultWriter;
  +    
       String description="No description";
   
       String request;
  @@ -193,8 +196,26 @@
       }
   
       // -------------------- Execute the request --------------------
  +    public static void setDefaultWriter( PrintWriter pw ) {
  +	defaultWriter=pw;
  +    }
   
  -    public void execute() throws BuildException {
  +    public static void setHtmlMode( boolean h ) {
  +	htmlMode=h;
  +    }
  +    
  +    public void log( String s ) {
  +	if( htmlMode) {
  +	    out.println(s);
  +	    out.println("<br>");
  +	}  else {
  +	    out.println( s );
  +	}
  +	
  +	
  +    }
  +    
  +    public void execute() {
   	
   	try {
   	    dispatch(request, null);
  
  
  

Mime
View raw message