avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test ConfigurableRoleManagerTestCase.java ContainerProfile.roles ContainerProfile.xconf ExcaliburRoleManagerTestCase.java
Date Tue, 19 Feb 2002 14:54:23 GMT
bloritsch    02/02/19 06:54:23

  Modified:    src/scratchpad/org/apache/avalon/excalibur/system/test
                        ContainerProfile.xconf
                        ExcaliburRoleManagerTestCase.java
  Added:       src/scratchpad/org/apache/avalon/excalibur/system/test
                        ConfigurableRoleManagerTestCase.java
                        ContainerProfile.roles
  Log:
  add RoleManager tests
  
  Revision  Changes    Path
  1.2       +1 -1      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ContainerProfile.xconf
  
  Index: ContainerProfile.xconf
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ContainerProfile.xconf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainerProfile.xconf	19 Feb 2002 13:47:29 -0000	1.1
  +++ ContainerProfile.xconf	19 Feb 2002 14:54:23 -0000	1.2
  @@ -22,7 +22,7 @@
     <component id="test3"
         class="org.apache.avalon.excalibur.xml.JaxpParser"
         role="org.apache.avalon.excalibur.xml.Parser"
  -      handler="org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler"
  +      handler="org.apache.avalon.excalibur.system.handler.PoolableComponentHandler"
         logger="test">
           <parameter name="validate" value="false"/>
           <parameter name="namespace-prefixes" value="false"/>
  
  
  
  1.3       +169 -37   jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ExcaliburRoleManagerTestCase.java
  
  Index: ExcaliburRoleManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ExcaliburRoleManagerTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExcaliburRoleManagerTestCase.java	19 Feb 2002 14:03:22 -0000	1.2
  +++ ExcaliburRoleManagerTestCase.java	19 Feb 2002 14:54:23 -0000	1.3
  @@ -17,7 +17,7 @@
    * in the org.apache.avalon.component package.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/02/19 14:03:22 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/02/19 14:54:23 $
    * @since 4.1
    */
   public class ExcaliburRoleManagerTestCase
  @@ -72,10 +72,6 @@
               Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" )
           );
           assertEquals(
  -            roles.getClassForName( "cache" ),
  -            Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" )
  -        );
  -        assertEquals(
               roles.getClassForName( "xalan-xpath" ),
               Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" )
           );
  @@ -138,10 +134,6 @@
               "passive-monitor"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache"
) ),
  -            "cache"
  -        );
  -        assertEquals(
               roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"
) ),
               "xalan-xpath"
           );
  @@ -172,60 +164,200 @@
           ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader()
);
   
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache"
) ),
  -            "cache"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache"
) ),
  +            "org.apache.avalon.excalibur.cache.Cache"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache"
) ),
  -            "lru-cache"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache"
) ),
  +            "org.apache.avalon.excalibur.cache.Cache"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource"
) ),
  -            "jdbc-datasource"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource"
) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource"
) ),
  -            "j2ee-datasource"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource"
) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource"
) ),
  -            "informix-datasource"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource"
) ),
  +            "org.apache.avalon.excalibur.datasource.DataSourceComponent"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector"
) ),
  -            "i18n"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector"
) ),
  +            "org.apache.avalon.excalibur.i18n.BundleSelector"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor"
) ),
  -            "monitor"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor"
) ),
  +            "org.apache.avalon.excalibur.monitor.Monitor"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor"
) ),
  -            "passive-monitor"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor"
) ),
  +            "org.apache.avalon.excalibur.monitor.Monitor"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache"
) ),
  -            "cache"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"
) ),
  +            "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"
) ),
  -            "xalan-xpath"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl"
) ),
  +            "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl"
) ),
  -            "jaxpath"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl"
) ),
  +            "org.apache.avalon.excalibur.source.SourceResolver"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl"
) ),
  -            "resolver"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser"
) ),
  +            "org.apache.avalon.excalibur.xml.Parser"
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser"
) ),
  -            "parser"
  +            roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser"
) ),
  +            "org.apache.avalon.excalibur.xml.Parser"
  +        );
  +    }
  +
  +    /**
  +     * Test the shorthand return values.
  +     */
  +    public void testClassesForRole()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader()
);
  +
  +        Class[] classes = roles.getClassesForRole( "org.apache.avalon.excalibur.cache.Cache"
);
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache" )
           );
           assertEquals(
  -            roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser"
) ),
  -            "xerces-parser"
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.cache.LRUCache" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.datasource.DataSourceComponent"
);
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource" )
  +        );
  +        assertEquals(
  +            classes[2],
  +            Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource"
)
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.i18n.BundleSelector"
);
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.monitor.Monitor"
);
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.xpath.XPathProcessor"
);
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.source.SourceResolver"
);
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl" )
  +        );
  +
  +        classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.Parser" );
  +
  +        assertEquals(
  +            classes[0],
  +            Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
  +        );
  +        assertEquals(
  +            classes[1],
  +            Class.forName( "org.apache.avalon.excalibur.xml.XercesParser" )
  +        );
  +    }
  +
  +    /**
  +     * Test the handler class return values.
  +     */
  +    public void testHandlerClassReturnValues()
  +        throws Exception
  +    {
  +        ExcaliburRoleManager roles = new ExcaliburRoleManager( null, this.getClass().getClassLoader()
);
  +
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.cache.DefaultCache"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.cache.LRUCache"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.J2eeDataSource"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.InformixDataSource"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.i18n.BundleSelector"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.PassiveMonitor"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.source.SourceResolverImpl"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler"
)
  +        );
  +        assertEquals(
  +            roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.XercesParser"
) ),
  +            Class.forName( "org.apache.avalon.excalibur.system.handler.FactoryComponentHandler"
)
           );
       }
   }
  
  
  
  1.1                  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ConfigurableRoleManagerTestCase.java
  
  Index: ConfigurableRoleManagerTestCase.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.system.test;
  
  import org.apache.avalon.excalibur.system.ConfigurableRoleManager;
  import org.apache.avalon.framework.configuration.*;
  
  import junit.framework.TestCase;
  
  /**
   * 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: 2002/02/19 14:54:23 $
   * @since 4.1
   */
  public class ConfigurableRoleManagerTestCase
      extends TestCase
  {
      /**
       * Default constructor--this RoleManager has no parent.
       */
      public ConfigurableRoleManagerTestCase( String name )
      {
          super( name );
      }
  
      /**
       * Test the shorthand return values.
       */
      public void testShorthandReturnValues()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader()
);
          roles.configure( builder.build(this.getClass().getClassLoader()
                           .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles"
) ) );
  
          assertEquals(
              roles.getClassForName( "datasource" ),
              Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
          );
          assertEquals(
              roles.getClassForName( "monitor" ),
              Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
          );
          assertEquals(
              roles.getClassForName( "parser" ),
              Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
          );
      }
  
      /**
       * Test the shorthand return values.
       */
      public void testShorthandRemapReturnValues()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader()
);
          roles.configure( builder.build(this.getClass().getClassLoader()
                           .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles"
) ) );
  
          assertEquals(
              roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource"
) ),
              "datasource"
          );
          assertEquals(
              roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor"
) ),
              "monitor"
          );
          assertEquals(
              roles.getNameForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser"
) ),
              "parser"
          );
      }
  
      /**
       * Test the shorthand return values.
       */
      public void testRoleForClass()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader()
);
          roles.configure( builder.build(this.getClass().getClassLoader()
                           .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles"
) ) );
  
          assertEquals(
              roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource"
) ),
              "org.apache.avalon.excalibur.datasource.DataSourceComponent"
          );
          assertEquals(
              roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor"
) ),
              "org.apache.avalon.excalibur.monitor.Monitor"
          );
          assertEquals(
              roles.getRoleForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser"
) ),
              "org.apache.avalon.excalibur.xml.Parser"
          );
      }
  
      /**
       * Test the shorthand return values.
       */
      public void testClassesForRole()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader()
);
          roles.configure( builder.build(this.getClass().getClassLoader()
                           .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles"
) ) );
  
          Class[] classes = roles.getClassesForRole( "org.apache.avalon.excalibur.datasource.DataSourceComponent"
);
  
          assertEquals(
              classes[0],
              Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource" )
          );
  
          classes = roles.getClassesForRole( "org.apache.avalon.excalibur.monitor.Monitor"
);
  
          assertEquals(
              classes[0],
              Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor" )
          );
  
          classes = roles.getClassesForRole( "org.apache.avalon.excalibur.xml.Parser" );
  
          assertEquals(
              classes[0],
              Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser" )
          );
      }
  
      /**
       * Test the handler class return values.
       */
      public void testHandlerClassReturnValues()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          ConfigurableRoleManager roles = new ConfigurableRoleManager( null, this.getClass().getClassLoader()
);
          roles.configure( builder.build(this.getClass().getClassLoader()
                           .getResourceAsStream( "org/apache/avalon/excalibur/system/test/ContainerProfile.roles"
) ) );
  
          assertEquals(
              roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.datasource.JdbcDataSource"
) ),
              Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
          );
          assertEquals(
              roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.monitor.ActiveMonitor"
) ),
              Class.forName( "org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"
)
          );
          assertEquals(
              roles.getHandlerClassForClass( Class.forName( "org.apache.avalon.excalibur.xml.JaxpParser"
) ),
              Class.forName( "org.apache.avalon.excalibur.system.handler.PoolableComponentHandler"
)
          );
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/test/ContainerProfile.roles
  
  Index: ContainerProfile.roles
  ===================================================================
  <test>
    <role name="org.apache.avalon.excalibur.datasource.DataSourceComponent">
      <component shorthand="datasource"
                 class="org.apache.avalon.excalibur.datasource.JdbcDataSource"
                 handler="org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"/>
    </role>
    <role name="org.apache.avalon.excalibur.monitor.Monitor">
      <component shorthand="monitor"
                 class="org.apache.avalon.excalibur.monitor.ActiveMonitor"
                 handler="org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler"/>
    </role>
    <role name="org.apache.avalon.excalibur.xml.Parser">
    <component shorthand="parser"
               class="org.apache.avalon.excalibur.xml.JaxpParser"
               handler="org.apache.avalon.excalibur.system.handler.PoolableComponentHandler"/>
    </role>
  </test>
  
  
  

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


Mime
View raw message