tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/tests build.xml
Date Fri, 29 Dec 2000 00:20:29 GMT
costin      00/12/28 16:20:29

  Modified:    .        build.xml
               src/share/org/apache/tomcat/context AutoSetup.java
               src/share/org/apache/tomcat/modules/config
                        WebAppsConfig.java
               src/share/org/apache/tomcat/startup Main.java Tomcat.java
               src/share/org/apache/tomcat/util FileUtil.java
  Added:       src/share/org/apache/tomcat/startup StopTomcat.java
               src/tests build.xml
  Removed:     src/share/org/apache/tomcat/task Expand.java GTest.java
                        StartTomcat.java StopTomcat.java
  Log:
  - expand was used in 2 places - moved the shared code to FileUtil
  
  - removed unused code
  
  - moved code specific to the sanity-test application to tests.
  Same for build.xml.
  
  - moved StopTomcat in startup pagkage. It should be replaced with a more
  secure system ( independent of ajp12 ) before a release.
  
  Revision  Changes    Path
  1.100     +7 -22     jakarta-tomcat/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/build.xml,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- build.xml	2000/12/28 23:19:44	1.99
  +++ build.xml	2000/12/29 00:20:20	1.100
  @@ -25,7 +25,6 @@
     <!-- External packages we depend on -->
   
     <property name="ant.home" value="../jakarta-ant"/>
  -  <property name="j2ee.home" value="../j2ee/build/unix"/>
     <property name="jaxp" value="../jaxp-1.0.1"/>
   
     <property name="servlet22.jar" value="bin/servlet22.jar"/>
  @@ -74,6 +73,10 @@
               <fileset dir="${ant.home}/bin"/>
           </copy>
       <copy tofile="${tomcat.build}/lib/ant.jar" file="${ant.home}/lib/ant.jar"/>
  +    <copy tofile="${tomcat.build}/lib/jaxp.jar" 
  +	  file="${ant.home}/lib/jaxp.jar"/>
  +    <copy tofile="${tomcat.build}/lib/parser.jar" 
  +	  file="${ant.home}/lib/parser.jar"/>
       <copy tofile="${tomcat.build}/lib/jaxp.jar" file="${jaxp}/jaxp.jar"/>
       <copy tofile="${tomcat.build}/lib/parser.jar" file="${jaxp}/parser.jar"/>
       
  @@ -284,28 +287,10 @@
   
     </target>
   
  -  <!-- ==================== Build the internal test app ==================== -->
  -  <target name="sanity-test">
  -    <mkdir dir="${tomcat.dist}/lib/test"/>
  -    <mkdir dir="${tomcat.dist}/lib/test/Golden"/>
  -    <copy todir="${tomcat.dist}/lib/test/Golden">
  -            <fileset dir="src/tests/share/tests/jsp/Golden"/>
  -        </copy>
  -
  -      <!-- Test application -->
  -    <mkdir dir="${tomcat.build}/webapps/test"/>
  -    <copy todir="${tomcat.build}/webapps/test">
  -            <fileset dir="src/tests/webpages"/>
  -        </copy>
  -    <javac srcdir="src/tests/webpages/WEB-INF/classes" optimize="${optimize}" destdir="${tomcat.build}/webapps/test/WEB-INF/classes"
classpath="${tomcat.build}/classes;${servlet22.jar}"/>
  -    <copy todir="${tomcat.dist}/webapps/test">
  -            <fileset dir="${tomcat.build}/webapps/test"/>
  -        </copy>
  -
  -    <jar jarfile="${tomcat.dist}/webapps/test.war" basedir="${tomcat.dist}/webapps/test"
