You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/09/09 17:04:51 UTC

cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

epugh       2003/09/09 08:04:51

  Modified:    .        project.xml
               src/java/org/apache/turbine/services/localization
                        TurbineLocalizationService.java
                        LocalizationTool.java LocalizationService.java
                        LocaleTokenizer.java
               src/java/org/apache/turbine/services
                        InstantiationException.java
  Added:       conf/test TestLocalization.properties
                        componentLocalizationConfiguration.xml
                        roleLocalizationConfiguration.xml
               src/test/org/apache/turbine/services/localization
                        BarBundle_en_US.java LocalizationToolTest.java
               src/test/org/apache/turbine/test
                        EnhancedMockHttpServletRequest.java
  Log:
  Deprecated Turbine localization in favor of using the Fulcrum Localization service.
  the way in is via the LocalizationTool, so if that is all you use, it should be pretty
  much backwards code compatible.  I added a unit test that verifies that the fulcrum
  localization service loads up.  The unit test leverages mock http objects.  All 
  jars are on the turbine repo: jakarta.apache.org/turbine/repo.
  
  Revision  Changes    Path
  1.139     +19 -0     jakarta-turbine-2/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
  retrieving revision 1.138
  retrieving revision 1.139
  diff -u -r1.138 -r1.139
  --- project.xml	3 Sep 2003 09:35:47 -0000	1.138
  +++ project.xml	9 Sep 2003 15:04:51 -0000	1.139
  @@ -398,6 +398,14 @@
         <url>http://jakarta.apache.org/avalon/</url>
       </dependency>
       <dependency>
  +      <id>fulcrum-localization</id>
  +      <version>1.0-alpha-3</version>
  +      <url>http://jakarta.apache.org/turbine/fulcrum/</url>
  +      <properties>
  +        <war.bundle.jar>true</war.bundle.jar>
  +      </properties>
  +    </dependency>    
  +    <dependency>
         <id>jaf:activation</id>
         <version>1.0.2</version>
         <url>http://java.sun.com/products/javabeans/glasgow/jaf.html</url>
  @@ -489,6 +497,17 @@
         <version>1.2-b1</version>
         <url>http://xml.apache.org/xmlrpc/</url>
       </dependency>
  +    
  +    <dependency>
  +      <groupId>mockobjects</groupId>
  +      <artifactId>mockobjects-jdk1.4-j2ee1.3</artifactId>
  +      <version>0.09</version>
  +    </dependency> 
  +    <dependency>
  +      <groupId>mockobjects</groupId>
  +      <artifactId>mockobjects-core</artifactId>
  +      <version>0.09</version>
  +    </dependency>     
     </dependencies>
   
     <build>
  
  
  
  1.1                  jakarta-turbine-2/conf/test/TestLocalization.properties
  
  Index: TestLocalization.properties
  ===================================================================
  # -------------------------------------------------------------------
  # $Id: TestLocalization.properties,v 1.1 2003/09/09 15:04:51 epugh Exp $
  #
  # This is the configuration file for Turbine.
  #
  # Note that strings containing "," (comma) characters must backslash
  # escape the comma (i.e. '\,')
  #
  # -------------------------------------------------------------------
  
  # -------------------------------------------------------------------
  #
  #  L O G 4 J - L O G G I N G
  #
  # -------------------------------------------------------------------
  
  log4j.file = /conf/test/Log4j.properties
  
  
  
  # If module.cache=true, then how large should we make the hashtables
  # by default.
  
  action.cache.size=20
  layout.cache.size=10
  navigation.cache.size=10
  page.cache.size=5
  screen.cache.size=50
  scheduledjob.cache.size=10
  
  # -------------------------------------------------------------------
  #
  #  M O D U L E  P A C K A G E S
  #
  # -------------------------------------------------------------------
  # This is the "classpath" for Turbine.  In order to locate your own
  # modules, you should add them to this path.  For example, if you have
  # com.company.actions, com.company.screens, com.company.navigations,
  # then this setting would be "com.company,org.apache.turbine.modules".
  # This path is searched in order.  For example, Turbine comes with a
  # screen module named "Login".  If you wanted to have your own screen
  # module named "Login", then you would specify the path to your
  # modules before the others.
  #
  # Note: org.apache.turbine.modules will always be added to the search
  # path.  If it is not explictly added here, it will be added to the
  # end.
  #
  # Default: org.apache.turbine.modules
  # -------------------------------------------------------------------
  
  module.packages=@MODULE_PACKAGES@
  
  
  
  services.AvalonComponentService.classname=org.apache.turbine.services.avaloncomponent.TurbineAvalonComponentService
  services.CryptoService.classname=org.apache.turbine.services.crypto.TurbineCryptoService
  services.ComponentService.classname=org.apache.turbine.services.component.TurbineComponentService
  services.FactoryService.classname=org.apache.turbine.services.factory.TurbineFactoryService
  services.PoolService.classname=org.apache.turbine.services.pool.TurbinePoolService
  services.RunDataService.classname=org.apache.turbine.services.rundata.TurbineRunDataService
  services.ServletService.classname=org.apache.turbine.services.servlet.TurbineServletService
  services.AssemblerBrokerService.classname=org.apache.turbine.services.assemblerbroker.TurbineAssemblerBrokerService
  services.LocalizationService.classname=org.apache.turbine.services.localization.TurbineLocalizationService
  services.MimeTypeService.classname=org.apache.turbine.services.mimetype.TurbineMimeTypeService
  services.PullService.classname=org.apache.turbine.services.pull.TurbinePullService
  services.TemplateService.classname=org.apache.turbine.services.template.TurbineTemplateService
  
  
  
  
  services.RunDataService.default.run.data=org.apache.turbine.services.rundata.DefaultTurbineRunData
  services.RunDataService.default.parameter.parser=org.apache.turbine.util.parser.DefaultParameterParser
  services.RunDataService.default.cookie.parser=org.apache.turbine.util.parser.DefaultCookieParser
  
  # -------------------------------------------------------------------
  #
  #  A S S E M B L E R  B R O K E R  S E R V I C E
  #
  # -------------------------------------------------------------------
  # A list of AssemblerFactory classes that will be registered
  # with TurbineAssemblerBrokerService
  # -------------------------------------------------------------------
  
  services.AssemblerBrokerService.screen=org.apache.turbine.services.assemblerbroker.util.java.JavaScreenFactory
  #services.AssemblerBrokerService.screen=org.apache.turbine.services.assemblerbroker.util.python.PythonScreenFactory
  services.AssemblerBrokerService.action=org.apache.turbine.services.assemblerbroker.util.java.JavaActionFactory
  services.AssemblerBrokerService.layout=org.apache.turbine.services.assemblerbroker.util.java.JavaLayoutFactory
  services.AssemblerBrokerService.page=org.apache.turbine.services.assemblerbroker.util.java.JavaPageFactory
  services.AssemblerBrokerService.navigation=org.apache.turbine.services.assemblerbroker.util.java.JavaNavigationFactory
  services.AssemblerBrokerService.scheduledjob=org.apache.turbine.services.assemblerbroker.util.java.JavaScheduledJobFactory
  
  # -------------------------------------------------------------------
  #
  #  T E M P L A T E  S E R V I C E
  #
  # -------------------------------------------------------------------
  
  # Roughly, the number of templates in each category.
  #
  # Defaults: layout=2, navigation=10, screen=50
  
  services.TemplateService.layout.cache.size=2
  services.TemplateService.navigation.cache.size=10
  services.TemplateService.screen.cache.size=50
  
  services.PullService.earlyInit= true
  
  services.PullService.tools.per.request.refresh=true
  
  tool.request.l10n=org.apache.turbine.services.localization.LocalizationTool
  
  
  # -------------------------------------------------------------------
  #
  #  L O C A L I Z A T I O N  S E R V I C E
  #
  # -------------------------------------------------------------------
  
  # Default ResourceBundle and language/country codes used by the
  # TurbineLocalizationService.
  #
  locale.default.bundle=MyBundle
  locale.default.language=en
  locale.default.country=US
  
  #
  # This will set the charset= portion of the ContentType: header.
  # Leave commented out unless you want to return stuff as a different
  # charset.
  #
  # locale.default.charset=
  
  # -------------------------------------------------------------------
  #
  #  P O O L  S E R V I C E
  #
  # -------------------------------------------------------------------
  
  # Default capacity of pools of the Object pooling service.
  #
  # Default: 128
  services.PoolService.pool.capacity = 128
  
  # Class specific capacities used instead of the default if specified.
  #
  #services.PoolService.pool.capacity.org.apache.turbine.services.rundata.DefaultTurbineRunData=512
  
  # -------------------------------------------------------------------
  #
  #  F A C T O R Y  S E R V I C E
  #
  # -------------------------------------------------------------------
  
  # A comma separated list of classloaders (very optional)
  #
  # Example: org.foo.bar.MyClassLoader, org.ack.joe.YourClassLoader
  #
  #services.FactoryService.class.loaders=
  
  # Customized factories to be used instead of the default factory.
  # E.g. to instantiate XML parsers, SSL sockets, etc., which require
  # specific instantiation not supported by the default factory.
  # The property name is prefixed with "factory" followed by the
  # name of the production class. The value is the class name of
  # the factory implementing the Factory interface. The factory
  # will be instantiated by using the service itself.
  #
  # Examples:
  #
  # services.FactoryService.factory.javax.xml.parsers.DocumentBuilder=org.foo.xml.DomBuilderFactory
  # services.FactoryService.factory.javax.xml.parsers.SAXParser=org.foo.xml.SaxParserFactory
  # services.FactoryService.factory.java.net.ServerSocket=org.foo.net.SslServerSocketFactory
  
  services.AvalonComponentService.componentConfiguration = conf/test/componentLocalizationConfiguration.xml
  services.AvalonComponentService.componentRoles = conf/test/roleLocalizationConfiguration.xml
  
  
  
  1.1                  jakarta-turbine-2/conf/test/componentLocalizationConfiguration.xml
  
  Index: componentLocalizationConfiguration.xml
  ===================================================================
  <!-- This configuration file for Avalon components is used for testing the LocalizationTool pull tool -->
  
  <componentConfig>
      <localization>
        <bundles>
          <bundle>org.apache.turbine.services.localization.BarBundle</bundle>     
        </bundles>
      </localization>
  </componentConfig>
  
  
  
  1.1                  jakarta-turbine-2/conf/test/roleLocalizationConfiguration.xml
  
  Index: roleLocalizationConfiguration.xml
  ===================================================================
  <!-- This configuration file for Avalon components is used for testing the TorqueComponent -->
  
  <role-list>
      <role
          name="org.apache.fulcrum.localization.LocalizationService"
          shorthand="localization"
          default-class="org.apache.fulcrum.localization.DefaultLocalizationService"/>
  </role-list>
  
  
  
  
  1.10      +3 -2      jakarta-turbine-2/src/java/org/apache/turbine/services/localization/TurbineLocalizationService.java
  
  Index: TurbineLocalizationService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/TurbineLocalizationService.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TurbineLocalizationService.java	7 Apr 2003 15:42:16 -0000	1.9
  +++ TurbineLocalizationService.java	9 Sep 2003 15:04:51 -0000	1.10
  @@ -95,7 +95,8 @@
    * <li>getBundle("MyBundleName", Locale)</li>
    * <li>etc.</li>
    * </ul></p>
  - *
  + * 
  + * @deprecated Use the Fulcrum Localization component instead.
    * @author <a href="mailto:jm@mediaphil.de">Jonas Maurus</a>
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
    * @author <a href="mailto:novalidemail@foo.com">Frank Y. Kim</a>
  
  
  
  1.8       +30 -29    jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationTool.java
  
  Index: LocalizationTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationTool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LocalizationTool.java	9 Mar 2003 03:06:29 -0000	1.7
  +++ LocalizationTool.java	9 Sep 2003 15:04:51 -0000	1.8
  @@ -1,5 +1,4 @@
   package org.apache.turbine.services.localization;
  -
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  @@ -53,20 +52,22 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   import java.util.Locale;
   import java.util.MissingResourceException;
  -import java.util.ResourceBundle;
  -
  +import org.apache.turbine.services.InstantiationException;
  +import org.apache.avalon.framework.component.ComponentException;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.fulcrum.localization.LocalizationService;
  +import org.apache.turbine.services.TurbineServices;
  +import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
   import org.apache.turbine.services.pull.ApplicationTool;
   import org.apache.turbine.util.RunData;
  -
   /**
    * A pull tool which provides lookups for localized text by delegating
  - * to the configured <code>LocalizationService</code>.
  + * to the configured Fulcrum <code>LocalizationService</code>.
    *
  + * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
    * @author <a href="mailto:jon@collab.net">Jon Stevens</a>
    */
  @@ -74,23 +75,33 @@
   {
       /** Logging */
       private static Log log = LogFactory.getLog(LocalizationTool.class);
  -
  +    /** Fulcrum Localization component */
  +    private LocalizationService localizationService;
       /**
        * The language and country information parsed from the request's
        * <code>Accept-Language</code> header.  Reset on each request.
        */
       protected Locale locale;
  -
  +    
       /**
  -     * The bundle for this request.
  +     * Lazy load the LocalizationService.
  +     * @return a fulcrum LocalizationService
        */
  -    private ResourceBundle bundle;
  -
  -    /**
  -     * The name of the bundle for this tool to use.
  -     */
  -    private String bundleName;
  -
  +    public LocalizationService getLocalizationService()
  +    {
  +        if (localizationService == null)
  +        {
  +            AvalonComponentService acs =
  +                (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
  +                try {
  +            localizationService = (LocalizationService)acs.lookup(LocalizationService.ROLE);
  +                }
  +                catch (ComponentException ce) {
  +                    throw new InstantiationException("Problem looking up Localization Service:"+ce.getMessage());
  +                }
  +        }
  +        return localizationService;
  +    }
       /**
        * Creates a new instance.  Used by <code>PullService</code>.
        */
  @@ -98,7 +109,6 @@
       {
           refresh();
       }
  -
       /**
        * <p>Performs text lookups for localization.</p>
        *
  @@ -116,7 +126,7 @@
       {
           try
           {
  -            return Localization.getString(getBundleName(null), getLocale(), key);
  +            return getLocalizationService().getString(getBundleName(null), getLocale(), key);
           }
           catch (MissingResourceException noKey)
           {
  @@ -124,7 +134,6 @@
               return null;
           }
       }
  -
       /**
        * Gets the current locale.
        *
  @@ -134,7 +143,6 @@
       {
           return locale;
       }
  -
       /**
        * The return value of this method is used to set the name of the
        * bundle used by this tool.  Useful as a hook for using a
  @@ -146,12 +154,9 @@
        */
       protected String getBundleName(Object data)
       {
  -        return Localization.getDefaultBundleName();
  +        return getLocalizationService().getDefaultBundleName();
       }
  -
  -
       // ApplicationTool implmentation
  -
       /**
        * Sets the request to get the <code>Accept-Language</code> header
        * from (reset on each request).
  @@ -162,18 +167,14 @@
           {
               // Pull necessary information out of RunData while we have
               // a reference to it.
  -            locale = Localization.getLocale(((RunData) data).getRequest());
  -            bundleName = getBundleName(data);
  +            locale = getLocalizationService().getLocale(((RunData) data).getRequest());
           }
       }
  -
       /**
        * No-op.
        */
       public void refresh()
       {
           locale = null;
  -        bundle = null;
  -        bundleName = null;
       }
   }
  
  
  
  1.9       +2 -1      jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationService.java
  
  Index: LocalizationService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LocalizationService.java	7 Apr 2003 15:34:52 -0000	1.8
  +++ LocalizationService.java	9 Sep 2003 15:04:51 -0000	1.9
  @@ -71,6 +71,7 @@
    * <a href="http://www.math.fu-berlin.de/~rene/www/java/tutorial/i18n/message/messageFormat.html">dealing with concatenated messages</a>
    * using <code>MessageFormat</code> and properties files.</p>
    *
  + * @deprecated Use the Fulcrum Localization component instead.
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
    * @author <a href="mailto:leonardr@collab.net">Leonard Richardson</a>
  
  
  
  1.4       +3 -2      jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocaleTokenizer.java
  
  Index: LocaleTokenizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocaleTokenizer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocaleTokenizer.java	9 Mar 2003 03:06:29 -0000	1.3
  +++ LocaleTokenizer.java	9 Sep 2003 15:04:51 -0000	1.4
  @@ -64,7 +64,8 @@
   /**
    * Parses the HTTP <code>Accept-Language</code> header as per section
    * 14.4 of RFC 2068 (HTTP 1.1 header field definitions).
  - *
  + * 
  + * @deprecated Use the Fulcrum Localization component instead.
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
    * @version $Id$
    */
  
  
  
  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/services/localization/BarBundle_en_US.java
  
  Index: BarBundle_en_US.java
  ===================================================================
  package org.apache.turbine.services.localization;
  
  import java.util.ListResourceBundle;
  
  /**
   * An english resource bundle for use in testing.
   */
  public class BarBundle_en_US extends ListResourceBundle
  {
      private static final Object[][] CONTENTS =
      {
          { "key1", "value1" },
          { "key2", "value2" },
          { "key3", "value3" },
          { "key4", "value4" }
      };
  
      protected Object[][] getContents()
      {
          return CONTENTS;
      }
  }
  
  
  
  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/services/localization/LocalizationToolTest.java
  
  Index: LocalizationToolTest.java
  ===================================================================
  package org.apache.turbine.services.localization;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, 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
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  import java.util.Vector;
  import javax.servlet.ServletConfig;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.turbine.om.security.User;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.services.rundata.RunDataService;
  import org.apache.turbine.test.BaseTestCase;
  import org.apache.turbine.test.EnhancedMockHttpServletRequest;
  import org.apache.turbine.util.RunData;
  import org.apache.turbine.util.TurbineConfig;
  import com.mockobjects.servlet.MockHttpServletResponse;
  import com.mockobjects.servlet.MockHttpSession;
  import com.mockobjects.servlet.MockServletConfig;
  /**
   * Unit test for Localization Tool.  Verifies that localization works the same using the
   * deprecated Turbine localization service as well as the new Fulcrum Localization
   * component.
   *
   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   * @version $Id: LocalizationToolTest.java,v 1.1 2003/09/09 15:04:51 epugh Exp $
   */
  public class LocalizationToolTest extends BaseTestCase
  {
      private static TurbineConfig tc = null;
      public LocalizationToolTest(String name) throws Exception
      {
          super(name);
      }
      public void testGet() throws Exception
      {
          LocalizationTool lt = new LocalizationTool();
          lt.init(getRunData());
          assertEquals("value1", lt.get("key1"));
          assertEquals("value3", lt.get("key3"));
      }
      public void testGetLocale() throws Exception
      {
          LocalizationTool lt = new LocalizationTool();
          lt.init(getRunData());
          assertNotNull(lt.getLocale());
          assertEquals("US", lt.getLocale().getCountry());
          assertEquals("en", lt.getLocale().getLanguage());
      }
      public void testInit() throws Exception
      {
          LocalizationTool lt = new LocalizationTool();
          lt.init(getRunData());
          assertNotNull(lt.getLocale());
      }
      public void testRefresh() throws Exception
      {
          LocalizationTool lt = new LocalizationTool();
          lt.init(getRunData());
          assertNotNull(lt.getLocale());
          lt.refresh();
          assertNull(lt.getLocale());
      }
      private RunData getRunData() throws Exception
      {
          RunDataService rds = (RunDataService) TurbineServices.getInstance().getService(RunDataService.SERVICE_NAME);
          EnhancedMockHttpServletRequest request = new EnhancedMockHttpServletRequest();
          request.setupServerName("bob");
          request.setupGetProtocol("http");
          request.setupScheme("scheme");
          request.setupPathInfo("damn");
          request.setupGetServletPath("damn2");
          request.setupGetContextPath("wow");
          request.setupGetContentType("html/text");
          request.setupAddHeader("Content-type", "html/text");
          request.setupAddHeader("Accept-Language", "en-US");
          Vector v = new Vector();
          request.setupGetParameterNames(v.elements());
          MockHttpSession session = new MockHttpSession();
          session.setupGetAttribute(User.SESSION_KEY, null);
          request.setSession(session);
          HttpServletResponse response = new MockHttpServletResponse();
          ServletConfig config = new MockServletConfig();
          RunData runData = rds.getRunData(request, response, config);
          return runData;
      }
      public void setUp() throws Exception
      {
          tc = new TurbineConfig(".", "/conf/test/TestLocalization.properties");
          tc.initialize();
      }
      public void tearDown() throws Exception
      {
          if (tc != null)
          {
              tc.dispose();
          }
      }
  }
  
  
  
  1.6       +3 -1      jakarta-turbine-2/src/java/org/apache/turbine/services/InstantiationException.java
  
  Index: InstantiationException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/InstantiationException.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InstantiationException.java	7 Apr 2003 15:30:48 -0000	1.5
  +++ InstantiationException.java	9 Sep 2003 15:04:51 -0000	1.6
  @@ -60,6 +60,8 @@
    * Thrown by <code>InitableBroker</code> and
    * <code>ServiceBroker</code> classes to indicate problems with
    * instatiation of requested objects.
  + * 
  + * Make sure you don't confuse this exception with the java.lang.InstantiationException.
    *
    * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
  
  
  
  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/test/EnhancedMockHttpServletRequest.java
  
  Index: EnhancedMockHttpServletRequest.java
  ===================================================================
  package org.apache.turbine.test;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, 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
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import com.mockobjects.servlet.MockHttpServletRequest;
  
  /**
   * Extension to the basic MockHttpServletRequest to provide some extra parameters
   * required by Turbine.
   *
   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   * @version $Id: EnhancedMockHttpServletRequest.java,v 1.1 2003/09/09 15:04:51 epugh Exp $
   */
  public class EnhancedMockHttpServletRequest extends MockHttpServletRequest
  {
      /**
       *
       */
      public EnhancedMockHttpServletRequest()
      {
          super();
          // TODO Auto-generated constructor stub
      }
      public int getServerPort(){
        return 8080;
      }
  
      public String getCharacterEncoding(){
      return "US-ASCII";
      }
  
  }
  
  
  

RE: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Eric Pugh <ep...@upstate.com>.
I like the name org.apache.fulcrum.localization.tools.LocalizationTool, that
works for me..  However, after digging into the code a bit, while someone
created a pull component in fulcrum, there is no code behind it!

Looking at what a pull tool needs to implement, this is what I see as the
big changes.

1) The LocalizationTool needs to implement the Avalon Composable interface,
because it needs to hold on to the container so it can dynamically look up
it's underlying Service.
	- does this mean you define the tool in the roles/configuration xml as
