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...@hyperreal.org on 1999/11/04 19:44:04 UTC

cvs commit: jakarta-tomcat/src/tests/share/tests/jsp/Golden ServletParam.txt servletParam1.txt servletParam2.txt

costin      99/11/04 10:44:03

  Modified:    src/tests/share/tests/jsp Jsp.java jsp.properties
  Added:       src/tests/share/tests/jsp/Golden ServletParam.txt
                        servletParam1.txt servletParam2.txt
  Log:
  -Added tests for "Servlet with multiple names" case
  -In the Golden client, display the current test
  -In case of failure, display the request that caused the failure,
  the current response and the expected response.
  This way it is easy to debug and fix - you know what fails.
  
  Revision  Changes    Path
  1.3       +33 -24    jakarta-tomcat/src/tests/share/tests/jsp/Jsp.java
  
  Index: Jsp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/tests/share/tests/jsp/Jsp.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Jsp.java	1999/11/04 01:39:42	1.2
  +++ Jsp.java	1999/11/04 18:43:42	1.3
  @@ -1,6 +1,6 @@
   
   /*
  - * $Id: Jsp.java,v 1.2 1999/11/04 01:39:42 costin Exp $
  + * $Id: Jsp.java,v 1.3 1999/11/04 18:43:42 costin Exp $
    */
   
   /**
  @@ -97,7 +97,7 @@
           boolean testCondition = Boolean.valueOf(magnitude).booleanValue(); 
           boolean responseStatus = dispatch(testId, testCondition);
   
  -        return (testCondition) ? responseStatus : ! responseStatus;
  +        return testCondition == responseStatus;
       }
   
       private boolean dispatch(String testId, boolean testCondition) {
  @@ -107,10 +107,12 @@
   
           if (ready()) {
               try {
  -                writeRequest(testId);
  +		String request = props.getProperty("test." + testId + ".request");
  +		System.out.println("Testing " + request );
  +		writeRequest(testId, request);
                   if (this.debug) 
                       System.out.println("<--BEG---");
  -                responseStatus = getResponse(testId, testCondition);
  +                responseStatus = getResponse(testId, testCondition, request);
                   if (this.debug)
                       System.out.println("---END-->");
   
  @@ -164,9 +166,8 @@
           }
       }
   
  -    private void writeRequest(String testId)
  +    private void writeRequest(String testId, String request)
       throws IOException {
  -        String request = props.getProperty("test." + testId + ".request");
           if (this.debug) 
               System.out.println(testId + ". " + request);
           if (request == null) {
  @@ -178,7 +179,7 @@
       
       }
   
  -    private boolean getResponse(String testId, boolean testCondition)
  +    private boolean getResponse(String testId, boolean testCondition, String request)
       throws IOException {
           String line = null;
   
  @@ -200,8 +201,18 @@
           //System.out.println("REveived: " + result + ".");
   
           // Compare the results and set the status
  -        return compare(result.toString(), expResult.toString(), 
  +
  +        boolean cmp=compare(result.toString(), expResult.toString(), 
               testCondition) && returnCode;
  +	if(  cmp != testCondition ) {
  +	    System.out.println("Error in : " + testId);
  +	    System.out.println("Expected: ");
  +	    System.out.println(expResult);
  +	    System.out.println();
  +	    System.out.println("Got:");
  +	    System.out.println(result);
  +	}
  +	return cmp;
       }
   
       private boolean checkReturnCode(String testId) {
  @@ -247,24 +258,30 @@
           }
       }
   
  -    private StringBuffer getServerBody() {
  +    StringBuffer readBody( BufferedReader rd ) {
           StringBuffer result = new StringBuffer("");
           String line;
           try {
  -            while ((line = br.readLine()) != null) {
  +            while ((line = rd.readLine()) != null) {
                   if (this.debug)
                       System.out.println("\t" + line);
                   // Tokenize the line
  -                StringTokenizer tok = new StringTokenizer(line);
  -                while (tok.hasMoreTokens()) {
  -                    String token = tok.nextToken();
  -                    result.append("  " + token);
  -                };
  +		// XXX Do we need to tokenize? Space is significant!
  +//                 StringTokenizer tok = new StringTokenizer(line);
  +//                 while (tok.hasMoreTokens()) {
  +//                     String token = tok.nextToken();
  +//                     result.append("  " + token);
  +//                 };
  +		result.append(line).append("\n");
               }
           } catch (IOException ioe) {
           }
           return result;
       }
  +    
  +    private StringBuffer getServerBody() {
  +	return readBody( br );
  +    }
   
       // Parse a file into a String.
       private StringBuffer getExpectedResult(String testId)
  @@ -283,15 +300,7 @@
               return expResult;
           }
           if (bin != null) {
  -            String line = null;
  -
  -            while ((line = bin.readLine()) != null ) {
  -                StringTokenizer tok = new StringTokenizer(line);
  -                while (tok.hasMoreTokens()) {
  -                    String token = tok.nextToken();
  -                    expResult.append("  " + token);
  -                }
  -            }
  +	    return readBody( bin );
           }
           //System.out.println("expResult: " + expResult);
           return expResult;
  
  
  
  1.3       +18 -1     jakarta-tomcat/src/tests/share/tests/jsp/jsp.properties
  
  Index: jsp.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/tests/share/tests/jsp/jsp.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jsp.properties	1999/11/04 01:39:44	1.2
  +++ jsp.properties	1999/11/04 18:43:49	1.3
  @@ -5,7 +5,7 @@
   Debug:false
   
   tests:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22, \
  -	22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
  +	22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43
   
   test.1.request:GET /jsp/HelloWorld.jsp HTTP/1.0
   test.1.golden: HelloWorld.txt
  @@ -187,3 +187,20 @@
   test.40.returnCode: HTTP/1.0 200 OK
   test.40.golden: pageImport.txt
   test.40.magnitude:true
  +
  +test.41.request:GET /servlet/servletParam1 HTTP/1.0
  +test.41.returnCode: HTTP/1.0 200 OK
  +test.41.golden: servletParam1.txt
  +test.41.magnitude:true
  +
  +test.42.request:GET /servlet/servletParam2 HTTP/1.0
  +test.42.returnCode: HTTP/1.0 200 OK
  +test.42.golden: servletParam2.txt
  +test.42.magnitude:true
  +
  +test.43.request:GET /servlet/ServletParam HTTP/1.0
  +test.43.returnCode: HTTP/1.0 200 OK
  +test.43.golden: ServletParam.txt
  +test.43.magnitude:true
  +
  +
  
  
  
  1.1                  jakarta-tomcat/src/tests/share/tests/jsp/Golden/ServletParam.txt
  
  Index: ServletParam.txt
  ===================================================================
  <html>
  <body>
  <h1>ServletParam</h1>
  <dl>
  </dl>
  </body></html>
  
  
  
  
  1.1                  jakarta-tomcat/src/tests/share/tests/jsp/Golden/servletParam1.txt
  
  Index: servletParam1.txt
  ===================================================================
  <html>
  <body>
  <h1>servletParam1</h1>
  <dl>
  <dt>param2</dt><dd>value2</dd>
  <dt>param1</dt><dd>value1</dd>
  </dl>
  </body></html>
  
  
  
  
  1.1                  jakarta-tomcat/src/tests/share/tests/jsp/Golden/servletParam2.txt
  
  Index: servletParam2.txt
  ===================================================================
  <html>
  <body>
  <h1>servletParam2</h1>
  <dl>
  <dt>param4</dt><dd>value4</dd>
  <dt>param3</dt><dd>value3</dd>
  </dl>
  </body></html>