includes="**"/> 
  -    <delete dir="${tomcat.dist}/webapps/test"/>
  +  <!-- ==================== Build the internal test app =================== -->
   
  -
  +  <target name="sanity-test">
  +    <ant antfile="src/tests/build.xml" target="sanity-test"/>
     </target>
   
     <!-- ==================== Copy the files to distribution format ======== -->
  
  
  
  1.22      +1 -42     jakarta-tomcat/src/share/org/apache/tomcat/context/AutoSetup.java
  
  Index: AutoSetup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/AutoSetup.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AutoSetup.java	2000/12/28 23:19:47	1.21
  +++ AutoSetup.java	2000/12/29 00:20:20	1.22
  @@ -66,8 +66,6 @@
   import java.net.*;
   import java.util.*;
   
  -import org.apache.tomcat.task.Expand;
  -
   /**
    *  Prepare a context manager - expand wars in webapps and
    *  automaticly install contexts
  @@ -122,7 +120,7 @@
   		    appDir.mkdirs();
   		    // Expand war file
   		    try {
  -			expand(home + "/webapps/" + name,
  +			FileUtil.expand(home + "/webapps/" + name,
   			       home + "/webapps/" + fname);
   		    } catch( IOException ex) {
   			log("expanding webapp " + name, ex);
  @@ -171,43 +169,4 @@
               }
   	}
       }
  -
  -    private void expand( String src, String dest)
  -	throws IOException
  -    {
  -	File srcF=new File( source);
  -	File dir=new File( dest );
  -	
  -	ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF));
  -	ZipEntry ze = null;
  -	
  -	while ((ze = zis.getNextEntry()) != null) {
  -	    try {
  -		File f = new File(dir, ze.getName());
  -		// create intermediary directories - sometimes zip don't add them
  -		File dirF=new File(f.getParent());
  -		dirF.mkdirs();
  -		
  -		if (ze.isDirectory()) {
  -		    f.mkdirs(); 
  -		} else {
  -		    byte[] buffer = new byte[1024];
  -		    int length = 0;
  -		    FileOutputStream fos = new FileOutputStream(f);
  -		    
  -		    while ((length = zis.read(buffer)) >= 0) {
  -			fos.write(buffer, 0, length);
  -		    }
  -		    
  -		    fos.close();
  -		}
  -	    } catch( FileNotFoundException ex ) {
  -		//loghelper.log("FileNotFoundException: " +
  -		//   ze.getName(), Logger.ERROR );
  -		throw ex;
  -	    }
  -	}
  -
  -    }
  -
   }
  
  
  
  1.2       +2 -5      jakarta-tomcat/src/share/org/apache/tomcat/modules/config/WebAppsConfig.java
  
  Index: WebAppsConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/WebAppsConfig.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebAppsConfig.java	2000/12/04 21:18:44	1.1
  +++ WebAppsConfig.java	2000/12/29 00:20:21	1.2
  @@ -67,7 +67,6 @@
   
   import org.apache.tomcat.util.xml.*;
   import org.apache.tomcat.helper.*;
  -import org.apache.tomcat.task.Expand;
   
   /**
    *
  @@ -280,11 +279,9 @@
   	    // To update you need to "remove" the context first!!!
   	    appDir.mkdirs();
   	    // Expand war file
  -	    Expand expand=new Expand();
  -	    expand.setSrc( dir.getAbsolutePath() + name );
  -	    expand.setDest( dir.getAbsolutePath() + fname);
   	    try {
  -		expand.execute();
  +		FileUtil.expand(dir.getAbsolutePath() + name,
  +				dir.getAbsolutePath() + fname );
   	    } catch( IOException ex) {
   		log("expanding webapp " + name, ex);
   		// do what ?
  
  
  
  1.17      +2 -2      jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Main.java	2000/12/28 23:19:50	1.16
  +++ Main.java	2000/12/29 00:20:21	1.17
  @@ -202,8 +202,8 @@
   	    Object proxy=cls.newInstance();
   	    
   	    processArgs( proxy, args );
  -	    IntrospectionUtils.setAttribute( proxy,
  -					     "parentClassLoader", parentL );
  +	    // 	    IntrospectionUtils.setAttribute( proxy,
  +	    // 		     "parentClassLoader", parentL );
   	    //	    setAttribute( proxy, "serverClassPath", urls );
   	    IntrospectionUtils.execute(  proxy, "execute" );
   	    return;
  
  
  
  1.47      +2 -2      jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java
  
  Index: Tomcat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- Tomcat.java	2000/12/28 23:19:51	1.46
  +++ Tomcat.java	2000/12/29 00:20:23	1.47
  @@ -51,8 +51,8 @@
       public void stop() throws Exception {
   	System.out.println(sm.getString("tomcat.stop"));
   	try {
  -	    org.apache.tomcat.task.StopTomcat task=
  -		new  org.apache.tomcat.task.StopTomcat();
  +	    StopTomcat task=
  +		new  StopTomcat();
   	    
   	    task.setConfig( configFile );
   	    task.execute();     
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java
  
  Index: StopTomcat.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  package org.apache.tomcat.startup;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.*;
  import org.apache.tomcat.helper.*;
  import org.apache.tomcat.util.xml.*;
  import org.apache.tomcat.util.log.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  
  // Used to stop tomcat
  //import org.apache.tomcat.service.PoolTcpConnector;
  //import org.apache.tomcat.service.connector.Ajp12ConnectionHandler;
  import org.apache.tomcat.modules.server.Ajp12Interceptor;
  
  /**
   * This task will stop tomcat
   *
   * @author Costin Manolache
   */
  public class StopTomcat { 
      static final String DEFAULT_CONFIG="conf/server.xml";
      private static StringManager sm =
  	StringManager.getManager("org.apache.tomcat.resources");
  
      String configFile;
      String tomcatHome;
      Log loghelper = new Log("tc_log", "StopTomcat");
      
      public StopTomcat() 
      {
      }
  
      // -------------------- Parameters --------------------
  
      public void setConfig( String s ) {
  	configFile=s;
      }
  
      /** -f option
       */
      public void setF( String s ) {
  	configFile=s;
      }
  
      public void setH( String s ) {
  	tomcatHome=s;
  	System.getProperties().put("tomcat.home", s);
      }
  
      public void setHome( String s ) {
  	tomcatHome=s;
  	System.getProperties().put("tomcat.home", s);
      }
  
      // -------------------- Ant execute --------------------
      public void execute() throws Exception {
  	System.out.println(sm.getString("tomcat.stop"));
  	try {
  	    stopTomcat(); // stop serving
  	}
  	catch (TomcatException te) {
  	    if (te.getRootCause() instanceof java.net.ConnectException)
  		System.out.println(sm.getString("tomcat.connectexception"));
  	    else
  		throw te;
  	}
  	return;
      }
  
      // -------------------- Implementation --------------------
      
      /** Stop tomcat using the configured cm
       *  The manager is set up using the same configuration file, so
       *  it will have the same port as the original instance ( no need
       *  for a "log" file).
       *  It uses the Ajp12 connector, which has a built-in "stop" method,
       *  that will change when we add real callbacks ( it's equivalent
       *  with the previous RMI method from almost all points of view )
       */
      void stopTomcat() throws TomcatException {
  	XmlMapper xh=new XmlMapper();
  	xh.setDebug( 0 );
  	ContextManager cm=new ContextManager();
  	
  	ServerXmlHelper sxml=new ServerXmlHelper();
  
  	sxml.setConnectorHelper( xh );
  	String tchome=sxml.getTomcatInstall();
  	// load server.xml
  	File f = null;
  	if (configFile != null)
  	    f=new File(configFile);
  	else
  	    f=new File(tchome, DEFAULT_CONFIG);
  	cm.setInstallDir( tchome);
  
  	try {
  	    xh.readXml(f,cm);
  	} catch( Exception ex ) {
  	    throw new TomcatException("Fatal exception reading " + f, ex);
  	}
  	
  	execute( cm );     
      }
      
      
      /** This particular implementation will search for an AJP12
  	connector ( that have a special stop command ).
      */
      public void execute(ContextManager cm)
  	throws TomcatException 
      {
  	// Find Ajp12 connector
  	int portInt=8007;
  	InetAddress address=null;
  	BaseInterceptor ci[]=cm.getContainer().getInterceptors();
  	for( int i=0; i<ci.length; i++ ) {
  	    Object con=ci[i];
  	    if( con instanceof  Ajp12Interceptor ) {
  		Ajp12Interceptor tcpCon=(Ajp12Interceptor) con;
  		portInt=tcpCon.getPort();
  		address=tcpCon.getAddress();
  	    }
  	}
  
  	// use Ajp12 to stop the server...
  	try {
  	    if (address == null)
  		address = InetAddress.getLocalHost();
  	    Socket socket = new Socket(address, portInt);
  	    OutputStream os=socket.getOutputStream();
  	    byte stopMessage[]=new byte[2];
  	    stopMessage[0]=(byte)254;
  	    stopMessage[1]=(byte)15;
  	    os.write( stopMessage );
  	    socket.close();
  	} catch(Exception ex ) {
  	    throw new TomcatException("Error stopping Tomcat with Ajp12 on " +
  				      address + ":" + portInt, ex);
  	}
      }
      
  }
  
  
  
  1.17      +42 -5     jakarta-tomcat/src/share/org/apache/tomcat/util/FileUtil.java
  
  Index: FileUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/FileUtil.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FileUtil.java	2000/12/08 23:18:53	1.16
  +++ FileUtil.java	2000/12/29 00:20:27	1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/FileUtil.java,v 1.16
