You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by la...@apache.org on 2001/09/22 23:10:50 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers GoldenMatch.java HeaderMatch.java HttpStatusMatch.java ResponseMatch.java ResponseMatchFile.java SessionMatch.java

larryi      01/09/22 14:10:50

  Modified:    src/share/org/apache/tomcat/util/test GTest.java
                        HttpClient.java Matcher.java
               src/share/org/apache/tomcat/util/test/matchers
                        GoldenMatch.java HeaderMatch.java
                        HttpStatusMatch.java ResponseMatch.java
                        ResponseMatchFile.java SessionMatch.java
  Log:
  At "if" and "unless" handling to GTest and HttpClient as well as the
  matchers. This functionality requires use of Ant 1.4.
  
  Revision  Changes    Path
  1.14      +13 -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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- GTest.java	2001/09/22 02:45:45	1.13
  +++ GTest.java	2001/09/22 21:10:50	1.14
  @@ -85,6 +85,8 @@
       // Instance variables
   
       Project project=null;
  +    String ifProp=null;
  +    String unlessProp=null;
   
       // The "real" thing.
       // GTest is here to support the old ( and simpler ) syntax .
  @@ -163,12 +165,20 @@
   	HttpClient.getHttpClients().clear();
       }
       
  -    // ----------------- Ant Properie -----------------
  +    // ----------------- Ant Properties -----------------
   
       public void setProject(Project p ) {
           project=p;
       }
   
  +    public void setIf(String prop) {
  +        ifProp=prop;
  +    }
  +
  +    public void setUnless(String prop) {
  +        unlessProp=prop;
  +    }
  +
       // -------------------- GTest behavior --------------------
       public void setWriter( PrintWriter pw ) {
   	out=pw;
  @@ -322,6 +332,8 @@
   	    if( debug==-1) debug=defaultDebug;
   
               httpClient.setProject(project);
  +            httpClient.setIf(ifProp);
  +            httpClient.setUnless(unlessProp);
   	    initMatchers();
               httpClient.setWriter(out);
               httpClient.setOutput(outType);
  
  
  
  1.10      +18 -0     jakarta-tomcat/src/share/org/apache/tomcat/util/test/HttpClient.java
  
  Index: HttpClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/HttpClient.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpClient.java	2001/09/22 02:45:45	1.9
  +++ HttpClient.java	2001/09/22 21:10:50	1.10
  @@ -82,6 +82,8 @@
       static Report defaultReport=new Report();
   
       Project project=null;
  +    String ifProp=null;
  +    String unlessProp=null;
       HttpRequest firstRequest=null;
       Vector actions=new Vector();
       String id;
  @@ -103,6 +105,14 @@
           return project;
       }
   
  +    public void setIf(String prop) {
  +        ifProp=prop;
  +    }
  +
  +    public void setUnless(String prop) {
  +        unlessProp=prop;
  +    }
  +
       /** Set an unique id to this request. This allows it to be
        *  referenced later, for complex tests/matchers that look
        * 	at multiple requests.
  @@ -205,6 +215,14 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( project != null ) {
  +            if( ifProp != null && project.getProperty(ifProp) == null)
  +                // skip if "if" property is not set
  +                return;
  +            if( unlessProp != null && project.getProperty(unlessProp) != null )
  +                // skip if "unless" property is set
  +                return;
  +        }
           HttpRequest lastRequest=null;
   	try {
   	    Enumeration aE=actions.elements();
  
  
  
  1.2       +30 -1     jakarta-tomcat/src/share/org/apache/tomcat/util/test/Matcher.java
  
  Index: Matcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/Matcher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Matcher.java	2001/02/09 03:48:15	1.1
  +++ Matcher.java	2001/09/22 21:10:50	1.2
  @@ -58,6 +58,7 @@
    */ 
   package org.apache.tomcat.util.test;
   
  +import org.apache.tools.ant.*;
   import java.net.*;
   import java.io.*;
   import java.util.*;
  @@ -76,10 +77,23 @@
       
       // If the matching fails, a description of what failed
       StringBuffer messageSB=new StringBuffer();
  +
  +    String ifProp=null;
  +    String unlessProp=null;
           
       public Matcher() {
       }
   
  +    // ----------------- Ant Properties -----------------
  +
  +    public void setIf(String prop) {
  +        ifProp=prop;
  +    }
  +
  +    public void setUnless(String prop) {
  +        unlessProp=prop;
  +    }
  +
       // -------------------- General Properties --------------------
   
       /** Test description ( text representation of the test )
  @@ -161,6 +175,21 @@
       public void execute() {
       }
   
  -    
  +    /** Check if test should be skipped
  +     */
  +    public boolean skipTest() {
  +        if( client != null ) {
  +            Project project = client.getProject();
  +            if( project != null ) {
  +                if( ifProp != null && project.getProperty(ifProp) == null)
  +                    // skip if "if" property is not set
  +                    return true;
  +                if( unlessProp != null && project.getProperty(unlessProp) != null )
  +                    // skip if "unless" property is set
  +                    return true;
  +            }
  +        }
  +        return false;
  +    }    
       
   }
  
  
  
  1.2       +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/GoldenMatch.java
  
  Index: GoldenMatch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/GoldenMatch.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GoldenMatch.java	2001/02/09 03:48:17	1.1
  +++ GoldenMatch.java	2001/09/22 21:10:50	1.2
  @@ -115,6 +115,8 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( skipTest() )
  +           return;
   	try {
   	    result=checkResponse( magnitude );
   	} catch(Exception ex ) {
  
  
  
  1.3       +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/HeaderMatch.java
  
  Index: HeaderMatch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/HeaderMatch.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HeaderMatch.java	2001/02/16 21:53:29	1.2
  +++ HeaderMatch.java	2001/09/22 21:10:50	1.3
  @@ -138,6 +138,8 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( skipTest() )
  +           return;
   	try {
   	    result=checkResponse( magnitude );
   	} catch(Exception ex ) {
  
  
  
  1.3       +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/HttpStatusMatch.java
  
  Index: HttpStatusMatch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/HttpStatusMatch.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HttpStatusMatch.java	2001/03/01 17:56:21	1.2
  +++ HttpStatusMatch.java	2001/09/22 21:10:50	1.3
  @@ -102,6 +102,8 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( skipTest() )
  +           return;
   	try {
   	    result=checkResponse( magnitude );
   	} catch(Exception ex ) {
  
  
  
  1.3       +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/ResponseMatch.java
  
  Index: ResponseMatch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/ResponseMatch.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResponseMatch.java	2001/03/01 17:56:23	1.2
  +++ ResponseMatch.java	2001/09/22 21:10:50	1.3
  @@ -100,6 +100,8 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( skipTest() )
  +           return;
   	try {
   	    result=checkResponse( magnitude );
   	} catch(Exception ex ) {
  
  
  
  1.2       +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/ResponseMatchFile.java
  
  Index: ResponseMatchFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/ResponseMatchFile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResponseMatchFile.java	2001/02/09 03:48:17	1.1
  +++ ResponseMatchFile.java	2001/09/22 21:10:50	1.2
  @@ -107,6 +107,8 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( skipTest() )
  +           return;
   	try {
   	    result=checkResponse( magnitude );
   	} catch(Exception ex ) {
  
  
  
  1.2       +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/SessionMatch.java
  
  Index: SessionMatch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/matchers/SessionMatch.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SessionMatch.java	2001/03/23 02:17:18	1.1
  +++ SessionMatch.java	2001/09/22 21:10:50	1.2
  @@ -90,6 +90,8 @@
       // -------------------- Execute the request --------------------
   
       public void execute() {
  +        if( skipTest() )
  +            return;
   	try {
   	    extractSession();
   	} catch(Exception ex ) {