craigmcc    01/05/10 15:52:29

  Modified:    tester/src/bin tester.xml
               tester/web/WEB-INF web.xml
  Added:       tester/src/tester/org/apache/tester GetLocales01.java
                        GetLocales02.java
  Log:
  Add tests for request.getLocale() and request.getLocales().
  
  Revision  Changes    Path
  1.43      +40 -0     jakarta-tomcat-4.0/tester/src/bin/tester.xml
  
  Index: tester.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.xml,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- tester.xml        2001/05/10 20:45:48     1.42
  +++ tester.xml        2001/05/10 22:52:23     1.43
  @@ -807,6 +807,46 @@
            request="${context.path}/WrappedGetInputStream01" debug="${debug}"
         outContent="GetInputStream01 PASSED"/>
   
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/GetLocales01" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca##Accept-Language:en-gb"
  +      outContent="GetLocales01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/WrappedGetLocales01" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca##Accept-Language:en-gb"
  +      outContent="GetLocales01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/GetLocales01" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca,en-gb"
  +      outContent="GetLocales01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/WrappedGetLocales01" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca,en-gb"
  +      outContent="GetLocales01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/GetLocales02" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca##Accept-Language:en-gb"
  +      outContent="GetLocales02 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/WrappedGetLocales02" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca##Accept-Language:en-gb"
  +      outContent="GetLocales02 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/GetLocales02" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca,en-gb"
  +      outContent="GetLocales02 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="HTTP/1.0"
  +         request="${context.path}/WrappedGetLocales02" debug="${debug}"
  +       inHeaders="Accept-Language:en-ca,en-gb"
  +      outContent="GetLocales02 PASSED"/>
  +
     </target>
   
   
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetLocales01.java
  
  Index: GetLocales01.java
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 The Apache Software License,  Version 1.1                 *
   *                                                                           *
   *     Copyright (c) 1999, 2000, 2001  The Apache Software Foundation.       *
   *                           All rights reserved.                            *
   *                                                                           *
   * ========================================================================= *
   *                                                                           *
   * Redistribution and use in source and binary forms,  with or without modi- *
   * fication, are permitted provided that the following conditions are met:   *
   *                                                                           *
   * 1. Redistributions of source code  must retain the above copyright notice *
   *    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 <[EMAIL PROTECTED]>.                        *
   *                                                                           *
   * 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 Software Foundation.                                            *
   *                                                                           *
   * 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 indivi- *
   * duals on behalf of the  Apache Software Foundation.  For more information *
   * on the Apache Software Foundation, please see <http://www.apache.org/>.   *
   *                                                                           *
   * ========================================================================= */
  
  package org.apache.tester;
  
  
  import java.io.*;
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Part 1 of the request locale tests.  Should receive a Locale that
   * corresponds to "en_CA" Accept-Language header that is sent first.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/05/10 22:52:25 $
   */
  
  public class GetLocales01 extends HttpServlet {
  
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          response.reset();
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          Locale expected = new Locale("en", "CA");
          Locale received = request.getLocale();
          if (received == null)
              writer.println("GetLocales01 FAILED - No locale was received");
          else if (!expected.equals(received))
              writer.println("GetLocales01 FAILED - Expected='" +
                             expected.toString() + "' Received='" +
                             received.toString() + "'");
          else
              writer.println("GetLocales01 PASSED");
  
          while (true) {
              String message = StaticLogger.read();
              if (message == null)
                  break;
              writer.println(message);
          }
          StaticLogger.reset();
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetLocales02.java
  
  Index: GetLocales02.java
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 The Apache Software License,  Version 1.1                 *
   *                                                                           *
   *     Copyright (c) 1999, 2000, 2001  The Apache Software Foundation.       *
   *                           All rights reserved.                            *
   *                                                                           *
   * ========================================================================= *
   *                                                                           *
   * Redistribution and use in source and binary forms,  with or without modi- *
   * fication, are permitted provided that the following conditions are met:   *
   *                                                                           *
   * 1. Redistributions of source code  must retain the above copyright notice *
   *    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 <[EMAIL PROTECTED]>.                        *
   *                                                                           *
   * 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 Software Foundation.                                            *
   *                                                                           *
   * 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 indivi- *
   * duals on behalf of the  Apache Software Foundation.  For more information *
   * on the Apache Software Foundation, please see <http://www.apache.org/>.   *
   *                                                                           *
   * ========================================================================= */
  
  package org.apache.tester;
  
  
  import java.io.*;
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Part 2 of the request locale tests.  Should receive a Locale that
   * corresponds to "en_CA" and then "en_GB" as sent by the client in
   * "Accept-Language" headers.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/05/10 22:52:25 $
   */
  
  public class GetLocales02 extends HttpServlet {
  
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          response.reset();
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
          StringBuffer sb = new StringBuffer();
          boolean ok = true;
  
          Enumeration locales = request.getLocales();
          if (locales == null) {
              sb.append(" No locales returned/");
              ok = false;
          }
  
          if (ok) {
              if (locales.hasMoreElements()) {
                  Locale expected = new Locale("en", "CA");
                  Locale received = (Locale) locales.nextElement();
                  if (!expected.equals(received)) {
                      sb.append(" Expected1='" +
                             expected.toString() + "' Received1='" +
                             received.toString() + "'");
                  }
              } else {
                  sb.append(" Zero locales returned/");
                  ok = false;
              }
          }
  
          if (ok) {
              if (locales.hasMoreElements()) {
                  Locale expected = new Locale("en", "GB");
                  Locale received = (Locale) locales.nextElement();
                  if (!expected.equals(received)) {
                      sb.append(" Expected2='" +
                             expected.toString() + "' Received2='" +
                             received.toString() + "'");
                  }
              } else {
                  sb.append(" One locale returned/");
                  ok = false;
              }
          }
  
          if (ok) {
              if (locales.hasMoreElements()) {
                  sb.append(" More than two locales returned/");
                  ok = false;
              }
          }
  
          if (ok && (sb.length() < 1)) {
              writer.println("GetLocales02 PASSED");
          } else {
              writer.print("GetLocales02 FAILED -");
              writer.println(sb.toString());
          }
  
  
          while (true) {
              String message = StaticLogger.read();
              if (message == null)
                  break;
              writer.println(message);
          }
          StaticLogger.reset();
  
      }
  
  
  }
  
  
  
  1.32      +40 -0     jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- web.xml   2001/05/10 20:46:00     1.31
  +++ web.xml   2001/05/10 22:52:27     1.32
  @@ -133,6 +133,16 @@
       </filter-mapping>
   
       <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedGetLocales01</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedGetLocales02</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
           <filter-name>GenericFilter</filter-name>
           <url-pattern>/WrappedGetParameter01</url-pattern>
       </filter-mapping>
  @@ -422,6 +432,16 @@
       </servlet>
   
       <servlet>
  +        <servlet-name>GetLocales01</servlet-name>
  +        <servlet-class>org.apache.tester.GetLocales01</servlet-class>
  +    </servlet>
  +
  +    <servlet>
  +        <servlet-name>GetLocales02</servlet-name>
  +        <servlet-class>org.apache.tester.GetLocales02</servlet-class>
  +    </servlet>
  +
  +    <servlet>
           <servlet-name>GetParameter01</servlet-name>
           <servlet-class>org.apache.tester.GetParameter01</servlet-class>
       </servlet>
  @@ -788,6 +808,26 @@
       <servlet-mapping>
           <servlet-name>GetInputStream01</servlet-name>
           <url-pattern>/WrappedGetInputStream01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>GetLocales01</servlet-name>
  +        <url-pattern>/GetLocales01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>GetLocales01</servlet-name>
  +        <url-pattern>/WrappedGetLocales01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>GetLocales02</servlet-name>
  +        <url-pattern>/GetLocales02</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>GetLocales02</servlet-name>
  +        <url-pattern>/WrappedGetLocales02</url-pattern>
       </servlet-mapping>
   
       <servlet-mapping>
  
  
  

Reply via email to