You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/01/20 22:44:40 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/test GTest.java

costin      01/01/20 13:44:40

  Modified:    src/share/org/apache/tomcat/util IntrospectionUtils.java
               src/share/org/apache/tomcat/util/http AcceptLanguage.java
                        ContentType.java
               src/share/org/apache/tomcat/util/log Logger.java
               src/share/org/apache/tomcat/util/test GTest.java
  Log:
  Trying to get my CVS in sync.
  
  Changes to IntrospectionUtil to better process the classpath, removed
  dead code, small optimization in ContentType ( one less String !).
  
  In the new GTest: allow to set a default outType ( it'll generate reports
  in text, xml, html ).
  
  Revision  Changes    Path
  1.4       +20 -1     jakarta-tomcat/src/share/org/apache/tomcat/util/IntrospectionUtils.java
  
  Index: IntrospectionUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/IntrospectionUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IntrospectionUtils.java	2000/12/28 23:19:56	1.3
  +++ IntrospectionUtils.java	2001/01/20 21:44:39	1.4
  @@ -135,12 +135,17 @@
       }
   
   
  +    public static String guessHome(String systemProperty, String jarName) {
  +	return guessHome( systemProperty, jarName, null);
  +    }
  +    
       /** Guess a product home by analyzing the class path.
        *  It works for product using the pattern: lib/executable.jar
        *  or if executable.jar is included in classpath by a shell
        *  script. ( java -jar also works )
        */
  -    public static String guessHome(String systemProperty, String jarName) {
  +    public static String guessHome(String systemProperty, String jarName,
  +				   String classFile) {
   	String h=null;
   	
   	if( systemProperty != null )
  @@ -167,6 +172,20 @@
   		    return h;
   		} catch( Exception ex ) {
   		    ex.printStackTrace();
  +		}
  +	    } else  {
  +		String fname=path + ( path.endsWith("/") ?"":"/" ) + classFile;
  +		if( new File( fname ).exists()) {
  +		    try {
  +			File f=new File( path );
  +			File f1=new File ( h, "..");
  +			h = f1.getCanonicalPath();
  +			if( systemProperty != null )
  +			    System.getProperties().put( systemProperty, h );
  +			return h;
  +		    } catch( Exception ex ) {
  +			ex.printStackTrace();
  +		    }
   		}
   	    }
   	}
  
  
  
  1.2       +1 -3      jakarta-tomcat/src/share/org/apache/tomcat/util/http/AcceptLanguage.java
  
  Index: AcceptLanguage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/AcceptLanguage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AcceptLanguage.java	2000/12/30 07:54:17	1.1
  +++ AcceptLanguage.java	2001/01/20 21:44:39	1.2
  @@ -76,9 +76,7 @@
    * @author costin@eng.sun.com
    */
   public class AcceptLanguage {
  -    protected static StringManager sm =
  -        StringManager.getManager("org.apache.tomcat.resources");
  -    
  +
       public static Locale getLocale(String acceptLanguage) {
   	if( acceptLanguage == null ) return Locale.getDefault();
   
  
  
  
  1.2       +2 -6      jakarta-tomcat/src/share/org/apache/tomcat/util/http/ContentType.java
  
  Index: ContentType.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/ContentType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContentType.java	2000/12/30 07:54:18	1.1
  +++ ContentType.java	2001/01/20 21:44:39	1.2
  @@ -76,9 +76,6 @@
    * @author costin@eng.sun.com
    */
   public class ContentType {
  -    protected static StringManager sm =
  -        StringManager.getManager("org.apache.tomcat.resources");
  -	
   
       // Basically return everything after ";charset="
       // If no charset specified, use the HTTP default (ASCII) character set.
  @@ -90,12 +87,11 @@
           if (semi == -1) {
               return null;
           }
  -        String afterSemi = type.substring(semi + 1);
  -        int charsetLocation = afterSemi.indexOf("charset=");
  +        int charsetLocation = type.indexOf("charset=", semi);
           if (charsetLocation == -1) {
               return null;
           }
  -        String afterCharset = afterSemi.substring(charsetLocation + 8);
  +        String afterCharset = type.substring(charsetLocation + 8);
           String encoding = afterCharset.trim();
           return encoding;
       }
  
  
  
  1.3       +1 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/log/Logger.java
  
  Index: Logger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/log/Logger.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Logger.java	2000/12/08 23:18:59	1.2
  +++ Logger.java	2001/01/20 21:44:39	1.3
  @@ -219,6 +219,7 @@
       private static Object emptyObjectArray[]=new Object[0];
   
       private static void printThrowable(PrintWriter w, Throwable t, String rootcause, int depth ) {
  +
   	if (t != null) {
   	    // XXX XXX XXX Something seems wrong - DOS, permissions. Need to
   	    // check.
  
  
  
  1.2       +7 -1      jakarta-tomcat/src/share/org/apache/tomcat/util/test/GTest.java
  
  Index: GTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/GTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GTest.java	2001/01/20 19:42:09	1.1
  +++ GTest.java	2001/01/20 21:44:39	1.2
  @@ -79,8 +79,10 @@
       String description="No description";
   
       static PrintWriter defaultOutput=new PrintWriter(System.out);
  +    static String defaultOutType="text";
  +    
       PrintWriter out=defaultOutput;
  -    String outType="text";
  +    String outType=defaultOutType;
       boolean failureOnly=false;
       
       public GTest() {
  @@ -94,6 +96,10 @@
   
       public static void setDefaultWriter( PrintWriter pw ) {
   	defaultOutput=pw;
  +    }
  +
  +    public static void setDefaultOutput( String s ) {
  +	defaultOutType=s;
       }
   
       /** text, xml, html