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/10/24 14:50:58 UTC

cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/services/cache FulcrumCacheComponent.java

epugh       2003/10/24 05:50:58

  Modified:    .        project.xml
  Added:       conf/test fulcrumRoleConfiguration.xml
                        fulcrumComponentConfiguration.xml
                        TestFulcrumComponents.properties
               src/test/org/apache/turbine/services/mimetype
                        FulcrumMimetypeComponent.java
               src/test/org/apache/turbine/services/cache
                        FulcrumCacheComponent.java
  Log:
  Add Unit tests for new fulcrum components loading in Turbine.
  
  Revision  Changes    Path
  1.141     +35 -2     jakarta-turbine-2/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
  retrieving revision 1.140
  retrieving revision 1.141
  diff -u -r1.140 -r1.141
  --- project.xml	14 Oct 2003 12:17:26 -0000	1.140
  +++ project.xml	24 Oct 2003 12:50:58 -0000	1.141
  @@ -399,6 +399,24 @@
       </dependency>
       <dependency>
         <groupId>fulcrum</groupId>
  +      <artifactId>fulcrum-cache</artifactId>
  +      <version>1.0-alpha-3</version>
  +      <url>http://jakarta.apache.org/turbine/fulcrum/fulcrum-cache</url>
  +      <properties>
  +        <war.bundle.jar>true</war.bundle.jar>
  +      </properties>
  +    </dependency>    
  +    <dependency>
  +      <groupId>fulcrum</groupId>
  +      <artifactId>fulcrum-crypto</artifactId>
  +      <version>1.0-alpha-3</version>
  +      <url>http://jakarta.apache.org/turbine/fulcrum/fulcrum-crypto</url>
  +      <properties>
  +        <war.bundle.jar>true</war.bundle.jar>
  +      </properties>
  +    </dependency>
  +    <dependency>
  +      <groupId>fulcrum</groupId>
         <artifactId>fulcrum-localization</artifactId>
         <version>1.0-alpha-3</version>
         <url>http://jakarta.apache.org/turbine/fulcrum/localization</url>
  @@ -425,6 +443,15 @@
         </properties>
       </dependency>     
       <dependency>
  +      <groupId>fulcrum</groupId>
  +      <artifactId>fulcrum-mimetype</artifactId>
  +      <version>1.0-alpha-3</version>
  +      <url>http://jakarta.apache.org/turbine/fulcrum/fulcrum-mimetype</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>
  @@ -487,6 +514,12 @@
         <url>http://db.apache.org/torque/</url>
       </dependency>
       <dependency>
  +    <groupId>turbine</groupId>
  +    <artifactId>turbine-torque-impl</artifactId>
  +    <version>2.4-dev</version>
  +      <url>http://jakarta.apache.org/turbine/</url>
  +    </dependency>
  +    <dependency>
         <id>velocity</id>
         <version>1.3.1</version>
         <url>http://jakarta.apache.org/velocity/</url>
  @@ -530,7 +563,7 @@
     </dependencies>
   
     <build>
  -    <sourceDirectory>target/src</sourceDirectory>
  +    <sourceDirectory>src/java</sourceDirectory>
       <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
       <unitTest>
         <includes>
  @@ -550,7 +583,7 @@
       <report>maven-changelog-plugin</report>
       <report>maven-developer-activity-plugin</report>
       <report>maven-file-activity-plugin</report>
  -    <report>maven-javadoc-plugin</report>
  +   <!-- <report>maven-javadoc-plugin</report>-->
       <report>maven-jxr-plugin</report>
       <!--
       <report>maven-junit-report-plugin</report>
  
  
  
  1.1                  jakarta-turbine-2/conf/test/fulcrumRoleConfiguration.xml
  
  Index: fulcrumRoleConfiguration.xml
  ===================================================================
  <!-- 
  	This configuration file for Avalon components is used for testing the Fulcrum Components with
  	Turbine.
  -->
  
  <role-list>
      <role
          name="org.apache.fulcrum.cache.GlobalCacheService"
          shorthand="cache"
          default-class="org.apache.fulcrum.cache.DefaultGlobalCacheService"/>
          
      <role
          name="org.apache.fulcrum.mimetype.MimeTypeService"
          shorthand="mimetype"
          default-class="org.apache.fulcrum.mimetype.DefaultMimeTypeService"/>        
  </role-list>
  
  
  
  
  1.1                  jakarta-turbine-2/conf/test/fulcrumComponentConfiguration.xml
  
  Index: fulcrumComponentConfiguration.xml
  ===================================================================
  <!-- 
  	This configuration file for Avalon components is used for testing the Fulcrum components
  	with Turbine.
  -->
  
  <componentConfig>
  	<cache cacheInitialSize="20" cacheCheckFrequency="5"/>   
  	<mimetype/>
  </componentConfig>
  
  
  
  1.1                  jakarta-turbine-2/conf/test/TestFulcrumComponents.properties
  
  Index: TestFulcrumComponents.properties
  ===================================================================
  # -------------------------------------------------------------------
  # $Id: TestFulcrumComponents.properties,v 1.1 2003/10/24 12:50:58 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.intake=org.apache.turbine.services.intake.IntakeTool
  
  
  
  services.AvalonComponentService.componentConfiguration = conf/test/fulcrumComponentConfiguration.xml
  services.AvalonComponentService.componentRoles = conf/test/fulcrumRoleConfiguration.xml
  services.AvalonComponentService.lookup = org.apache.fulcrum.cache.GlobalCacheService
  
  
  
  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/services/mimetype/FulcrumMimetypeComponent.java
  
  Index: FulcrumMimetypeComponent.java
  ===================================================================
  package org.apache.turbine.services.mimetype;
  /*
   * ==================================================================== 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/)."
   * AintakeToolernately, 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.Locale;
  
  import org.apache.fulcrum.mimetype.MimeTypeService;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
  import org.apache.turbine.test.BaseTestCase;
  import org.apache.turbine.util.TurbineConfig;
  /**
   * Unit test for Accessing the Fulcrum Mimetype component within Turbine.
   * 
   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   * @version $Id: FulcrumMimetypeComponent.java,v 1.1 2003/10/24 12:50:58 epugh Exp $
   */
  public class FulcrumMimetypeComponent extends BaseTestCase
  {
      private static TurbineConfig tc = null;
      public FulcrumMimetypeComponent(String name) throws Exception
      {
          super(name);
      }
      public void testComponent() throws Exception
      {
          AvalonComponentService acs =
              (AvalonComponentService) TurbineServices.getInstance().getService(
                  AvalonComponentService.SERVICE_NAME);
          MimeTypeService mimeTypeService =
              (MimeTypeService) acs.lookup(MimeTypeService.ROLE);
          Locale locale = new Locale("en", "US");
          String s = mimeTypeService.getCharSet(locale);
          assertEquals("ISO-8859-1", s);
      }
  
      public void setUp() throws Exception
      {
          tc =
              new TurbineConfig(
                  ".",
                  "/conf/test/TestFulcrumComponents.properties");
          tc.initialize();
      }
      public void tearDown() throws Exception
      {
          if (tc != null)
          {
              tc.dispose();
          }
      }
  }
  
  
  
  1.1                  jakarta-turbine-2/src/test/org/apache/turbine/services/cache/FulcrumCacheComponent.java
  
  Index: FulcrumCacheComponent.java
  ===================================================================
  package org.apache.turbine.services.cache;
  /* ====================================================================
   * 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/)."
   *    AintakeToolernately, 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 org.apache.fulcrum.cache.CacheServiceFacade;
  import org.apache.fulcrum.cache.CachedObject;
  import org.apache.fulcrum.cache.GlobalCacheService;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
  import org.apache.turbine.test.BaseTestCase;
  import org.apache.turbine.util.TurbineConfig;
  /**
   * Unit test for Accessing the Fulcrum Cache component via the
   * CacheServiceFacade and the Component within Turbine.
   *
   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
   * @version $Id: FulcrumCacheComponent.java,v 1.1 2003/10/24 12:50:58 epugh Exp $
   */
  public class FulcrumCacheComponent extends BaseTestCase
  {
      private static TurbineConfig tc = null;
      public FulcrumCacheComponent(String name) throws Exception
      {
          super(name);
      }
      public void testComponentAndFacaded() throws Exception
      {
  		AvalonComponentService acs = (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
  		GlobalCacheService cache = (GlobalCacheService)acs.lookup(GlobalCacheService.ROLE);
  		CachedObject inputObject = new CachedObject(new Double(10.2));
  		cache.addObject("testObj",inputObject);
  		CachedObject returnObject = CacheServiceFacade.getObject("testObj");
  		assertEquals(inputObject,returnObject);
      }
  
      
      public void setUp() throws Exception
      {
          tc = new TurbineConfig(".", "/conf/test/TestFulcrumComponents.properties");
          tc.initialize();
      }
      public void tearDown() throws Exception
      {
          if (tc != null)
          {
              tc.dispose();
          }
      }
  }
  
  
  

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