You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/04/21 20:05:03 UTC

cvs commit: avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/util/test ComponentTestCase.java FullLifecycleComponent.java AbstractRoleManagerTestCase.java ConfigurableRoleManagerTestCase.java FortressRoleManagerTestCase.java

bloritsch    2003/04/21 11:05:03

  Modified:    fortress/src/test/org/apache/avalon/fortress/util/test
                        ComponentTestCase.java FullLifecycleComponent.java
  Added:       fortress/src/test/org/apache/avalon/fortress/impl/role/test
                        AbstractRoleManagerTestCase.java
                        ConfigurableRoleManagerTestCase.java
                        FortressRoleManagerTestCase.java
  Removed:     fortress/src/test/org/apache/avalon/fortress/util/test
                        AbstractRoleManagerTestCase.java
                        ConfigurableRoleManagerTestCase.java
                        FortressRoleManagerTestCase.java
  Log:
  finish rearranging test cases
  
  Revision  Changes    Path
  1.1                  avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test/AbstractRoleManagerTestCase.java
  
  Index: AbstractRoleManagerTestCase.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", 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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.avalon.fortress.impl.role.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.fortress.RoleEntry;
  import org.apache.avalon.fortress.RoleManager;
  
  /**
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2003/04/21 18:05:02 $
   */
  public class AbstractRoleManagerTestCase extends TestCase
  {
      private boolean m_informixClassExists = false;
  
      public AbstractRoleManagerTestCase( final String key )
      {
          super( key );
  
          try
          {
              Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource" );
              m_informixClassExists = true;
          }
          catch ( Exception e )
          {
              m_informixClassExists = false;
          }
      }
  
      protected boolean isInformixClassExists()
      {
          return m_informixClassExists;
      }
  
      protected void checkRole( final RoleManager roles,
                                final String shortname,
                                final String role,
                                final String className,
                                final String handlerClassname )
          throws ClassNotFoundException
      {
          final RoleEntry roleEntry = roles.getRoleForShortName( shortname );
          assertNotNull( "RoleEntry", roleEntry );
  
          assertEquals( "componentClass:",
              roleEntry.getComponentClass(), Class.forName( className ) );
          assertEquals( "Role:", roleEntry.getRole(), role );
          assertEquals( "Handler:",
              roleEntry.getHandlerClass(), Class.forName( handlerClassname ) );
      }
  }
  
  
  
  1.1                  avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test/ConfigurableRoleManagerTestCase.java
  
  Index: ConfigurableRoleManagerTestCase.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", 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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.avalon.fortress.impl.role.test;
  
  import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  import org.apache.avalon.framework.logger.ConsoleLogger;
  import org.apache.avalon.fortress.impl.role.ConfigurableRoleManager;
  
  
  /**
   * Configurable RoleManager implementation.  It populates the RoleManager
   * from a configuration hierarchy.  This is based on the DefaultRoleManager
   * in the org.apache.avalon.component package.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/04/21 18:05:02 $
   * @since 4.1
   */
  public class ConfigurableRoleManagerTestCase
      extends AbstractRoleManagerTestCase
  {
      public ConfigurableRoleManagerTestCase( String name )
      {
          super( name );
      }
  
      public void testShorthandReturnValues()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader() );
          roles.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_INFO ) );
          roles.configure( builder.build( this.getClass().getClassLoader()
              .getResourceAsStream( "org/apache/avalon/fortress/test/ContainerProfile.roles" ) ) );
  
          checkRole( roles,
              "datasource",
              "org.apache.avalon.excalibur.datasource.DataSourceComponent",
              "org.apache.avalon.excalibur.datasource.JdbcDataSource",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "monitor",
              "org.apache.avalon.excalibur.monitor.Monitor",
              "org.apache.avalon.excalibur.monitor.ActiveMonitor",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "parser",
              "org.apache.excalibur.xml.dom.DOMParser",
              "org.apache.excalibur.xml.impl.JaxpParser",
              "org.apache.avalon.fortress.impl.handler.PoolableComponentHandler" );
      }
  }
  
  
  
  
  1.1                  avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test/FortressRoleManagerTestCase.java
  
  Index: FortressRoleManagerTestCase.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", 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 (INCLU-
   DING, 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/>.
  
  */
  package org.apache.avalon.fortress.impl.role.test;
  
  import org.apache.avalon.framework.logger.ConsoleLogger;
  import org.apache.avalon.fortress.impl.role.FortressRoleManager;
  
  /**
   * Configurable RoleManager implementation.  It populates the RoleManager
   * from a configuration hierarchy.  This is based on the DefaultRoleManager
   * in the org.apache.avalon.component package.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/04/21 18:05:02 $
   * @since 4.1
   */
  public class FortressRoleManagerTestCase
      extends AbstractRoleManagerTestCase
  {
      public FortressRoleManagerTestCase( String name )
      {
          super( name );
      }
  
      /**
       * Test the shorthand return values.
       */
      public void testShorthandReturnValues()
          throws Exception
      {
          FortressRoleManager roles = new FortressRoleManager( null, this.getClass().getClassLoader() );
          roles.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_INFO ) );
          roles.initialize();
  
          checkRole( roles,
              "jdbc-datasource",
              "org.apache.avalon.excalibur.datasource.DataSourceComponent",
              "org.apache.avalon.excalibur.datasource.JdbcDataSource",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "j2ee-datasource",
              "org.apache.avalon.excalibur.datasource.DataSourceComponent",
              "org.apache.avalon.excalibur.datasource.J2eeDataSource",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          if ( isInformixClassExists() )
          {
              checkRole( roles,
                  "informix-datasource",
                  "org.apache.avalon.excalibur.datasource.DataSourceComponent",
                  "org.apache.avalon.excalibur.datasource.InformixDataSource",
                  "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          }
          checkRole( roles,
              "monitor",
              "org.apache.avalon.excalibur.monitor.Monitor",
              "org.apache.avalon.excalibur.monitor.ActiveMonitor",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "passive-monitor",
              "org.apache.avalon.excalibur.monitor.Monitor",
              "org.apache.avalon.excalibur.monitor.PassiveMonitor",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "xalan-xpath",
              "org.apache.excalibur.xml.xpath.XPathProcessor",
              "org.apache.excalibur.xml.xpath.XPathProcessorImpl",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "jaxpath",
              "org.apache.excalibur.xml.xpath.XPathProcessor",
              "org.apache.excalibur.xml.xpath.JaxenProcessorImpl",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "resolver",
              "org.apache.excalibur.source.SourceResolver",
              "org.apache.excalibur.source.impl.SourceResolverImpl",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( roles,
              "parser",
              "org.apache.excalibur.xml.dom.DOMParser",
              "org.apache.excalibur.xml.impl.JaxpParser",
              "org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler" );
          checkRole( roles,
              "xerces-parser",
              "org.apache.excalibur.xml.dom.DOMParser",
              "org.apache.excalibur.xml.impl.XercesParser",
              "org.apache.avalon.fortress.impl.handler.FactoryComponentHandler" );
      }
  
  }
  
  
  
  
  1.2       +1 -2      avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/util/test/ComponentTestCase.java
  
  Index: ComponentTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/util/test/ComponentTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ComponentTestCase.java	21 Apr 2003 17:52:09 -0000	1.1
  +++ ComponentTestCase.java	21 Apr 2003 18:05:03 -0000	1.2
  @@ -55,7 +55,6 @@
   import org.apache.avalon.framework.logger.NullLogger;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.avalon.fortress.test.util.FullLifecycleComponent;
   
   /**
    * This class provides basic facilities for enforcing Avalon's contracts
  
  
  
  1.2       +15 -14    avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/util/test/FullLifecycleComponent.java
  
  Index: FullLifecycleComponent.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/util/test/FullLifecycleComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FullLifecycleComponent.java	21 Apr 2003 17:52:09 -0000	1.1
  +++ FullLifecycleComponent.java	21 Apr 2003 18:05:03 -0000	1.2
  @@ -49,25 +49,26 @@
   */
   package org.apache.avalon.fortress.util.test;
   
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.activity.Initializable;
  -import org.apache.avalon.framework.activity.Startable;
  -import org.apache.avalon.framework.activity.Suspendable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.parameters.ParameterException;
  +import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.parameters.ParameterException;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Startable;
  +import org.apache.avalon.framework.activity.Suspendable;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +
   
   /**
    * This test class is used to test the AbstractComponent facilities for you.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org