2000/12/08 23:18:53 costin Exp $
  - * $Revision: 1.16 $
  - * $Date: 2000/12/08 23:18:53 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/FileUtil.java,v 1.17
2000/12/29 00:20:27 costin Exp $
  + * $Revision: 1.17 $
  + * $Date: 2000/12/29 00:20:27 $
    *
    * ====================================================================
    *
  @@ -64,8 +64,8 @@
   
   package org.apache.tomcat.util;
   
  -import java.io.File;
  -import java.io.IOException;
  +import java.io.*;
  +import java.util.zip.*;
   
   import org.apache.tomcat.util.log.*;
   
  @@ -346,6 +346,43 @@
   	    return null;
       }
   
  +    public static void expand( String src, String dest)
  +	throws IOException
  +    {
  +	File srcF=new File( src);
  +	File dir=new File( dest );
  +	
  +	ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF));
  +	ZipEntry ze = null;
  +	
  +	while ((ze = zis.getNextEntry()) != null) {
  +	    try {
  +		File f = new File(dir, ze.getName());
  +		// create intermediary directories - sometimes zip don't add them
  +		File dirF=new File(f.getParent());
  +		dirF.mkdirs();
  +		
  +		if (ze.isDirectory()) {
  +		    f.mkdirs(); 
  +		} else {
  +		    byte[] buffer = new byte[1024];
  +		    int length = 0;
  +		    FileOutputStream fos = new FileOutputStream(f);
  +		    
  +		    while ((length = zis.read(buffer)) >= 0) {
  +			fos.write(buffer, 0, length);
  +		    }
  +		    
  +		    fos.close();
  +		}
  +	    } catch( FileNotFoundException ex ) {
  +		//loghelper.log("FileNotFoundException: " +
  +		//   ze.getName(), Logger.ERROR );
  +		throw ex;
  +	    }
  +	}
  +
  +    }
   
   
   }
  
  
  
  1.1                  jakarta-tomcat/src/tests/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?> 
  
  <!-- Emacs indentation & editting support
      <antstructure output="ant.dtd"/>
  <!DOCTYPE ant SYSTEM "ant.dtd" >
  -->
  
  <project name="Tomcat-test" default="main" basedir=".">
  
    <!-- Compilation properties -->
  
    <property name="build.compiler" value="classic"/>
    <property name="optimize" value="false" />
    <property name="debug" value="off" />
  
    <!-- Directories -->
  
    <property name="tomcat.home" value="../../../build/tomcat"/>
  
  
    <!-- External packages we depend on -->
  
    <property name="ant.home" value="../jakarta-ant" />
    <property name="jaxp" value="../jaxp1.0.1" />
  
    <!-- set it if not specified as -D or in parent antfile -->
    <property name="servlet.jar" value="${tomcat.home}/lib/servlet.jar" />
  
    <!-- ==================== Initialization - guessing config ========== -->
    <target name="init">
    </target>
  
    <!-- ==================== Copy static files ==================== -->
  
    <target name="prepare" depends="init">
    </target>
  
    <!-- ==================== Build the internal test app ================== -->
    <target name="sanity-test" >
      <mkdir dir="${tomcat.dist}/lib/test"/>
      <mkdir dir="${tomcat.dist}/lib/test/Golden"/>
      <copy todir="${tomcat.dist}/lib/test/Golden">
              <fileset dir="src/tests/share/tests/jsp/Golden"/>
      </copy>
  
        <!-- Test application -->
      <mkdir dir="${tomcat.build}/webapps/test"/>
      <copy 
  	  todir="${tomcat.build}/webapps/test">
              <fileset dir="src/tests/webpages"/>
      </copy>
      <javac 
  	   srcdir="src/tests/webpages/WEB-INF/classes" 
  	   optimize="${optimize}" 
  	   destdir="${tomcat.build}/webapps/test/WEB-INF/classes" 
  	   classpath="${tomcat.build}/classes;${servlet22.jar}" />
      <javac 
  	   srcdir="src/tests/share/gtest" 
  	   optimize="${optimize}" 
  	   destdir="${tomcat.build}/webapps/test/WEB-INF/classes" 
  	   classpath="${tomcat.build}/classes" />
      <copy 
  	  todir="${tomcat.dist}/webapps/test">
              <fileset dir="${tomcat.build}/webapps/test"/>
      </copy>
  
      <jar 
  	 jarfile="${tomcat.dist}/webapps/test.war" 
  	 basedir="${tomcat.dist}/webapps/test" includes="**"/> 
      <delete dir="${tomcat.dist}/webapps/test"/>
    </target>
  
    <!-- ==================== Admin & agreagate ==================== -->
     
    <target name="clean-classes" depends="init">
      <deltree dir="${tomcat.build}/classes/org"/>
    </target>
  
    <target name="clean" depends="init">
      <deltree dir="${tomcat.build}"/>
      <deltree dir="${tomcat.home}"/>
    </target>
    
    <target name="all" depends=""/>
    <target name="main" depends=""/>
      
  </project>
  
  
  

Mime
View raw message