well?

2) The init method:
 public final void init(Object data)
    {
        if (data instanceof RunData)
        {
            // Pull necessary information out of RunData while we have
            // a reference to it.
            locale = getLocalizationService().getLocale(((RunData)
data).getRequest());
        }
    }

Seems to pass in a rundata object.  However, it could just as easily pass in
a Locale object or a HttpRequest object.  However, how does Turbine know
what to pass in?  Since Turbine only passes in a rundata object.  However,
that means that this pull tool would have a dependency on the Turbine jar.
Is that okay?

The easiest, but maybe not the right way is to keep the tool under turbine,
but mark it either via the name or the package as using the fulcrum version.
That way you can hard code in the lookup via the AvalonComponentService.

Not sure I have the brain power to come up with the full fledged pull
container yet!

Eric

> -----Original Message-----
> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> Sent: Wednesday, September 10, 2003 3:38 PM
> To: turbine-dev@jakarta.apache.org
> Subject: Re: cvs commit:
> jakarta-turbine-2/src/test/org/apache/turbine/test
> EnhancedMockHttpServletRequest.java
>
>
> "Eric Pugh" <ep...@upstate.com> writes:
>
> >Um..  Actually, that is a pretty good idea..  There is no
> reason we can't do
> >that.  My concern though is that we are going to delay when
> they make the
> >conversion.  It seems to me that the second pull tool should
> be in the
> >turbine core, since pull tools are a turbine concept, and by
> putting them in
> >the turbine codebase, you can do whatever makes it easiest
> for the user of
> >turbine.
>
> Well. ;-) Pull Tools will soon be a "Pull Component" concept, which is
> used by the Turbine core to supply Pull tools to the View
> component. So there is IMHO no reason why they can't be separated out
> with the components/services that they belong to. If one wants to use
> the localization component which supplied a pull component tool, they
> must also add the pull component to the application.
>
> >I don't know exactly what the right approach is, I am fine
> with adding to
> >the Turbine code a pulltool that mimics the existing pull
> tool and just hits
> >Turbine.  I'll back out my changes and add a fresh tool..
> >FulcrumLocalizationTool?  I just hope that we aren't in for
> a nightmare of
> >patching the deprecated turbine LocalizationTool, the 2.3 branch
> >LocalizationTool, and the FulcrumLocalizationTool.
>
> I'd suggest org.apache.fulcrum.localization.tools.LocalizationTool
>                                             ^^^^^
>            seems to be convention for (Pull)Tools
>                                                   ^^^^^^^^^^^^^^^^
>                         No need to put "Fulcrum" in one more time,
>                         it's already in the package
>
> 	Regards
> 		Henning
>
>
>
> >Eric
>
> >> -----Original Message-----
> >> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> >> Sent: Wednesday, September 10, 2003 2:56 PM
> >> To: turbine-dev@jakarta.apache.org
> >> Subject: Re: cvs commit:
> >> jakarta-turbine-2/src/test/org/apache/turbine/test
> >> EnhancedMockHttpServletRequest.java
> >>
> >>
> >> "Eric Pugh" <ep...@upstate.com> writes:
> >>
> >> Is it really necessary to actually change the pull tool code?
> >> Why not add
> >> a second pull tool which uses the fulcrum code to the fulcrum
> >> component and
> >> we add a readme "if you want to use the fulcrum component,
> >> you must also change
> >> your TR.props to have tool.request.i18n =
> >> org.apache.fulcrum.<whatever>"
> >>
> >> I feel uncomfortable to make changes to Turbine that actually
> >> force unsuspecting
> >> users to switch to Fulcrum. If we simply keep (and deprecate)
> >> the old code and add
> >> new code that is separate from the turbine core, we will gain
> >> a few things:
> >>
> >> - easier migration
> >> - better encapsulation of a component
> >> - a smaller turbine core (once the service is actually removed)
> >>
> >> I admit I didn't look to deep into your code but it looked
> to me that
> >> the changes to the pull tool are a "no way back" change.
> >>
> >> 	Regards
> >> 		Henning
> >>
> >> --
> >> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen
> INTERMETA GmbH
> >> hps@intermeta.de        +49 9131 50 654 0
http://www.intermeta.de/
>>
>> Java, perl, Solaris, Linux, xSP Consulting, Web Services
>> freelance consultant -- Jakarta Turbine Development  -- hero for hire
>>
>> "Dominate!! Dominate!! Eat your young and aggregate! I have
>> grotty silicon!"
>>       -- AOL CD when played backwards  (User Friendly - 200-10-15)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
      -- AOL CD when played backwards  (User Friendly - 200-10-15)

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Eric Pugh" <ep...@upstate.com> writes:

>Um..  Actually, that is a pretty good idea..  There is no reason we can't do
>that.  My concern though is that we are going to delay when they make the
>conversion.  It seems to me that the second pull tool should be in the
>turbine core, since pull tools are a turbine concept, and by putting them in
>the turbine codebase, you can do whatever makes it easiest for the user of
>turbine.

Well. ;-) Pull Tools will soon be a "Pull Component" concept, which is
used by the Turbine core to supply Pull tools to the View
component. So there is IMHO no reason why they can't be separated out
with the components/services that they belong to. If one wants to use
the localization component which supplied a pull component tool, they
must also add the pull component to the application.

>I don't know exactly what the right approach is, I am fine with adding to
>the Turbine code a pulltool that mimics the existing pull tool and just hits
>Turbine.  I'll back out my changes and add a fresh tool..
>FulcrumLocalizationTool?  I just hope that we aren't in for a nightmare of
>patching the deprecated turbine LocalizationTool, the 2.3 branch
>LocalizationTool, and the FulcrumLocalizationTool.

I'd suggest org.apache.fulcrum.localization.tools.LocalizationTool
                                            ^^^^^
           seems to be convention for (Pull)Tools
                                                  ^^^^^^^^^^^^^^^^
                        No need to put "Fulcrum" in one more time, 
                        it's already in the package 

	Regards
		Henning



>Eric

>> -----Original Message-----
>> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
>> Sent: Wednesday, September 10, 2003 2:56 PM
>> To: turbine-dev@jakarta.apache.org
>> Subject: Re: cvs commit:
>> jakarta-turbine-2/src/test/org/apache/turbine/test
>> EnhancedMockHttpServletRequest.java
>>
>>
>> "Eric Pugh" <ep...@upstate.com> writes:
>>
>> Is it really necessary to actually change the pull tool code?
>> Why not add
>> a second pull tool which uses the fulcrum code to the fulcrum
>> component and
>> we add a readme "if you want to use the fulcrum component,
>> you must also change
>> your TR.props to have tool.request.i18n =
>> org.apache.fulcrum.<whatever>"
>>
>> I feel uncomfortable to make changes to Turbine that actually
>> force unsuspecting
>> users to switch to Fulcrum. If we simply keep (and deprecate)
>> the old code and add
>> new code that is separate from the turbine core, we will gain
>> a few things:
>>
>> - easier migration
>> - better encapsulation of a component
>> - a smaller turbine core (once the service is actually removed)
>>
>> I admit I didn't look to deep into your code but it looked to me that
>> the changes to the pull tool are a "no way back" change.
>>
>> 	Regards
>> 		Henning
>>
>> --
>> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
>> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>>
>> Java, perl, Solaris, Linux, xSP Consulting, Web Services
>> freelance consultant -- Jakarta Turbine Development  -- hero for hire
>>
>> "Dominate!! Dominate!! Eat your young and aggregate! I have
>> grotty silicon!"
>>       -- AOL CD when played backwards  (User Friendly - 200-10-15)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!" 
      -- AOL CD when played backwards  (User Friendly - 200-10-15)

RE: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Eric Pugh <ep...@upstate.com>.
Um..  Actually, that is a pretty good idea..  There is no reason we can't do
that.  My concern though is that we are going to delay when they make the
conversion.  It seems to me that the second pull tool should be in the
turbine core, since pull tools are a turbine concept, and by putting them in
the turbine codebase, you can do whatever makes it easiest for the user of
turbine.

I do think though that we are planning on a no-way back approach..  If you
want to use T2.4, you should use the T2.4 codebase, which means updating
your various project config files to be avalon friendly etc..

I don't know exactly what the right approach is, I am fine with adding to
the Turbine code a pulltool that mimics the existing pull tool and just hits
Turbine.  I'll back out my changes and add a fresh tool..
FulcrumLocalizationTool?  I just hope that we aren't in for a nightmare of
patching the deprecated turbine LocalizationTool, the 2.3 branch
LocalizationTool, and the FulcrumLocalizationTool.

Eric

> -----Original Message-----
> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> Sent: Wednesday, September 10, 2003 2:56 PM
> To: turbine-dev@jakarta.apache.org
> Subject: Re: cvs commit:
> jakarta-turbine-2/src/test/org/apache/turbine/test
> EnhancedMockHttpServletRequest.java
>
>
> "Eric Pugh" <ep...@upstate.com> writes:
>
> Is it really necessary to actually change the pull tool code?
> Why not add
> a second pull tool which uses the fulcrum code to the fulcrum
> component and
> we add a readme "if you want to use the fulcrum component,
> you must also change
> your TR.props to have tool.request.i18n =
> org.apache.fulcrum.<whatever>"
>
> I feel uncomfortable to make changes to Turbine that actually
> force unsuspecting
> users to switch to Fulcrum. If we simply keep (and deprecate)
> the old code and add
> new code that is separate from the turbine core, we will gain
> a few things:
>
> - easier migration
> - better encapsulation of a component
> - a smaller turbine core (once the service is actually removed)
>
> I admit I didn't look to deep into your code but it looked to me that
> the changes to the pull tool are a "no way back" change.
>
> 	Regards
> 		Henning
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>
> Java, perl, Solaris, Linux, xSP Consulting, Web Services
> freelance consultant -- Jakarta Turbine Development  -- hero for hire
>
> "Dominate!! Dominate!! Eat your young and aggregate! I have
> grotty silicon!"
>       -- AOL CD when played backwards  (User Friendly - 200-10-15)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Eric Pugh" <ep...@upstate.com> writes:

Is it really necessary to actually change the pull tool code? Why not add
a second pull tool which uses the fulcrum code to the fulcrum component and
we add a readme "if you want to use the fulcrum component, you must also change
your TR.props to have tool.request.i18n = org.apache.fulcrum.<whatever>"

I feel uncomfortable to make changes to Turbine that actually force unsuspecting
users to switch to Fulcrum. If we simply keep (and deprecate) the old code and add
new code that is separate from the turbine core, we will gain a few things:

- easier migration
- better encapsulation of a component
- a smaller turbine core (once the service is actually removed)

I admit I didn't look to deep into your code but it looked to me that
the changes to the pull tool are a "no way back" change.

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!" 
      -- AOL CD when played backwards  (User Friendly - 200-10-15)

Re: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Eric Dobbs wrote:

> 
> On Tuesday, September 9, 2003, at 01:26 PM, Eric Pugh wrote:
> 
>> I wanted to add the mock objects because I feel that the cactus 
>> approach to
>> testing, while valuable, is just too darn complex/heavy.  Especially with
>> the number of maven plugins that all have to work simultanously just 
>> to get
>> a single test to work..  I want to add more unit tests in surrounding
>> rundata because it seems like an area that could accidentally break as we
>> move more components in.
> 
> 
> +0 for mock objects instead of cactus (that would be an emphatic +1 if I 
> had
> time to help).  Cactus is complicated.  Mock objects rock.

Though I'm not intimately familiar with the Mock Objects implementation, 
I've used the concept with my own implementations with great success. 
The existing Cactus tests shouldn't be removed, but moving towards a 
simpler system based around Mock Objects makes sense to me.



Re: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Eric Dobbs <er...@dobbse.net>.
On Tuesday, September 9, 2003, at 01:26 PM, Eric Pugh wrote:

> I wanted to add the mock objects because I feel that the cactus 
> approach to
> testing, while valuable, is just too darn complex/heavy.  Especially 
> with
> the number of maven plugins that all have to work simultanously just 
> to get
> a single test to work..  I want to add more unit tests in surrounding
> rundata because it seems like an area that could accidentally break as 
> we
> move more components in.

+0 for mock objects instead of cactus (that would be an emphatic +1 if 
I had
time to help).  Cactus is complicated.  Mock objects rock.

-Eric


RE: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Eric Pugh <ep...@upstate.com>.
I wanted to perform this change mostly as a "see how it goes" change.
Localization seemed like a relatively simple area to make the changes, so if
we zig/zag a bit, it won't mean revamping the code.  What integrating the
localization component suggests to me is that the pull style tools are the
way to gain access to the component when you might want to use it in your
templates.  The various components in fulcrum probably shouldn't have any
dependencies on turbine (unless they are their own turbine component) and
then we access them via pulltools.

I think people should look at what I did and toss out their opinons on the
good/the bad/ and the ugly for this approach.  I will resist the urge to
*improve* wholesale and instead focus on whack all the stuff that can be
pruned.

I wanted to add the mock objects because I feel that the cactus approach to
testing, while valuable, is just too darn complex/heavy.  Especially with
the number of maven plugins that all have to work simultanously just to get
a single test to work..  I want to add more unit tests in surrounding
rundata because it seems like an area that could accidentally break as we
move more components in.

Eric

