avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test AbstractMetaInfoManagerTestCase.java Role2MetaInfoManagerTestCase.java ServiceMetaManagerTestCase.java
Date Mon, 21 Apr 2003 18:34:54 GMT
bloritsch    2003/04/21 11:34:54

  Modified:    fortress/src/java/org/apache/avalon/fortress/impl/role
                        Role2MetaInfoManager.java
  Added:       fortress/src/test/org/apache/avalon/fortress/impl/role/test
                        AbstractMetaInfoManagerTestCase.java
                        Role2MetaInfoManagerTestCase.java
                        ServiceMetaManagerTestCase.java
  Log:
  100% testing of roles subpackage
  
  Revision  Changes    Path
  1.2       +1 -1      avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/role/Role2MetaInfoManager.java
  
  Index: Role2MetaInfoManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/role/Role2MetaInfoManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Role2MetaInfoManager.java	18 Apr 2003 20:02:30 -0000	1.1
  +++ Role2MetaInfoManager.java	21 Apr 2003 18:34:54 -0000	1.2
  @@ -55,7 +55,7 @@
   import org.apache.avalon.fortress.RoleManager;
   
   /**
  - * Role2MetaInfoManager does XYZ
  + * Role2MetaInfoManagerTestCase does XYZ
    *
    * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
    * @version CVS Revision: 1.1 $
  
  
  
  1.1                  avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test/AbstractMetaInfoManagerTestCase.java
  
  Index: AbstractMetaInfoManagerTestCase.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.MetaInfoManager;
  import org.apache.avalon.fortress.MetaInfoEntry;
  
  /**
   * AbstractMetaInfoManagerTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public abstract class AbstractMetaInfoManagerTestCase extends TestCase
  {
      private boolean m_informixClassExists = false;
      protected MetaInfoManager m_manager;
  
      public AbstractMetaInfoManagerTestCase( String name )
      {
          super( name );
  
          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 String shortname,
                                final String[] roles,
                                final String className,
                                final String handlerClassname )
          throws ClassNotFoundException
      {
          final MetaInfoEntry metaEntry = m_manager.getMetaInfoForShortName(shortname);
          assertNotNull( "MetaInfoEntry", metaEntry );
  
          assertEquals( "componentClass:",
              metaEntry.getComponentClass(), Class.forName( className ) );
  
          for (int i = 0; i < roles.length; i++)
          {
              assertTrue( "Role:", metaEntry.containsRole( roles[i] ) );
          }
          assertEquals( "Handler:",
              metaEntry.getHandlerClass(), Class.forName( handlerClassname ) );
      }
  }
  
  
  1.1                  avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test/Role2MetaInfoManagerTestCase.java
  
  Index: Role2MetaInfoManagerTestCase.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.impl.role.Role2MetaInfoManager;
  import org.apache.avalon.fortress.impl.role.FortressRoleManager;
  import org.apache.avalon.framework.logger.ConsoleLogger;
  
  /**
   * Role2MetaInfoManagerTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS Revision: 1.1 $
   */
  public class Role2MetaInfoManagerTestCase extends AbstractMetaInfoManagerTestCase
  {
      public Role2MetaInfoManagerTestCase( String name )
      {
          super( name );
      }
  
      public void setUp()
      {
          FortressRoleManager roles = new FortressRoleManager( null, this.getClass().getClassLoader()
);
          roles.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_INFO ) );
          roles.initialize();
          m_manager = new Role2MetaInfoManager(roles);
      }
  
      public void testRole2MetaInfoManager() throws Exception
      {
          String[] roles = new String[] {"org.apache.avalon.excalibur.datasource.DataSourceComponent"};
  
          checkRole( "jdbc-datasource", roles,
              "org.apache.avalon.excalibur.datasource.JdbcDataSource",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( "j2ee-datasource", roles,
              "org.apache.avalon.excalibur.datasource.J2eeDataSource",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          if ( isInformixClassExists() )
          {
              checkRole( "informix-datasource", roles,
                  "org.apache.avalon.excalibur.datasource.InformixDataSource",
                  "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          }
  
          roles[0] = "org.apache.avalon.excalibur.monitor.Monitor";
  
          checkRole( "monitor", roles,
              "org.apache.avalon.excalibur.monitor.ActiveMonitor",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( "passive-monitor", roles,
              "org.apache.avalon.excalibur.monitor.PassiveMonitor",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
  
          roles[0] = "org.apache.excalibur.xml.xpath.XPathProcessor";
  
          checkRole( "xalan-xpath", roles,
              "org.apache.excalibur.xml.xpath.XPathProcessorImpl",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
          checkRole( "jaxpath", roles,
              "org.apache.excalibur.xml.xpath.JaxenProcessorImpl",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
  
          roles[0] = "org.apache.excalibur.source.SourceResolver";
  
          checkRole( "resolver", roles,
              "org.apache.excalibur.source.impl.SourceResolverImpl",
              "org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler" );
  
          roles[0] = "org.apache.excalibur.xml.dom.DOMParser";
  
          checkRole( "parser", roles,
              "org.apache.excalibur.xml.impl.JaxpParser",
              "org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler" );
          checkRole( "xerces-parser", roles,
              "org.apache.excalibur.xml.impl.XercesParser",
              "org.apache.avalon.fortress.impl.handler.FactoryComponentHandler" );
      }
  }
  
  
  1.1                  avalon-excalibur/fortress/src/test/org/apache/avalon/fortress/impl/role/test/ServiceMetaManagerTestCase.java
  
  Index: ServiceMetaManagerTestCase.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.fortress.impl.role.ServiceMetaManager;
  import org.apache.avalon.fortress.impl.handler.ThreadSafeComponentHandler;
  import org.apache.avalon.fortress.impl.handler.PoolableComponentHandler;
  import org.apache.avalon.fortress.impl.handler.FactoryComponentHandler;
  import org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler;
  import org.apache.avalon.fortress.test.data.*;
  import org.apache.avalon.framework.container.ContainerUtil;
  import org.apache.avalon.framework.logger.NullLogger;
  
  /**
   * ServiceMetaManagerTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class ServiceMetaManagerTestCase extends AbstractMetaInfoManagerTestCase
  {
      public ServiceMetaManagerTestCase( String name )
      {
          super( name );
      }
  
      public void setUp() throws Exception
      {
          m_manager = new ServiceMetaManager();
          ContainerUtil.enableLogging(m_manager, new NullLogger());
          ContainerUtil.initialize(m_manager);
      }
  
      public void testTestRoles() throws Exception
      {
          String[] roles = new String[] {Role1.class.getName()};
          checkRole("component1", roles, Component1.class.getName(), ThreadSafeComponentHandler.class.getName());
  
          roles[0] = Role2.class.getName();
          checkRole("component2", roles, Component2.class.getName(), PoolableComponentHandler.class.getName());
  
          roles[0] = Role4.class.getName();
          checkRole("component4", roles, Component4.class.getName(), FactoryComponentHandler.class.getName());
  
          roles = new String[]
          {
              Role3.class.getName(),
              BaseRole.class.getName()
          };
  
          checkRole("component3", roles, Component3.class.getName(), PerThreadComponentHandler.class.getName());
      }
  }
  
  

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


Mime
View raw message