jakarta-watchdog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest GetCookiesTestServlet.java
Date Sun, 17 Dec 2000 03:39:33 GMT
craigmcc    00/12/16 19:39:33

  Modified:    src/conf servlet-gtest.xml
               src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest
                        GetCookiesTestServlet.java
  Log:
  Fix GetCookiesTest to check the name as well as the value of the
  received cookie, and to report all possible causes for a test failure.
  
  Revision  Changes    Path
  1.12      +1 -1      jakarta-watchdog-4.0/src/conf/servlet-gtest.xml
  
  Index: servlet-gtest.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-watchdog-4.0/src/conf/servlet-gtest.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- servlet-gtest.xml	2000/12/17 02:50:16	1.11
  +++ servlet-gtest.xml	2000/12/17 03:39:32	1.12
  @@ -1032,7 +1032,7 @@
   
        <target name="GetCookiesTest" >
         <gtest request="GET /servlet-tests/GetCookiesTest HTTP/1.0"
  -           debug="0" host="${host}" port="${port}" requestHeaders="Cookie: BestLanguage=java"

  +           debug="0" host="${host}" port="${port}" requestHeaders="Cookie:BestLanguage=Java"

              goldenFile="${wgdir}/javax_servlet_http/HttpServletRequest/GetCookiesTest.html"
/>
   	</target>
   
  
  
  
  1.2       +36 -33    jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetCookiesTestServlet.java
  
  Index: GetCookiesTestServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetCookiesTestServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetCookiesTestServlet.java	2000/10/16 22:38:56	1.1
  +++ GetCookiesTestServlet.java	2000/12/17 03:39:33	1.2
  @@ -1,6 +1,6 @@
   /*
  - * $Header: /home/cvs/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetCookiesTestServlet.java,v
1.1 2000/10/16 22:38:56 santosh Exp $
  - * $Date: 2000/10/16 22:38:56 $
  + * $Header: /home/cvs/jakarta-watchdog-4.0/src/server/servlet-tests/WEB-INF/classes/tests/javax_servlet_http/HttpServletRequest/GetCookiesTestServlet.java,v
1.2 2000/12/17 03:39:33 craigmcc Exp $
  + * $Date: 2000/12/17 03:39:33 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -85,37 +85,40 @@
   
   
   		PrintWriter out = response.getWriter( );
  -		Cookie cookies[]=null;
  +                String expectedName = "BestLanguage";
  +                String expectedValue = "Java";
  +                int expectedCount = 1;
  +		String gotName = null;
  +                String gotValue= null;
  +
  +		Cookie cookies[] = request.getCookies();
  +                if (cookies == null) {
  +                    out.println("GetCookiesTest test FAILED");
  +                    out.println("getCookies() returned null");
  +                    out.flush();
  +                    return;
  +                }
  +                for (int i = 0; i < cookies.length; i++) {
  +                    gotName = cookies[i].getName();
  +                    if (gotName.equals(expectedName)) {
  +                        gotValue = cookies[i].getValue();
  +                    }
  +                }
  +
  +                if ((expectedCount != cookies.length) ||
  +                    !expectedName.equals(gotName) ||
  +                    !expectedValue.equals(gotValue)) {
  +                    out.println("GetCookiesTest test FAILED");
  +                    out.println("Expected count = " + expectedCount +
  +                                ", actual count = " + cookies.length);
  +                    out.println("Expected name = " + expectedName +
  +                                ", gotName = " + gotName);
  +                    out.println("Expected value = " + expectedValue +
  +                                ", gotValue = " + gotValue);
  +                } else {
  +                    out.println("GetCookiesTest test PASSED");
  +                }
   
  -		boolean gotCookie=false;
  +        }
   
  -		if((request.getCookies() instanceof Cookie[])) {
  -
  -			cookies = request.getCookies();
  -			gotCookie=true;
  -		}
  -		else {
  -
  -			out.println("GetCookiesTest test FAILED");	
  -			out.println("getCookies()did not return an object of type Cookie[]");
  -		}
  -
  -		if(gotCookie) {
  -
  -			int j=cookies.length;
  -
  -			if(j<1) {
  -				out.println("GetCookiesTest test FAILED");
  -				out.println("getCookies failed to get all cookies set");
  -				out.println("cookies : " + cookies );
  -			}
  -			else
  -			{
  -				out.println("GetCookiesTest test PASSED");
  -			}
  -				
  -		 }
  -
  -
  -	}
   }
  
  
  

Mime
View raw message