> -----Original Message-----
> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> Sent: Tuesday, September 09, 2003 6:24 PM
> To: turbine-dev@jakarta.apache.org
> Subject: Re: cvs commit:
> jakarta-turbine-2/src/test/org/apache/turbine/test
> EnhancedMockHttpServletRequest.java
>
>
> epugh@apache.org writes:
>
> This is cool, but IMHO it is still a little early to start doing a big
> architectural upheaval. Things like getting a container properly
> intergrated or shooting at the service broker should preference over
> this. And, IMHO, this isn't really necessary. You can easily add the
> tests and examples to Fulcrum and test with the Turbine-2.3.jar
>
> No need to deprecate services yet. IMHO, it is still a little early.
>
> 	Regards
> 		Henning
>
> >epugh       2003/09/09 08:04:51
>
> >  Modified:    .        project.xml
> >               src/java/org/apache/turbine/services/localization
> >                        TurbineLocalizationService.java
> >                        LocalizationTool.java
> LocalizationService.java
> >                        LocaleTokenizer.java
> >               src/java/org/apache/turbine/services
> >                        InstantiationException.java
> >  Added:       conf/test TestLocalization.properties
> >                        componentLocalizationConfiguration.xml
> >                        roleLocalizationConfiguration.xml
> >               src/test/org/apache/turbine/services/localization
> >                        BarBundle_en_US.java
> LocalizationToolTest.java
> >               src/test/org/apache/turbine/test
> >                        EnhancedMockHttpServletRequest.java
> >  Log:
> >  Deprecated Turbine localization in favor of using the
> Fulcrum Localization service.
> >  the way in is via the LocalizationTool, so if that is all
> you use, it should be pretty
> >  much backwards code compatible.  I added a unit test that
> verifies that the fulcrum
> >  localization service loads up.  The unit test leverages
> mock http objects.  All
> >  jars are on the turbine repo: jakarta.apache.org/turbine/repo.
> >
> >  Revision  Changes    Path
> >  1.139     +19 -0     jakarta-turbine-2/project.xml
> >
> >  Index: project.xml
> >  ===================================================================
> >  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
> >  retrieving revision 1.138
> >  retrieving revision 1.139
> >  diff -u -r1.138 -r1.139
> >  --- project.xml	3 Sep 2003 09:35:47 -0000	1.138
> >  +++ project.xml	9 Sep 2003 15:04:51 -0000	1.139
> >  @@ -398,6 +398,14 @@
> >         <url>http://jakarta.apache.org/avalon/</url>
> >       </dependency>
> >       <dependency>
> >  +      <id>fulcrum-localization</id>
> >  +      <version>1.0-alpha-3</version>
> >  +      <url>http://jakarta.apache.org/turbine/fulcrum/</url>
> >  +      <properties>
> >  +        <war.bundle.jar>true</war.bundle.jar>
> >  +      </properties>
> >  +    </dependency>
> >  +    <dependency>
> >         <id>jaf:activation</id>
> >         <version>1.0.2</version>
> >
> <url>http://java.sun.com/products/javabeans/glasgow/jaf.html</url>
> >  @@ -489,6 +497,17 @@
> >         <version>1.2-b1</version>
> >         <url>http://xml.apache.org/xmlrpc/</url>
> >       </dependency>
> >  +
> >  +    <dependency>
> >  +      <groupId>mockobjects</groupId>
> >  +      <artifactId>mockobjects-jdk1.4-j2ee1.3</artifactId>
> >  +      <version>0.09</version>
> >  +    </dependency>
> >  +    <dependency>
> >  +      <groupId>mockobjects</groupId>
> >  +      <artifactId>mockobjects-core</artifactId>
> >  +      <version>0.09</version>
> >  +    </dependency>
> >     </dependencies>
> >
> >     <build>
> >
> >
> >
> >  1.1
> jakarta-turbine-2/conf/test/TestLocalization.properties
> >
> >  Index: TestLocalization.properties
> >  ===================================================================
> >  #
> -------------------------------------------------------------------
> >  # $Id: TestLocalization.properties,v 1.1 2003/09/09
> 15:04:51 epugh Exp $
> >  #
> >  # This is the configuration file for Turbine.
> >  #
> >  # Note that strings containing "," (comma) characters must
> backslash
> >  # escape the comma (i.e. '\,')
> >  #
> >  #
> -------------------------------------------------------------------
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  L O G 4 J - L O G G I N G
> >  #
> >  #
> -------------------------------------------------------------------
> >
> >  log4j.file = /conf/test/Log4j.properties
> >
> >
> >
> >  # If module.cache=true, then how large should we make the
> hashtables
> >  # by default.
> >
> >  action.cache.size=20
> >  layout.cache.size=10
> >  navigation.cache.size=10
> >  page.cache.size=5
> >  screen.cache.size=50
> >  scheduledjob.cache.size=10
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  M O D U L E  P A C K A G E S
> >  #
> >  #
> -------------------------------------------------------------------
> >  # This is the "classpath" for Turbine.  In order to locate your own
> >  # modules, you should add them to this path.  For example,
> if you have
> >  # com.company.actions, com.company.screens,
> com.company.navigations,
> >  # then this setting would be
> "com.company,org.apache.turbine.modules".
> >  # This path is searched in order.  For example, Turbine
> comes with a
> >  # screen module named "Login".  If you wanted to have your
> own screen
> >  # module named "Login", then you would specify the path to your
> >  # modules before the others.
> >  #
> >  # Note: org.apache.turbine.modules will always be added to
> the search
> >  # path.  If it is not explictly added here, it will be added to the
> >  # end.
> >  #
> >  # Default: org.apache.turbine.modules
> >  #
> -------------------------------------------------------------------
> >
> >  module.packages=@MODULE_PACKAGES@
> >
> >
> >
> >
> services.AvalonComponentService.classname=org.apache.turbine.s
> ervices.avaloncomponent.TurbineAvalonComponentService
> >
> services.CryptoService.classname=org.apache.turbine.services.c
> rypto.TurbineCryptoService
> >
> services.ComponentService.classname=org.apache.turbine.service
> s.component.TurbineComponentService
> >
> services.FactoryService.classname=org.apache.turbine.services.
> factory.TurbineFactoryService
> >
> services.PoolService.classname=org.apache.turbine.services.poo
> l.TurbinePoolService
> >
> services.RunDataService.classname=org.apache.turbine.services.
> rundata.TurbineRunDataService
> >
> services.ServletService.classname=org.apache.turbine.services.
> servlet.TurbineServletService
> >
> services.AssemblerBrokerService.classname=org.apache.turbine.s
> ervices.assemblerbroker.TurbineAssemblerBrokerService
> >
> services.LocalizationService.classname=org.apache.turbine.serv
> ices.localization.TurbineLocalizationService
> >
> services.MimeTypeService.classname=org.apache.turbine.services
> .mimetype.TurbineMimeTypeService
> >
> services.PullService.classname=org.apache.turbine.services.pul
> l.TurbinePullService
> >
> services.TemplateService.classname=org.apache.turbine.services
> .template.TurbineTemplateService
> >
> >
> >
> >
> >
> services.RunDataService.default.run.data=org.apache.turbine.se
> rvices.rundata.DefaultTurbineRunData
> >
> services.RunDataService.default.parameter.parser=org.apache.tu
> rbine.util.parser.DefaultParameterParser
> >
> services.RunDataService.default.cookie.parser=org.apache.turbi
> ne.util.parser.DefaultCookieParser
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  A S S E M B L E R  B R O K E R  S E R V I C E
> >  #
> >  #
> -------------------------------------------------------------------
> >  # A list of AssemblerFactory classes that will be registered
> >  # with TurbineAssemblerBrokerService
> >  #
> -------------------------------------------------------------------
> >
> >
> services.AssemblerBrokerService.screen=org.apache.turbine.serv
> ices.assemblerbroker.util.java.JavaScreenFactory
> >
> #services.AssemblerBrokerService.screen=org.apache.turbine.ser
> vices.assemblerbroker.util.python.PythonScreenFactory
> >
> services.AssemblerBrokerService.action=org.apache.turbine.serv
> ices.assemblerbroker.util.java.JavaActionFactory
> >
> services.AssemblerBrokerService.layout=org.apache.turbine.serv
> ices.assemblerbroker.util.java.JavaLayoutFactory
> >
> services.AssemblerBrokerService.page=org.apache.turbine.servic
> es.assemblerbroker.util.java.JavaPageFactory
> >
> services.AssemblerBrokerService.navigation=org.apache.turbine.
> services.assemblerbroker.util.java.JavaNavigationFactory
> >
> services.AssemblerBrokerService.scheduledjob=org.apache.turbin
> e.services.assemblerbroker.util.java.JavaScheduledJobFactory
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  T E M P L A T E  S E R V I C E
> >  #
> >  #
> -------------------------------------------------------------------
> >
> >  # Roughly, the number of templates in each category.
> >  #
> >  # Defaults: layout=2, navigation=10, screen=50
> >
> >  services.TemplateService.layout.cache.size=2
> >  services.TemplateService.navigation.cache.size=10
> >  services.TemplateService.screen.cache.size=50
> >
> >  services.PullService.earlyInit= true
> >
> >  services.PullService.tools.per.request.refresh=true
> >
> >
> tool.request.l10n=org.apache.turbine.services.localization.Loc
> alizationTool
> >
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  L O C A L I Z A T I O N  S E R V I C E
> >  #
> >  #
> -------------------------------------------------------------------
> >
> >  # Default ResourceBundle and language/country codes used by the
> >  # TurbineLocalizationService.
> >  #
> >  locale.default.bundle=MyBundle
> >  locale.default.language=en
> >  locale.default.country=US
> >
> >  #
> >  # This will set the charset= portion of the ContentType: header.
> >  # Leave commented out unless you want to return stuff as a
> different
> >  # charset.
> >  #
> >  # locale.default.charset=
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  P O O L  S E R V I C E
> >  #
> >  #
> -------------------------------------------------------------------
> >
> >  # Default capacity of pools of the Object pooling service.
> >  #
> >  # Default: 128
> >  services.PoolService.pool.capacity = 128
> >
> >  # Class specific capacities used instead of the default if
> specified.
> >  #
> >
> #services.PoolService.pool.capacity.org.apache.turbine.service
> s.rundata.DefaultTurbineRunData=512
> >
> >  #
> -------------------------------------------------------------------
> >  #
> >  #  F A C T O R Y  S E R V I C E
> >  #
> >  #
> -------------------------------------------------------------------
> >
> >  # A comma separated list of classloaders (very optional)
> >  #
> >  # Example: org.foo.bar.MyClassLoader, org.ack.joe.YourClassLoader
> >  #
> >  #services.FactoryService.class.loaders=
> >
> >  # Customized factories to be used instead of the default factory.
> >  # E.g. to instantiate XML parsers, SSL sockets, etc., which require
> >  # specific instantiation not supported by the default factory.
> >  # The property name is prefixed with "factory" followed by the
> >  # name of the production class. The value is the class name of
> >  # the factory implementing the Factory interface. The factory
> >  # will be instantiated by using the service itself.
> >  #
> >  # Examples:
> >  #
> >  #
> services.FactoryService.factory.javax.xml.parsers.DocumentBuil
> der=org.foo.xml.DomBuilderFactory
> >  #
> services.FactoryService.factory.javax.xml.parsers.SAXParser=or
> g.foo.xml.SaxParserFactory
> >  #
> services.FactoryService.factory.java.net.ServerSocket=org.foo.
> net.SslServerSocketFactory
> >
> >  services.AvalonComponentService.componentConfiguration =
> conf/test/componentLocalizationConfiguration.xml
> >  services.AvalonComponentService.componentRoles =
> conf/test/roleLocalizationConfiguration.xml
> >
> >
> >
> >  1.1
> jakarta-turbine-2/conf/test/componentLocalizationConfiguration.xml
> >
> >  Index: componentLocalizationConfiguration.xml
> >  ===================================================================
> >  <!-- This configuration file for Avalon components is used
> for testing the LocalizationTool pull tool -->
> >
> >  <componentConfig>
> >      <localization>
> >        <bundles>
> >
> <bundle>org.apache.turbine.services.localization.BarBundle</bu
> ndle>
> >        </bundles>
> >      </localization>
> >  </componentConfig>
> >
> >
> >
> >  1.1
> jakarta-turbine-2/conf/test/roleLocalizationConfiguration.xml
> >
> >  Index: roleLocalizationConfiguration.xml
> >  ===================================================================
> >  <!-- This configuration file for Avalon components is used
> for testing the TorqueComponent -->
> >
> >  <role-list>
> >      <role
> >          name="org.apache.fulcrum.localization.LocalizationService"
> >          shorthand="localization"
> >
> default-class="org.apache.fulcrum.localization.DefaultLocaliza
> tionService"/>
> >  </role-list>
> >
> >
> >
> >
> >  1.10      +3 -2
> jakarta-turbine-2/src/java/org/apache/turbine/services/localiz
> ation/TurbineLocalizationService.java
> >
> >  Index: TurbineLocalizationService.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/servic
> es/localization/TurbineLocalizationService.java,v
> >  retrieving revision 1.9
> >  retrieving revision 1.10
> >  diff -u -r1.9 -r1.10
> >  --- TurbineLocalizationService.java	7 Apr 2003
> 15:42:16 -0000	1.9
> >  +++ TurbineLocalizationService.java	9 Sep 2003
> 15:04:51 -0000	1.10
> >  @@ -95,7 +95,8 @@
> >    * <li>getBundle("MyBundleName", Locale)</li>
> >    * <li>etc.</li>
> >    * </ul></p>
> >  - *
> >  + *
> >  + * @deprecated Use the Fulcrum Localization component instead.
> >    * @author <a href="mailto:jm@mediaphil.de">Jonas Maurus</a>
> >    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
> >    * @author <a href="mailto:novalidemail@foo.com">Frank Y. Kim</a>
> >
> >
> >
> >  1.8       +30 -29
> jakarta-turbine-2/src/java/org/apache/turbine/services/localiz
> ation/LocalizationTool.java
> >
> >  Index: LocalizationTool.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/servic
> es/localization/LocalizationTool.java,v
> >  retrieving revision 1.7
> >  retrieving revision 1.8
> >  diff -u -r1.7 -r1.8
> >  --- LocalizationTool.java	9 Mar 2003 03:06:29 -0000	1.7
> >  +++ LocalizationTool.java	9 Sep 2003 15:04:51 -0000	1.8
> >  @@ -1,5 +1,4 @@
> >   package org.apache.turbine.services.localization;
> >  -
> >   /*
> ====================================================================
> >    * The Apache Software License, Version 1.1
> >    *
> >  @@ -53,20 +52,22 @@
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    */
> >  -
> >   import java.util.Locale;
> >   import java.util.MissingResourceException;
> >  -import java.util.ResourceBundle;
> >  -
> >  +import org.apache.turbine.services.InstantiationException;
> >  +import org.apache.avalon.framework.component.ComponentException;
> >   import org.apache.commons.logging.Log;
> >   import org.apache.commons.logging.LogFactory;
> >  +import org.apache.fulcrum.localization.LocalizationService;
> >  +import org.apache.turbine.services.TurbineServices;
> >  +import
> org.apache.turbine.services.avaloncomponent.AvalonComponentService;
> >   import org.apache.turbine.services.pull.ApplicationTool;
> >   import org.apache.turbine.util.RunData;
> >  -
> >   /**
> >    * A pull tool which provides lookups for localized text
> by delegating
> >  - * to the configured <code>LocalizationService</code>.
> >  + * to the configured Fulcrum <code>LocalizationService</code>.
> >    *
> >  + * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
> >    * @author <a href="mailto:jon@collab.net">Jon Stevens</a>
> >    */
> >  @@ -74,23 +75,33 @@
> >   {
> >       /** Logging */
> >       private static Log log =
> LogFactory.getLog(LocalizationTool.class);
> >  -
> >  +    /** Fulcrum Localization component */
> >  +    private LocalizationService localizationService;
> >       /**
> >        * The language and country information parsed from
> the request's
> >        * <code>Accept-Language</code> header.  Reset on
> each request.
> >        */
> >       protected Locale locale;
> >  -
> >  +
> >       /**
> >  -     * The bundle for this request.
> >  +     * Lazy load the LocalizationService.
> >  +     * @return a fulcrum LocalizationService
> >        */
> >  -    private ResourceBundle bundle;
> >  -
> >  -    /**
> >  -     * The name of the bundle for this tool to use.
> >  -     */
> >  -    private String bundleName;
> >  -
> >  +    public LocalizationService getLocalizationService()
> >  +    {
> >  +        if (localizationService == null)
> >  +        {
> >  +            AvalonComponentService acs =
> >  +                (AvalonComponentService)
> TurbineServices.getInstance().getService(AvalonComponentServic
> e.SERVICE_NAME);
> >  +                try {
> >  +            localizationService =
> (LocalizationService)acs.lookup(LocalizationService.ROLE);
> >  +                }
> >  +                catch (ComponentException ce) {
> >  +                    throw new
> InstantiationException("Problem looking up Localization
> Service:"+ce.getMessage());
> >  +                }
> >  +        }
> >  +        return localizationService;
> >  +    }
> >       /**
> >        * Creates a new instance.  Used by <code>PullService</code>.
> >        */
> >  @@ -98,7 +109,6 @@
> >       {
> >           refresh();
> >       }
> >  -
> >       /**
> >        * <p>Performs text lookups for localization.</p>
> >        *
> >  @@ -116,7 +126,7 @@
> >       {
> >           try
> >           {
> >  -            return
> Localization.getString(getBundleName(null), getLocale(), key);
> >  +            return
> getLocalizationService().getString(getBundleName(null),
> getLocale(), key);
> >           }
> >           catch (MissingResourceException noKey)
> >           {
> >  @@ -124,7 +134,6 @@
> >               return null;
> >           }
> >       }
> >  -
> >       /**
> >        * Gets the current locale.
> >        *
> >  @@ -134,7 +143,6 @@
> >       {
> >           return locale;
> >       }
> >  -
> >       /**
> >        * The return value of this method is used to set the
> name of the
> >        * bundle used by this tool.  Useful as a hook for using a
> >  @@ -146,12 +154,9 @@
> >        */
> >       protected String getBundleName(Object data)
> >       {
> >  -        return Localization.getDefaultBundleName();
> >  +        return getLocalizationService().getDefaultBundleName();
> >       }
> >  -
> >  -
> >       // ApplicationTool implmentation
> >  -
> >       /**
> >        * Sets the request to get the
> <code>Accept-Language</code> header
> >        * from (reset on each request).
> >  @@ -162,18 +167,14 @@
> >           {
> >               // Pull necessary information out of RunData
> while we have
> >               // a reference to it.
> >  -            locale = Localization.getLocale(((RunData)
> data).getRequest());
> >  -            bundleName = getBundleName(data);
> >  +            locale =
> getLocalizationService().getLocale(((RunData) data).getRequest());
> >           }
> >       }
> >  -
> >       /**
> >        * No-op.
> >        */
> >       public void refresh()
> >       {
> >           locale = null;
> >  -        bundle = null;
> >  -        bundleName = null;
> >       }
> >   }
> >
> >
> >
> >  1.9       +2 -1
> jakarta-turbine-2/src/java/org/apache/turbine/services/localiz
> ation/LocalizationService.java
> >
> >  Index: LocalizationService.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/servic
> es/localization/LocalizationService.java,v
> >  retrieving revision 1.8
> >  retrieving revision 1.9
> >  diff -u -r1.8 -r1.9
> >  --- LocalizationService.java	7 Apr 2003 15:34:52
> -0000	1.8
> >  +++ LocalizationService.java	9 Sep 2003 15:04:51
> -0000	1.9
> >  @@ -71,6 +71,7 @@
> >    * <a
> href="http://www.math.fu-berlin.de/~rene/www/java/tutorial/i18
> n/message/messageFormat.html">dealing with concatenated messages</a>
> >    * using <code>MessageFormat</code> and properties files.</p>
> >    *
> >  + * @deprecated Use the Fulcrum Localization component instead.
> >    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
> >    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
> >    * @author <a href="mailto:leonardr@collab.net">Leonard
> Richardson</a>
> >
> >
> >
> >  1.4       +3 -2
> jakarta-turbine-2/src/java/org/apache/turbine/services/localiz
> ation/LocaleTokenizer.java
> >
> >  Index: LocaleTokenizer.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/servic
> es/localization/LocaleTokenizer.java,v
> >  retrieving revision 1.3
> >  retrieving revision 1.4
> >  diff -u -r1.3 -r1.4
> >  --- LocaleTokenizer.java	9 Mar 2003 03:06:29 -0000	1.3
> >  +++ LocaleTokenizer.java	9 Sep 2003 15:04:51 -0000	1.4
> >  @@ -64,7 +64,8 @@
> >   /**
> >    * Parses the HTTP <code>Accept-Language</code> header as
> per section
> >    * 14.4 of RFC 2068 (HTTP 1.1 header field definitions).
> >  - *
> >  + *
> >  + * @deprecated Use the Fulcrum Localization component instead.
> >    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
> >    * @version $Id$
> >    */
> >
> >
> >
> >  1.1
> jakarta-turbine-2/src/test/org/apache/turbine/services/localiz
> ation/BarBundle_en_US.java
> >
> >  Index: BarBundle_en_US.java
> >  ===================================================================
> >  package org.apache.turbine.services.localization;
> >
> >  import java.util.ListResourceBundle;
> >
> >  /**
> >   * An english resource bundle for use in testing.
> >   */
> >  public class BarBundle_en_US extends ListResourceBundle
> >  {
> >      private static final Object[][] CONTENTS =
> >      {
> >          { "key1", "value1" },
> >          { "key2", "value2" },
> >          { "key3", "value3" },
> >          { "key4", "value4" }
> >      };
> >
> >      protected Object[][] getContents()
> >      {
> >          return CONTENTS;
> >      }
> >  }
> >
> >
> >
> >  1.1
> jakarta-turbine-2/src/test/org/apache/turbine/services/localiz
> ation/LocalizationToolTest.java
> >
> >  Index: LocalizationToolTest.java
> >  ===================================================================
> >  package org.apache.turbine.services.localization;
> >  /*
> ====================================================================
> >   * The Apache Software License, Version 1.1
> >   *
> >   * Copyright (c) 2001-2003 The Apache Software Foundation.
>  All rights
> >   * reserved.
> >   *
> >   * Redistribution and use in source and binary forms, with
> or without
> >   * modification, are permitted provided that the following
> conditions
> >   * are met:
> >   *
> >   * 1. Redistributions of source code must retain the above
> copyright
> >   *    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 acknowledgment:
> >   *       "This product includes software developed by the
> >   *        Apache Software Foundation (http://www.apache.org/)."
> >   *    Alternately, this acknowledgment may appear in the
> software itself,
> >   *    if and wherever such third-party acknowledgments
> normally appear.
> >   *
> >   * 4. The names "Apache" and "Apache Software Foundation" and
> >   *    "Apache Turbine" must not be used to endorse or
> promote products
> >   *    derived from this software without prior written
> permission. For
> >   *    written permission, please contact apache@apache.org.
> >   *
> >   * 5. Products derived from this software may not be
> called "Apache",
> >   *    "Apache Turbine", nor may "Apache" appear in their
> name, 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
> >   * individuals on behalf of the Apache Software
> Foundation.  For more
> >   * information on the Apache Software Foundation, please see
> >   * <http://www.apache.org/>.
> >   */
> >  import java.util.Vector;
> >  import javax.servlet.ServletConfig;
> >  import javax.servlet.http.HttpServletResponse;
> >  import org.apache.turbine.om.security.User;
> >  import org.apache.turbine.services.TurbineServices;
> >  import org.apache.turbine.services.rundata.RunDataService;
> >  import org.apache.turbine.test.BaseTestCase;
> >  import org.apache.turbine.test.EnhancedMockHttpServletRequest;
> >  import org.apache.turbine.util.RunData;
> >  import org.apache.turbine.util.TurbineConfig;
> >  import com.mockobjects.servlet.MockHttpServletResponse;
> >  import com.mockobjects.servlet.MockHttpSession;
> >  import com.mockobjects.servlet.MockServletConfig;
> >  /**
> >   * Unit test for Localization Tool.  Verifies that
> localization works the same using the
> >   * deprecated Turbine localization service as well as the
> new Fulcrum Localization
> >   * component.
> >   *
> >   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >   * @version $Id: LocalizationToolTest.java,v 1.1
> 2003/09/09 15:04:51 epugh Exp $
> >   */
> >  public class LocalizationToolTest extends BaseTestCase
> >  {
> >      private static TurbineConfig tc = null;
> >      public LocalizationToolTest(String name) throws Exception
> >      {
> >          super(name);
> >      }
> >      public void testGet() throws Exception
> >      {
> >          LocalizationTool lt = new LocalizationTool();
> >          lt.init(getRunData());
> >          assertEquals("value1", lt.get("key1"));
> >          assertEquals("value3", lt.get("key3"));
> >      }
> >      public void testGetLocale() throws Exception
> >      {
> >          LocalizationTool lt = new LocalizationTool();
> >          lt.init(getRunData());
> >          assertNotNull(lt.getLocale());
> >          assertEquals("US", lt.getLocale().getCountry());
> >          assertEquals("en", lt.getLocale().getLanguage());
> >      }
> >      public void testInit() throws Exception
> >      {
> >          LocalizationTool lt = new LocalizationTool();
> >          lt.init(getRunData());
> >          assertNotNull(lt.getLocale());
> >      }
> >      public void testRefresh() throws Exception
> >      {
> >          LocalizationTool lt = new LocalizationTool();
> >          lt.init(getRunData());
> >          assertNotNull(lt.getLocale());
> >          lt.refresh();
> >          assertNull(lt.getLocale());
> >      }
> >      private RunData getRunData() throws Exception
> >      {
> >          RunDataService rds = (RunDataService)
> TurbineServices.getInstance().getService(RunDataService.SERVICE_NAME);
> >          EnhancedMockHttpServletRequest request = new
> EnhancedMockHttpServletRequest();
> >          request.setupServerName("bob");
> >          request.setupGetProtocol("http");
> >          request.setupScheme("scheme");
> >          request.setupPathInfo("damn");
> >          request.setupGetServletPath("damn2");
> >          request.setupGetContextPath("wow");
> >          request.setupGetContentType("html/text");
> >          request.setupAddHeader("Content-type", "html/text");
> >          request.setupAddHeader("Accept-Language", "en-US");
> >          Vector v = new Vector();
> >          request.setupGetParameterNames(v.elements());
> >          MockHttpSession session = new MockHttpSession();
> >          session.setupGetAttribute(User.SESSION_KEY, null);
> >          request.setSession(session);
> >          HttpServletResponse response = new
> MockHttpServletResponse();
> >          ServletConfig config = new MockServletConfig();
> >          RunData runData = rds.getRunData(request,
> response, config);
> >          return runData;
> >      }
> >      public void setUp() throws Exception
> >      {
> >          tc = new TurbineConfig(".",
> "/conf/test/TestLocalization.properties");
> >          tc.initialize();
> >      }
> >      public void tearDown() throws Exception
> >      {
> >          if (tc != null)
> >          {
> >              tc.dispose();
> >          }
> >      }
> >  }
> >
> >
> >
> >  1.6       +3 -1
> jakarta-turbine-2/src/java/org/apache/turbine/services/Instant
> iationException.java
> >
> >  Index: InstantiationException.java
> >  ===================================================================
> >  RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/servic
> es/InstantiationException.java,v
> >  retrieving revision 1.5
> >  retrieving revision 1.6
> >  diff -u -r1.5 -r1.6
> >  --- InstantiationException.java	7 Apr 2003 15:30:48
> -0000	1.5
> >  +++ InstantiationException.java	9 Sep 2003 15:04:51
> -0000	1.6
> >  @@ -60,6 +60,8 @@
> >    * Thrown by <code>InitableBroker</code> and
> >    * <code>ServiceBroker</code> classes to indicate problems with
> >    * instatiation of requested objects.
> >  + *
> >  + * Make sure you don't confuse this exception with the
> java.lang.InstantiationException.
> >    *
> >    * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
> >    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
> >
> >
> >
> >  1.1
> jakarta-turbine-2/src/test/org/apache/turbine/test/EnhancedMoc
> kHttpServletRequest.java
> >
> >  Index: EnhancedMockHttpServletRequest.java
> >  ===================================================================
> >  package org.apache.turbine.test;
> >  /*
> ====================================================================
> >   * The Apache Software License, Version 1.1
> >   *
> >   * Copyright (c) 2001-2002 The Apache Software Foundation.
>  All rights
> >   * reserved.
> >   *
> >   * Redistribution and use in source and binary forms, with
> or without
> >   * modification, are permitted provided that the following
> conditions
> >   * are met:
> >   *
> >   * 1. Redistributions of source code must retain the above
> copyright
> >   *    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 acknowledgment:
> >   *       "This product includes software developed by the
> >   *        Apache Software Foundation (http://www.apache.org/)."
> >   *    Alternately, this acknowledgment may appear in the
> software itself,
> >   *    if and wherever such third-party acknowledgments
> normally appear.
> >   *
> >   * 4. The names "Apache" and "Apache Software Foundation" and
> >   *    "Apache Turbine" must not be used to endorse or
> promote products
> >   *    derived from this software without prior written
> permission. For
> >   *    written permission, please contact apache@apache.org.
> >   *
> >   * 5. Products derived from this software may not be
> called "Apache",
> >   *    "Apache Turbine", nor may "Apache" appear in their
> name, 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
> >   * individuals on behalf of the Apache Software
> Foundation.  For more
> >   * information on the Apache Software Foundation, please see
> >   * <http://www.apache.org/>.
> >   */
> >
> >  import com.mockobjects.servlet.MockHttpServletRequest;
> >
> >  /**
> >   * Extension to the basic MockHttpServletRequest to
> provide some extra parameters
> >   * required by Turbine.
> >   *
> >   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
> >   * @version $Id: EnhancedMockHttpServletRequest.java,v 1.1
> 2003/09/09 15:04:51 epugh Exp $
> >   */
> >  public class EnhancedMockHttpServletRequest extends
> MockHttpServletRequest
> >  {
> >      /**
> >       *
> >       */
> >      public EnhancedMockHttpServletRequest()
> >      {
> >          super();
> >          // TODO Auto-generated constructor stub
> >      }
> >      public int getServerPort(){
> >        return 8080;
> >      }
> >
> >      public String getCharacterEncoding(){
> >      return "US-ASCII";
> >      }
> >
> >  }
> >
> >
> >
>
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>
> Java, perl, Solaris, Linux, xSP Consulting, Web Services
> freelance consultant -- Jakarta Turbine Development  -- hero for hire
>
> "Dominate!! Dominate!! Eat your young and aggregate! I have
> grotty silicon!"
>       -- AOL CD when played backwards  (User Friendly - 200-10-15)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
epugh@apache.org writes:

This is cool, but IMHO it is still a little early to start doing a big
architectural upheaval. Things like getting a container properly
intergrated or shooting at the service broker should preference over
this. And, IMHO, this isn't really necessary. You can easily add the
tests and examples to Fulcrum and test with the Turbine-2.3.jar

No need to deprecate services yet. IMHO, it is still a little early.

	Regards
		Henning

>epugh       2003/09/09 08:04:51

>  Modified:    .        project.xml
>               src/java/org/apache/turbine/services/localization
>                        TurbineLocalizationService.java
>                        LocalizationTool.java LocalizationService.java
>                        LocaleTokenizer.java
>               src/java/org/apache/turbine/services
>                        InstantiationException.java
>  Added:       conf/test TestLocalization.properties
>                        componentLocalizationConfiguration.xml
>                        roleLocalizationConfiguration.xml
>               src/test/org/apache/turbine/services/localization
>                        BarBundle_en_US.java LocalizationToolTest.java
>               src/test/org/apache/turbine/test
>                        EnhancedMockHttpServletRequest.java
>  Log:
>  Deprecated Turbine localization in favor of using the Fulcrum Localization service.
>  the way in is via the LocalizationTool, so if that is all you use, it should be pretty
>  much backwards code compatible.  I added a unit test that verifies that the fulcrum
>  localization service loads up.  The unit test leverages mock http objects.  All 
>  jars are on the turbine repo: jakarta.apache.org/turbine/repo.
>  
>  Revision  Changes    Path
>  1.139     +19 -0     jakarta-turbine-2/project.xml
>  
>  Index: project.xml
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
>  retrieving revision 1.138
>  retrieving revision 1.139
>  diff -u -r1.138 -r1.139
>  --- project.xml	3 Sep 2003 09:35:47 -0000	1.138
>  +++ project.xml	9 Sep 2003 15:04:51 -0000	1.139
>  @@ -398,6 +398,14 @@
>         <url>http://jakarta.apache.org/avalon/</url>
>       </dependency>
>       <dependency>
>  +      <id>fulcrum-localization</id>
>  +      <version>1.0-alpha-3</version>
>  +      <url>http://jakarta.apache.org/turbine/fulcrum/</url>
>  +      <properties>
>  +        <war.bundle.jar>true</war.bundle.jar>
>  +      </properties>
>  +    </dependency>    
>  +    <dependency>
>         <id>jaf:activation</id>
>         <version>1.0.2</version>
>         <url>http://java.sun.com/products/javabeans/glasgow/jaf.html</url>
>  @@ -489,6 +497,17 @@
>         <version>1.2-b1</version>
>         <url>http://xml.apache.org/xmlrpc/</url>
>       </dependency>
>  +    
>  +    <dependency>
>  +      <groupId>mockobjects</groupId>
>  +      <artifactId>mockobjects-jdk1.4-j2ee1.3</artifactId>
>  +      <version>0.09</version>
>  +    </dependency> 
>  +    <dependency>
>  +      <groupId>mockobjects</groupId>
>  +      <artifactId>mockobjects-core</artifactId>
>  +      <version>0.09</version>
>  +    </dependency>     
>     </dependencies>
>   
>     <build>
>  
>  
>  
>  1.1                  jakarta-turbine-2/conf/test/TestLocalization.properties
>  
>  Index: TestLocalization.properties
>  ===================================================================
>  # -------------------------------------------------------------------
>  # $Id: TestLocalization.properties,v 1.1 2003/09/09 15:04:51 epugh Exp $
>  #
>  # This is the configuration file for Turbine.
>  #
>  # Note that strings containing "," (comma) characters must backslash
>  # escape the comma (i.e. '\,')
>  #
>  # -------------------------------------------------------------------
>  
>  # -------------------------------------------------------------------
>  #
>  #  L O G 4 J - L O G G I N G
>  #
>  # -------------------------------------------------------------------
>  
>  log4j.file = /conf/test/Log4j.properties
>  
>  
>  
>  # If module.cache=true, then how large should we make the hashtables
>  # by default.
>  
>  action.cache.size=20
>  layout.cache.size=10
>  navigation.cache.size=10
>  page.cache.size=5
>  screen.cache.size=50
>  scheduledjob.cache.size=10
>  
>  # -------------------------------------------------------------------
>  #
>  #  M O D U L E  P A C K A G E S
>  #
>  # -------------------------------------------------------------------
>  # This is the "classpath" for Turbine.  In order to locate your own
>  # modules, you should add them to this path.  For example, if you have
>  # com.company.actions, com.company.screens, com.company.navigations,
>  # then this setting would be "com.company,org.apache.turbine.modules".
>  # This path is searched in order.  For example, Turbine comes with a
>  # screen module named "Login".  If you wanted to have your own screen
>  # module named "Login", then you would specify the path to your
>  # modules before the others.
>  #
>  # Note: org.apache.turbine.modules will always be added to the search
>  # path.  If it is not explictly added here, it will be added to the
>  # end.
>  #
>  # Default: org.apache.turbine.modules
>  # -------------------------------------------------------------------
>  
>  module.packages=@MODULE_PACKAGES@
>  
>  
>  
>  services.AvalonComponentService.classname=org.apache.turbine.services.avaloncomponent.TurbineAvalonComponentService
>  services.CryptoService.classname=org.apache.turbine.services.crypto.TurbineCryptoService
>  services.ComponentService.classname=org.apache.turbine.services.component.TurbineComponentService
>  services.FactoryService.classname=org.apache.turbine.services.factory.TurbineFactoryService
>  services.PoolService.classname=org.apache.turbine.services.pool.TurbinePoolService
>  services.RunDataService.classname=org.apache.turbine.services.rundata.TurbineRunDataService
>  services.ServletService.classname=org.apache.turbine.services.servlet.TurbineServletService
>  services.AssemblerBrokerService.classname=org.apache.turbine.services.assemblerbroker.TurbineAssemblerBrokerService
>  services.LocalizationService.classname=org.apache.turbine.services.localization.TurbineLocalizationService
>  services.MimeTypeService.classname=org.apache.turbine.services.mimetype.TurbineMimeTypeService
>  services.PullService.classname=org.apache.turbine.services.pull.TurbinePullService
>  services.TemplateService.classname=org.apache.turbine.services.template.TurbineTemplateService
>  
>  
>  
>  
>  services.RunDataService.default.run.data=org.apache.turbine.services.rundata.DefaultTurbineRunData
>  services.RunDataService.default.parameter.parser=org.apache.turbine.util.parser.DefaultParameterParser
>  services.RunDataService.default.cookie.parser=org.apache.turbine.util.parser.DefaultCookieParser
>  
>  # -------------------------------------------------------------------
>  #
>  #  A S S E M B L E R  B R O K E R  S E R V I C E
>  #
>  # -------------------------------------------------------------------
>  # A list of AssemblerFactory classes that will be registered
>  # with TurbineAssemblerBrokerService
>  # -------------------------------------------------------------------
>  
>  services.AssemblerBrokerService.screen=org.apache.turbine.services.assemblerbroker.util.java.JavaScreenFactory
>  #services.AssemblerBrokerService.screen=org.apache.turbine.services.assemblerbroker.util.python.PythonScreenFactory
>  services.AssemblerBrokerService.action=org.apache.turbine.services.assemblerbroker.util.java.JavaActionFactory
>  services.AssemblerBrokerService.layout=org.apache.turbine.services.assemblerbroker.util.java.JavaLayoutFactory
>  services.AssemblerBrokerService.page=org.apache.turbine.services.assemblerbroker.util.java.JavaPageFactory
>  services.AssemblerBrokerService.navigation=org.apache.turbine.services.assemblerbroker.util.java.JavaNavigationFactory
>  services.AssemblerBrokerService.scheduledjob=org.apache.turbine.services.assemblerbroker.util.java.JavaScheduledJobFactory
>  
>  # -------------------------------------------------------------------
>  #
>  #  T E M P L A T E  S E R V I C E
>  #
>  # -------------------------------------------------------------------
>  
>  # Roughly, the number of templates in each category.
>  #
>  # Defaults: layout=2, navigation=10, screen=50
>  
>  services.TemplateService.layout.cache.size=2
>  services.TemplateService.navigation.cache.size=10
>  services.TemplateService.screen.cache.size=50
>  
>  services.PullService.earlyInit= true
>  
>  services.PullService.tools.per.request.refresh=true
>  
>  tool.request.l10n=org.apache.turbine.services.localization.LocalizationTool
>  
>  
>  # -------------------------------------------------------------------
>  #
>  #  L O C A L I Z A T I O N  S E R V I C E
>  #
>  # -------------------------------------------------------------------
>  
>  # Default ResourceBundle and language/country codes used by the
>  # TurbineLocalizationService.
>  #
>  locale.default.bundle=MyBundle
>  locale.default.language=en
>  locale.default.country=US
>  
>  #
>  # This will set the charset= portion of the ContentType: header.
>  # Leave commented out unless you want to return stuff as a different
>  # charset.
>  #
>  # locale.default.charset=
>  
>  # -------------------------------------------------------------------
>  #
>  #  P O O L  S E R V I C E
>  #
>  # -------------------------------------------------------------------
>  
>  # Default capacity of pools of the Object pooling service.
>  #
>  # Default: 128
>  services.PoolService.pool.capacity = 128
>  
>  # Class specific capacities used instead of the default if specified.
>  #
>  #services.PoolService.pool.capacity.org.apache.turbine.services.rundata.DefaultTurbineRunData=512
>  
>  # -------------------------------------------------------------------
>  #
>  #  F A C T O R Y  S E R V I C E
>  #
>  # -------------------------------------------------------------------
>  
>  # A comma separated list of classloaders (very optional)
>  #
>  # Example: org.foo.bar.MyClassLoader, org.ack.joe.YourClassLoader
>  #
>  #services.FactoryService.class.loaders=
>  
>  # Customized factories to be used instead of the default factory.
>  # E.g. to instantiate XML parsers, SSL sockets, etc., which require
>  # specific instantiation not supported by the default factory.
>  # The property name is prefixed with "factory" followed by the
>  # name of the production class. The value is the class name of
>  # the factory implementing the Factory interface. The factory
>  # will be instantiated by using the service itself.
>  #
>  # Examples:
>  #
>  # services.FactoryService.factory.javax.xml.parsers.DocumentBuilder=org.foo.xml.DomBuilderFactory
>  # services.FactoryService.factory.javax.xml.parsers.SAXParser=org.foo.xml.SaxParserFactory
>  # services.FactoryService.factory.java.net.ServerSocket=org.foo.net.SslServerSocketFactory
>  
>  services.AvalonComponentService.componentConfiguration = conf/test/componentLocalizationConfiguration.xml
>  services.AvalonComponentService.componentRoles = conf/test/roleLocalizationConfiguration.xml
>  
>  
>  
>  1.1                  jakarta-turbine-2/conf/test/componentLocalizationConfiguration.xml
>  
>  Index: componentLocalizationConfiguration.xml
>  ===================================================================
>  <!-- This configuration file for Avalon components is used for testing the LocalizationTool pull tool -->
>  
>  <componentConfig>
>      <localization>
>        <bundles>
>          <bundle>org.apache.turbine.services.localization.BarBundle</bundle>     
>        </bundles>
>      </localization>
>  </componentConfig>
>  
>  
>  
>  1.1                  jakarta-turbine-2/conf/test/roleLocalizationConfiguration.xml
>  
>  Index: roleLocalizationConfiguration.xml
>  ===================================================================
>  <!-- This configuration file for Avalon components is used for testing the TorqueComponent -->
>  
>  <role-list>
>      <role
>          name="org.apache.fulcrum.localization.LocalizationService"
>          shorthand="localization"
>          default-class="org.apache.fulcrum.localization.DefaultLocalizationService"/>
>  </role-list>
>  
>  
>  
>  
>  1.10      +3 -2      jakarta-turbine-2/src/java/org/apache/turbine/services/localization/TurbineLocalizationService.java
>  
>  Index: TurbineLocalizationService.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/TurbineLocalizationService.java,v
>  retrieving revision 1.9
>  retrieving revision 1.10
>  diff -u -r1.9 -r1.10
>  --- TurbineLocalizationService.java	7 Apr 2003 15:42:16 -0000	1.9
>  +++ TurbineLocalizationService.java	9 Sep 2003 15:04:51 -0000	1.10
>  @@ -95,7 +95,8 @@
>    * <li>getBundle("MyBundleName", Locale)</li>
>    * <li>etc.</li>
>    * </ul></p>
>  - *
>  + * 
>  + * @deprecated Use the Fulcrum Localization component instead.
>    * @author <a href="mailto:jm@mediaphil.de">Jonas Maurus</a>
>    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
>    * @author <a href="mailto:novalidemail@foo.com">Frank Y. Kim</a>
>  
>  
>  
>  1.8       +30 -29    jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationTool.java
>  
>  Index: LocalizationTool.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationTool.java,v
>  retrieving revision 1.7
>  retrieving revision 1.8
>  diff -u -r1.7 -r1.8
>  --- LocalizationTool.java	9 Mar 2003 03:06:29 -0000	1.7
>  +++ LocalizationTool.java	9 Sep 2003 15:04:51 -0000	1.8
>  @@ -1,5 +1,4 @@
>   package org.apache.turbine.services.localization;
>  -
>   /* ====================================================================
>    * The Apache Software License, Version 1.1
>    *
>  @@ -53,20 +52,22 @@
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    */
>  -
>   import java.util.Locale;
>   import java.util.MissingResourceException;
>  -import java.util.ResourceBundle;
>  -
>  +import org.apache.turbine.services.InstantiationException;
>  +import org.apache.avalon.framework.component.ComponentException;
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
>  +import org.apache.fulcrum.localization.LocalizationService;
>  +import org.apache.turbine.services.TurbineServices;
>  +import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
>   import org.apache.turbine.services.pull.ApplicationTool;
>   import org.apache.turbine.util.RunData;
>  -
>   /**
>    * A pull tool which provides lookups for localized text by delegating
>  - * to the configured <code>LocalizationService</code>.
>  + * to the configured Fulcrum <code>LocalizationService</code>.
>    *
>  + * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
>    * @author <a href="mailto:jon@collab.net">Jon Stevens</a>
>    */
>  @@ -74,23 +75,33 @@
>   {
>       /** Logging */
>       private static Log log = LogFactory.getLog(LocalizationTool.class);
>  -
>  +    /** Fulcrum Localization component */
>  +    private LocalizationService localizationService;
>       /**
>        * The language and country information parsed from the request's
>        * <code>Accept-Language</code> header.  Reset on each request.
>        */
>       protected Locale locale;
>  -
>  +    
>       /**
>  -     * The bundle for this request.
>  +     * Lazy load the LocalizationService.
>  +     * @return a fulcrum LocalizationService
>        */
>  -    private ResourceBundle bundle;
>  -
>  -    /**
>  -     * The name of the bundle for this tool to use.
>  -     */
>  -    private String bundleName;
>  -
>  +    public LocalizationService getLocalizationService()
>  +    {
>  +        if (localizationService == null)
>  +        {
>  +            AvalonComponentService acs =
>  +                (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
>  +                try {
>  +            localizationService = (LocalizationService)acs.lookup(LocalizationService.ROLE);
>  +                }
>  +                catch (ComponentException ce) {
>  +                    throw new InstantiationException("Problem looking up Localization Service:"+ce.getMessage());
>  +                }
>  +        }
>  +        return localizationService;
>  +    }
>       /**
>        * Creates a new instance.  Used by <code>PullService</code>.
>        */
>  @@ -98,7 +109,6 @@
>       {
>           refresh();
>       }
>  -
>       /**
>        * <p>Performs text lookups for localization.</p>
>        *
>  @@ -116,7 +126,7 @@
>       {
>           try
>           {
>  -            return Localization.getString(getBundleName(null), getLocale(), key);
>  +            return getLocalizationService().getString(getBundleName(null), getLocale(), key);
>           }
>           catch (MissingResourceException noKey)
>           {
>  @@ -124,7 +134,6 @@
>               return null;
>           }
>       }
>  -
>       /**
>        * Gets the current locale.
>        *
>  @@ -134,7 +143,6 @@
>       {
>           return locale;
>       }
>  -
>       /**
>        * The return value of this method is used to set the name of the
>        * bundle used by this tool.  Useful as a hook for using a
>  @@ -146,12 +154,9 @@
>        */
>       protected String getBundleName(Object data)
>       {
>  -        return Localization.getDefaultBundleName();
>  +        return getLocalizationService().getDefaultBundleName();
>       }
>  -
>  -
>       // ApplicationTool implmentation
>  -
>       /**
>        * Sets the request to get the <code>Accept-Language</code> header
>        * from (reset on each request).
>  @@ -162,18 +167,14 @@
>           {
>               // Pull necessary information out of RunData while we have
>               // a reference to it.
>  -            locale = Localization.getLocale(((RunData) data).getRequest());
>  -            bundleName = getBundleName(data);
>  +            locale = getLocalizationService().getLocale(((RunData) data).getRequest());
>           }
>       }
>  -
>       /**
>        * No-op.
>        */
>       public void refresh()
>       {
>           locale = null;
>  -        bundle = null;
>  -        bundleName = null;
>       }
>   }
>  
>  
>  
>  1.9       +2 -1      jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationService.java
>  
>  Index: LocalizationService.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationService.java,v
>  retrieving revision 1.8
>  retrieving revision 1.9
>  diff -u -r1.8 -r1.9
>  --- LocalizationService.java	7 Apr 2003 15:34:52 -0000	1.8
>  +++ LocalizationService.java	9 Sep 2003 15:04:51 -0000	1.9
>  @@ -71,6 +71,7 @@
>    * <a href="http://www.math.fu-berlin.de/~rene/www/java/tutorial/i18n/message/messageFormat.html">dealing with concatenated messages</a>
>    * using <code>MessageFormat</code> and properties files.</p>
>    *
>  + * @deprecated Use the Fulcrum Localization component instead.
>    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
>    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
>    * @author <a href="mailto:leonardr@collab.net">Leonard Richardson</a>
>  
>  
>  
>  1.4       +3 -2      jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocaleTokenizer.java
>  
>  Index: LocaleTokenizer.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocaleTokenizer.java,v
>  retrieving revision 1.3
>  retrieving revision 1.4
>  diff -u -r1.3 -r1.4
>  --- LocaleTokenizer.java	9 Mar 2003 03:06:29 -0000	1.3
>  +++ LocaleTokenizer.java	9 Sep 2003 15:04:51 -0000	1.4
>  @@ -64,7 +64,8 @@
>   /**
>    * Parses the HTTP <code>Accept-Language</code> header as per section
>    * 14.4 of RFC 2068 (HTTP 1.1 header field definitions).
>  - *
>  + * 
>  + * @deprecated Use the Fulcrum Localization component instead.
>    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
>    * @version $Id$
>    */
>  
>  
>  
>  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/services/localization/BarBundle_en_US.java
>  
>  Index: BarBundle_en_US.java
>  ===================================================================
>  package org.apache.turbine.services.localization;
>  
>  import java.util.ListResourceBundle;
>  
>  /**
>   * An english resource bundle for use in testing.
>   */
>  public class BarBundle_en_US extends ListResourceBundle
>  {
>      private static final Object[][] CONTENTS =
>      {
>          { "key1", "value1" },
>          { "key2", "value2" },
>          { "key3", "value3" },
>          { "key4", "value4" }
>      };
>  
>      protected Object[][] getContents()
>      {
>          return CONTENTS;
>      }
>  }
>  
>  
>  
>  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/services/localization/LocalizationToolTest.java
>  
>  Index: LocalizationToolTest.java
>  ===================================================================
>  package org.apache.turbine.services.localization;
>  /* ====================================================================
>   * The Apache Software License, Version 1.1
>   *
>   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
>   * reserved.
>   *
>   * Redistribution and use in source and binary forms, with or without
>   * modification, are permitted provided that the following conditions
>   * are met:
>   *
>   * 1. Redistributions of source code must retain the above copyright
>   *    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 acknowledgment:
>   *       "This product includes software developed by the
>   *        Apache Software Foundation (http://www.apache.org/)."
>   *    Alternately, this acknowledgment may appear in the software itself,
>   *    if and wherever such third-party acknowledgments normally appear.
>   *
>   * 4. The names "Apache" and "Apache Software Foundation" and
>   *    "Apache Turbine" must not be used to endorse or promote products
>   *    derived from this software without prior written permission. For
>   *    written permission, please contact apache@apache.org.
>   *
>   * 5. Products derived from this software may not be called "Apache",
>   *    "Apache Turbine", nor may "Apache" appear in their name, 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
>   * individuals on behalf of the Apache Software Foundation.  For more
>   * information on the Apache Software Foundation, please see
>   * <http://www.apache.org/>.
>   */
>  import java.util.Vector;
>  import javax.servlet.ServletConfig;
>  import javax.servlet.http.HttpServletResponse;
>  import org.apache.turbine.om.security.User;
>  import org.apache.turbine.services.TurbineServices;
>  import org.apache.turbine.services.rundata.RunDataService;
>  import org.apache.turbine.test.BaseTestCase;
>  import org.apache.turbine.test.EnhancedMockHttpServletRequest;
>  import org.apache.turbine.util.RunData;
>  import org.apache.turbine.util.TurbineConfig;
>  import com.mockobjects.servlet.MockHttpServletResponse;
>  import com.mockobjects.servlet.MockHttpSession;
>  import com.mockobjects.servlet.MockServletConfig;
>  /**
>   * Unit test for Localization Tool.  Verifies that localization works the same using the
>   * deprecated Turbine localization service as well as the new Fulcrum Localization
>   * component.
>   *
>   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>   * @version $Id: LocalizationToolTest.java,v 1.1 2003/09/09 15:04:51 epugh Exp $
>   */
>  public class LocalizationToolTest extends BaseTestCase
>  {
>      private static TurbineConfig tc = null;
>      public LocalizationToolTest(String name) throws Exception
>      {
>          super(name);
>      }
>      public void testGet() throws Exception
>      {
>          LocalizationTool lt = new LocalizationTool();
>          lt.init(getRunData());
>          assertEquals("value1", lt.get("key1"));
>          assertEquals("value3", lt.get("key3"));
>      }
>      public void testGetLocale() throws Exception
>      {
>          LocalizationTool lt = new LocalizationTool();
>          lt.init(getRunData());
>          assertNotNull(lt.getLocale());
>          assertEquals("US", lt.getLocale().getCountry());
>          assertEquals("en", lt.getLocale().getLanguage());
>      }
>      public void testInit() throws Exception
>      {
>          LocalizationTool lt = new LocalizationTool();
>          lt.init(getRunData());
>          assertNotNull(lt.getLocale());
>      }
>      public void testRefresh() throws Exception
>      {
>          LocalizationTool lt = new LocalizationTool();
>          lt.init(getRunData());
>          assertNotNull(lt.getLocale());
>          lt.refresh();
>          assertNull(lt.getLocale());
>      }
>      private RunData getRunData() throws Exception
>      {
>          RunDataService rds = (RunDataService) TurbineServices.getInstance().getService(RunDataService.SERVICE_NAME);
>          EnhancedMockHttpServletRequest request = new EnhancedMockHttpServletRequest();
>          request.setupServerName("bob");
>          request.setupGetProtocol("http");
>          request.setupScheme("scheme");
>          request.setupPathInfo("damn");
>          request.setupGetServletPath("damn2");
>          request.setupGetContextPath("wow");
>          request.setupGetContentType("html/text");
>          request.setupAddHeader("Content-type", "html/text");
>          request.setupAddHeader("Accept-Language", "en-US");
>          Vector v = new Vector();
>          request.setupGetParameterNames(v.elements());
>          MockHttpSession session = new MockHttpSession();
>          session.setupGetAttribute(User.SESSION_KEY, null);
>          request.setSession(session);
>          HttpServletResponse response = new MockHttpServletResponse();
>          ServletConfig config = new MockServletConfig();
>          RunData runData = rds.getRunData(request, response, config);
>          return runData;
>      }
>      public void setUp() throws Exception
>      {
>          tc = new TurbineConfig(".", "/conf/test/TestLocalization.properties");
>          tc.initialize();
>      }
>      public void tearDown() throws Exception
>      {
>          if (tc != null)
>          {
>              tc.dispose();
>          }
>      }
>  }
>  
>  
>  
>  1.6       +3 -1      jakarta-turbine-2/src/java/org/apache/turbine/services/InstantiationException.java
>  
>  Index: InstantiationException.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/InstantiationException.java,v
>  retrieving revision 1.5
>  retrieving revision 1.6
>  diff -u -r1.5 -r1.6
>  --- InstantiationException.java	7 Apr 2003 15:30:48 -0000	1.5
>  +++ InstantiationException.java	9 Sep 2003 15:04:51 -0000	1.6
>  @@ -60,6 +60,8 @@
>    * Thrown by <code>InitableBroker</code> and
>    * <code>ServiceBroker</code> classes to indicate problems with
>    * instatiation of requested objects.
>  + * 
>  + * Make sure you don't confuse this exception with the java.lang.InstantiationException.
>    *
>    * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
>    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
>  
>  
>  
>  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/test/EnhancedMockHttpServletRequest.java
>  
>  Index: EnhancedMockHttpServletRequest.java
>  ===================================================================
>  package org.apache.turbine.test;
>  /* ====================================================================
>   * The Apache Software License, Version 1.1
>   *
>   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
>   * reserved.
>   *
>   * Redistribution and use in source and binary forms, with or without
>   * modification, are permitted provided that the following conditions
>   * are met:
>   *
>   * 1. Redistributions of source code must retain the above copyright
>   *    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 acknowledgment:
>   *       "This product includes software developed by the
>   *        Apache Software Foundation (http://www.apache.org/)."
>   *    Alternately, this acknowledgment may appear in the software itself,
>   *    if and wherever such third-party acknowledgments normally appear.
>   *
>   * 4. The names "Apache" and "Apache Software Foundation" and
>   *    "Apache Turbine" must not be used to endorse or promote products
>   *    derived from this software without prior written permission. For
>   *    written permission, please contact apache@apache.org.
>   *
>   * 5. Products derived from this software may not be called "Apache",
>   *    "Apache Turbine", nor may "Apache" appear in their name, 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
>   * individuals on behalf of the Apache Software Foundation.  For more
>   * information on the Apache Software Foundation, please see
>   * <http://www.apache.org/>.
>   */
>  
>  import com.mockobjects.servlet.MockHttpServletRequest;
>  
>  /**
>   * Extension to the basic MockHttpServletRequest to provide some extra parameters
>   * required by Turbine.
>   *
>   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
>   * @version $Id: EnhancedMockHttpServletRequest.java,v 1.1 2003/09/09 15:04:51 epugh Exp $
>   */
>  public class EnhancedMockHttpServletRequest extends MockHttpServletRequest
>  {
>      /**
>       *
>       */
>      public EnhancedMockHttpServletRequest()
>      {
>          super();
>          // TODO Auto-generated constructor stub
>      }
>      public int getServerPort(){
>        return 8080;
>      }
>  
>      public String getCharacterEncoding(){
>      return "US-ASCII";
>      }
>  
>  }
>  
>  
>  

>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!" 
      -- AOL CD when played backwards  (User Friendly - 200-10-15)

RE: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Eric Pugh <ep...@upstate.com>.
Sure, in fact I would rather do that, then have all these stinkin
fulcrum-xxx folders!

The reason I didn't was when I run the multiproject build, it installs all
of them in repo/fulcrum-localization.  How can I tell it to instead install
it in repo/fulcrum/?

Eric Pugh

> -----Original Message-----
> From: Martin Poeschl [mailto:mpoeschl@marmot.at]
> Sent: Tuesday, September 09, 2003 6:26 PM
> To: Turbine Developers List
> Subject: Re: cvs commit:
> jakarta-turbine-2/src/test/org/apache/turbine/test
> EnhancedMockHttpServletRequest.java
>
>
> could we change this to groupId=fulcrum artifact=localization
>
> martin
>
> epugh@apache.org wrote:
>
> >epugh       2003/09/09 08:04:51
> >
> >  Modified:    .        project.xml
> >
> >  Index: project.xml
> >  ===================================================================
> >  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
> >  retrieving revision 1.138
> >  retrieving revision 1.139
> >  diff -u -r1.138 -r1.139
> >  --- project.xml	3 Sep 2003 09:35:47 -0000	1.138
> >  +++ project.xml	9 Sep 2003 15:04:51 -0000	1.139
> >  @@ -398,6 +398,14 @@
> >         <url>http://jakarta.apache.org/avalon/</url>
> >       </dependency>
> >       <dependency>
> >  +      <id>fulcrum-localization</id>
> >  +      <version>1.0-alpha-3</version>
> >  +      <url>http://jakarta.apache.org/turbine/fulcrum/</url>
> >  +      <properties>
> >  +        <war.bundle.jar>true</war.bundle.jar>
> >  +      </properties>
> >  +    </dependency>
> >  +    <dependency>
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/test EnhancedMockHttpServletRequest.java

Posted by Martin Poeschl <mp...@marmot.at>.
could we change this to groupId=fulcrum artifact=localization

martin

epugh@apache.org wrote:

>epugh       2003/09/09 08:04:51
>
>  Modified:    .        project.xml
>   
>  Index: project.xml
>  ===================================================================
>  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
>  retrieving revision 1.138
>  retrieving revision 1.139
>  diff -u -r1.138 -r1.139
>  --- project.xml	3 Sep 2003 09:35:47 -0000	1.138
>  +++ project.xml	9 Sep 2003 15:04:51 -0000	1.139
>  @@ -398,6 +398,14 @@
>         <url>http://jakarta.apache.org/avalon/</url>
>       </dependency>
>       <dependency>
>  +      <id>fulcrum-localization</id>
>  +      <version>1.0-alpha-3</version>
>  +      <url>http://jakarta.apache.org/turbine/fulcrum/</url>
>  +      <properties>
>  +        <war.bundle.jar>true</war.bundle.jar>
>  +      </properties>
>  +    </dependency>    
>  +    <dependency>
>