avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/test/org/apache/excalibur/assembly/type TypeManagerTestCase.java
Date Sat, 23 Nov 2002 16:32:01 GMT
mcconnell    2002/11/23 08:32:01

  Modified:    assembly/src/java/org/apache/excalibur/assembly/appliance
                        DefaultApplianceManager.java
               assembly/src/java/org/apache/excalibur/assembly/profile
                        DefaultProfileManager.java
               assembly/src/java/org/apache/excalibur/assembly/service
                        DefaultServiceManager.java ServiceManager.java
               assembly/src/java/org/apache/excalibur/assembly/type
                        DefaultTypeManager.java TypeManager.java
               assembly/src/test/org/apache/excalibur/assembly/service
                        DefaultServiceManagerTestCase.java
               assembly/src/test/org/apache/excalibur/assembly/type
                        TypeManagerTestCase.java
  Log:
  Updating TypeManager and ServiceManager by moving static operations
  down to instance level, removing dependecies, updating interfaces, and
  updating respective unit tests.
  
  Revision  Changes    Path
  1.3       +2 -14     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/DefaultApplianceManager.java
  
  Index: DefaultApplianceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/DefaultApplianceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultApplianceManager.java	22 Nov 2002 23:42:37 -0000	1.2
  +++ DefaultApplianceManager.java	23 Nov 2002 16:32:00 -0000	1.3
  @@ -155,11 +155,6 @@
        */
       private final Map m_appliances = new Hashtable();
   
  -   /**
  -    * The profile manager.
  -    */
  -    private ProfileManager m_profiles;
  -
       //==============================================================
       // Contextualizable
       //==============================================================
  @@ -182,18 +177,11 @@
       *     <td>{@link org.apache.excalibur.assembly.appliance.ApplianceManager}</td>
       *     <td>In no value suppled, this appliance manager will be considered as a
root manager.</td> 
       *   </tr>
  -    *   <tr>
  -    *     <td>assembly:profiles</td>
  -    *     <td>{@link org.apache.excalibur.assembly.profile.ProfileManager}</td>
  -    *     <td>Required entry - the profile manager.</td> 
  -    *   </tr>
       * </table>
       * @param context the runtime context
       */
  -    public void contextualize( Context context ) throws ContextException
  +    public void contextualize( Context context )
       {
  -        m_profiles = (ProfileManager) context.get("assembly.profiles");
  -
           try
           {
               m_parent = (ApplianceManager) context.get( "assembly:parent" );
  
  
  
  1.3       +1 -19     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/profile/DefaultProfileManager.java
  
  Index: DefaultProfileManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/profile/DefaultProfileManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultProfileManager.java	22 Nov 2002 23:42:37 -0000	1.2
  +++ DefaultProfileManager.java	23 Nov 2002 16:32:00 -0000	1.3
  @@ -209,18 +209,11 @@
       *     <td>{@link org.apache.excalibur.assembly.type.TypeManager}</td>
       *     <td>In no value suppled, this type manager will be considered as a root
manager.</td> 
       *   </tr>
  -    *   <tr>
  -    *     <td>assembly:services</td>
  -    *     <td>{@link org.apache.excalibur.assembly.service.ServiceManager}</td>
  -    *     <td>Required entry - the service manager.</td> 
  -    *   </tr>
       * </table>
       * @param context the runtime context
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_types = (TypeManager) context.get("assembly.types");
  -
           try
           {
               m_parent = (ProfileManager) context.get( "assembly:parent" );
  @@ -281,17 +274,6 @@
        */
       public Profile[] getProfiles( Type type ) throws UnknownTypeException, DuplicateTypeException
       {
  -        //
  -        // check that the type is registered
  -        //
  -
  -        Type local = m_types.getType( type.getInfo().getClassname() );
  -        if( !type.equals( type ) )
  -        {
  -            final String error = "Supplied type is not equal to the type known by the manager.";
  -            throw new DuplicateTypeException( error );
  -        }
  -
           ArrayList list = new ArrayList();
           if( m_parent != null )
           {
  
  
  
  1.5       +58 -60    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/service/DefaultServiceManager.java
  
  Index: DefaultServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/service/DefaultServiceManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultServiceManager.java	23 Nov 2002 13:00:17 -0000	1.4
  +++ DefaultServiceManager.java	23 Nov 2002 16:32:00 -0000	1.5
  @@ -120,60 +120,6 @@
        */
       private Hashtable m_services = new Hashtable();
   
  -    /**
  -     * Create a services associated from a supplied path. 
  -     *
  -     * @param clazz the service class
  -     * @return the service defintions
  -     */
  -    public static Service createService( Class clazz ) throws ServiceException
  -    {
  -        if( clazz == null )
  -        {
  -            throw new NullPointerException("clazz");
  -        }
  -
  -        try
  -        {
  -            return m_builder.build( clazz.getName(), clazz.getClassLoader() );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -               "Could not create a service relative to the path: " 
  -               + clazz.getName() + " due to a service build error.";
  -            throw new ServiceException( error, e );
  -        }
  -    }
  -
  -    /**
  -     * Create a service instance based on a supplied classname.
  -     *
  -     * @param classname the component implementation classname
  -     * @param loader the classloader to use
  -     * @return the component type
  -     */
  -    public static Service createService( String classname, ClassLoader loader ) throws
ServiceException
  -    {
  -        if( classname == null )
  -        {
  -            throw new NullPointerException("classname");
  -        }
  -
  -        try
  -        {
  -            Class clazz = loader.loadClass( classname );
  -            return createService( clazz );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unexpected error while attempting to build a service from the classname:
" + classname;
  -            throw new ServiceException( error, e );
  -        }
  -    }
  -
  -
       //==============================================================
       // Contextualizable
       //==============================================================
  @@ -258,6 +204,60 @@
       //==============================================================
   
       /**
  +     * Create a services associated from a supplied path. 
  +     *
  +     * @param clazz the service class
  +     * @return the service defintions
  +     * @exception ServiceException if an error occurs during service creation
  +     */
  +    public Service createService( Class clazz ) throws ServiceException
  +    {
  +        if( clazz == null )
  +        {
  +            throw new NullPointerException("clazz");
  +        }
  +
  +        try
  +        {
  +            return m_builder.build( clazz.getName(), clazz.getClassLoader() );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +               "Could not create a service relative to the path: " 
  +               + clazz.getName() + " due to a service build error.";
  +            throw new ServiceException( error, e );
  +        }
  +    }
  +
  +    /**
  +     * Create a service instance based on a supplied classname.
  +     *
  +     * @param classname the component implementation classname
  +     * @return the component type
  +     * @exception ServiceException if an error occurs during service creation
  +     */
  +    public Service createService( String classname ) throws ServiceException
  +    {
  +        if( classname == null )
  +        {
  +            throw new NullPointerException("classname");
  +        }
  +
  +        try
  +        {
  +            Class clazz = m_classloader.loadClass( classname );
  +            return createService( clazz );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unexpected error while attempting to build a service from the classname:
" + classname;
  +            throw new ServiceException( error, e );
  +        }
  +    }
  +
  +    /**
        * Locate a {@link Service} instances associated with the 
        * supplied classname and version. If a service defintion is not
        * found locally, the implementation redirects the request to 
  @@ -293,16 +293,14 @@
           }
       }
   
  -    //==============================================================
  -    // implemetation
  -    //==============================================================
  -
       /**
        * Add a service to the manager.
        *
        * @param path the service class name
        * @return the set of service defintions
  -     */
  +     * @exception DuplicateServiceException if the service already exists
  +     * @exception ServiceException if the service definition is invalid
  +    */
       public void addService( Service service ) throws ServiceException
       {
           //
  
  
  
  1.3       +29 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/service/ServiceManager.java
  
  Index: ServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/service/ServiceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceManager.java	22 Nov 2002 23:42:37 -0000	1.2
  +++ ServiceManager.java	23 Nov 2002 16:32:00 -0000	1.3
  @@ -70,6 +70,34 @@
   {
   
       /**
  +     * Create a services associated from a supplied path. 
  +     *
  +     * @param clazz the service class
  +     * @return the service defintions
  +     * @exception ServiceException if an error occurs during service creation
  +     */
  +    public Service createService( Class clazz ) throws ServiceException;
  +
  +    /**
  +     * Create a service instance based on a supplied classname.
  +     *
  +     * @param classname the component implementation classname
  +     * @return the component type
  +     * @exception ServiceException if an error occurs during service creation
  +     */
  +    public Service createService( String classname ) throws ServiceException;
  +
  +    /**
  +     * Add a service to the manager.
  +     *
  +     * @param path the service class name
  +     * @return the set of service defintions
  +     * @exception DuplicateServiceException if the service already exists
  +     * @exception ServiceException if the service definition is invalid
  +    */
  +    public void addService( Service service ) throws ServiceException;
  +
  +    /**
        * Locate a {@link Service} instances associated with the 
        * supplied classname and version. 
        *
  
  
  
  1.7       +61 -67    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/type/DefaultTypeManager.java
  
  Index: DefaultTypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/type/DefaultTypeManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultTypeManager.java	23 Nov 2002 13:00:17 -0000	1.6
  +++ DefaultTypeManager.java	23 Nov 2002 16:32:00 -0000	1.7
  @@ -96,60 +96,6 @@
       */
       private static final TypeBuilder m_builder = new TypeBuilder();
   
  -    /**
  -     * Create a new type instance.
  -     *
  -     * @param clazz the component implementation class
  -     * @return the component type
  -     */
  -    public static Type createType( Class clazz ) throws TypeException
  -    {
  -        if( clazz == null )
  -        {
  -            throw new NullPointerException("clazz");
  -        }
  -
  -        try
  -        {
  -            return m_builder.build( clazz.getName(), clazz.getClassLoader() );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Could not register a type relative to the path: " 
  -              + clazz.getName()
  -              + " due to a type build error.";
  -            throw new TypeException( error, e );
  -        }
  -    }
  -
  -    /**
  -     * Create a type instance based on a supplied classname and classloader.
  -     *
  -     * @param classname the component implementation classname
  -     * @param loader the classloader to use
  -     * @return the component type
  -     */
  -    public static Type createType( String classname, ClassLoader loader ) throws TypeException
  -    {
  -        if( classname == null )
  -        {
  -            throw new NullPointerException("classname");
  -        }
  -
  -        try
  -        {
  -            Class clazz = loader.loadClass( classname );
  -            return createType( clazz );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unexpected error while attempting to build a type from the classname: "
+ classname;
  -            throw new TypeException( error, e );
  -        }
  -    }
  -
       //==============================================================
       // state
       //==============================================================
  @@ -174,11 +120,6 @@
       */
       private TypeManager m_parent;
   
  -   /**
  -    * The parent type manager (may be null)
  -    */
  -    private ServiceManager m_services;
  -
       /**
        * Table of component types keyed by implementation classname.
        */
  @@ -206,18 +147,11 @@
       *     <td>{@link org.apache.excalibur.assembly.type.TypeManager}</td>
       *     <td>In no value suppled, this type manager will be considered as a root
manager.</td> 
       *   </tr>
  -    *   <tr>
  -    *     <td>assembly:services</td>
  -    *     <td>{@link org.apache.excalibur.assembly.service.ServiceManager}</td>
  -    *     <td>Required entry - the service manager.</td> 
  -    *   </tr>
       * </table>
       * @param context the runtime context
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_services = (ServiceManager) context.get("assembly:services");
  -
           try
           {
               m_parent = (TypeManager) context.get( "assembly:parent" );
  @@ -269,11 +203,71 @@
       // TypeManager
       //==============================================================
   
  +    /**
  +     * Create a new type instance.  The type instance returned is not 
  +     * registered with the manager.  To register the type the client 
  +     * must explicity declare the type using the {@link #addType} 
  +     * operation.
  +     *
  +     * @param clazz the component implementation class
  +     * @return the component type
  +     * @exception TypeException is a type creation error occurs
  +     * @see #addType
  +     */
  +    public Type createType( Class clazz ) throws TypeException
  +    {
  +        if( clazz == null )
  +        {
  +            throw new NullPointerException("clazz");
  +        }
  +
  +        try
  +        {
  +            return m_builder.build( clazz.getName(), clazz.getClassLoader() );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Could not register a type relative to the path: " 
  +              + clazz.getName()
  +              + " due to a type build error.";
  +            throw new TypeException( error, e );
  +        }
  +    }
  +
  +    /**
  +     * Create a type instance based on a supplied classname and classloader.
  +     *
  +     * @param classname the component implementation classname
  +     * @param loader the classloader to use
  +     * @return the component type
  +     */
  +    public Type createType( String classname ) throws TypeException
  +    {
  +        if( classname == null )
  +        {
  +            throw new NullPointerException("classname");
  +        }
  +
  +        try
  +        {
  +            Class clazz = m_classloader.loadClass( classname );
  +            return createType( clazz );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unexpected error while attempting to build a type from the classname: "
+ classname;
  +            throw new TypeException( error, e );
  +        }
  +    }
  +
      /**
       * Add a type to the manager.
       * @param type the component type description.
       * @exception DuplicateTypeException if the supplied type is already registered
       * @exception TypeException if a type verification failure occurs
  +    * @see #createType
       */
       public void addType( Type type ) throws DuplicateTypeException, TypeException
       {
  
  
  
  1.5       +31 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/type/TypeManager.java
  
  Index: TypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/type/TypeManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TypeManager.java	22 Nov 2002 23:42:37 -0000	1.4
  +++ TypeManager.java	23 Nov 2002 16:32:00 -0000	1.5
  @@ -71,6 +71,36 @@
    */
   public interface TypeManager
   {
  +    /**
  +     * Create a new type instance.  The type instance returned is not 
  +     * registered with the manager.  To register the type the client 
  +     * must explicity declare the type using the {@link #addType} 
  +     * operation.
  +     *
  +     * @param clazz the component implementation class
  +     * @return the component type
  +     * @exception TypeException is a type creation error occurs
  +     * @see #addType
  +     */
  +    public Type createType( Class clazz ) throws TypeException;
  +
  +    /**
  +     * Create a type instance based on a supplied classname and classloader.
  +     *
  +     * @param classname the component implementation classname
  +     * @param loader the classloader to use
  +     * @return the component type
  +     */
  +    public Type createType( String classname ) throws TypeException;
  +
  +   /**
  +    * Add a type to the manager.
  +    * @param type the component type description.
  +    * @exception DuplicateTypeException if the supplied type is already registered
  +    * @exception TypeException if a type verification failure occurs
  +    * @see #createType
  +    */
  +    public void addType( Type type ) throws DuplicateTypeException, TypeException;
   
       /**
        * Locate a {@link Type} instances associated with the 
  
  
  
  1.3       +27 -50    jakarta-avalon-excalibur/assembly/src/test/org/apache/excalibur/assembly/service/DefaultServiceManagerTestCase.java
  
  Index: DefaultServiceManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/test/org/apache/excalibur/assembly/service/DefaultServiceManagerTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultServiceManagerTestCase.java	23 Nov 2002 14:38:25 -0000	1.2
  +++ DefaultServiceManagerTestCase.java	23 Nov 2002 16:32:01 -0000	1.3
  @@ -26,6 +26,8 @@
   public class DefaultServiceManagerTestCase extends TestCaseBase
   {
   
  +    private ServiceManager m_manager;
  +
       public DefaultServiceManagerTestCase()
       {
           this( "DefaultServiceManager" );
  @@ -36,27 +38,40 @@
           super( name );
       }
   
  -    public void testStaticOperations()
  +    protected void setUp() throws Exception
  +    {
  +        super.setUp();
  +        DefaultServiceManager manager = new DefaultServiceManager();
  +        manager.enableLogging( getLogger().getChildLogger("services") );
  +        DefaultContext context = new DefaultContext();
  +        context.put( "assembly:classloader", m_loader );
  +        context.makeReadOnly();
  +        manager.contextualize( context );
  +        manager.initialize();
  +        m_manager = manager;
  +    }
  +
  +    public void testStaticBasicService()
       {
           final String classname = "org.apache.excalibur.playground.BasicService";
             
           try
           {
  -            assertTrue( doStaticCreation( classname ) != null );
  +            assertTrue( m_manager.createService( classname ) != null );
           }
           catch( Throwable e )
           {
               System.out.println("static operation failure for create type using : " + classname
);
  -            assertTrue( false );
               e.printStackTrace();
  +            assertTrue( false );
           }
       }
   
  -    public void testStaticOperationsNull()
  +    public void testOperationsNull()
       {          
           try
           {
  -            doStaticCreation( null );
  +            m_manager.createService( (String) null );
               assertTrue( false );
           }
           catch( NullPointerException e )
  @@ -76,8 +91,7 @@
           final String classname = "org.something.else";
           try
           {
  -            Service service = DefaultServiceManager.createService( classname, m_loader
);
  -            doStaticCreation( classname );
  +            Service service = m_manager.createService( classname );
               assertTrue( false );
           }
           catch( ServiceException e )
  @@ -94,31 +108,14 @@
           }
       }
   
  -   /**
  -    * Validation of the creation of the default type manager implememtation.
  -    */
  -    public void testCreation()
  -    {
  -        try
  -        {
  -            assertTrue( createServiceManager() != null );
  -        }
  -        catch( Throwable e )
  -        {
  -            assertTrue( false );
  -        }
  -    }
  -
       public void testServiceRegistrationAndRetrival() throws Exception
       {
           final String classname = "org.apache.excalibur.playground.BasicService";
   
  -        DefaultServiceManager manager = createServiceManager();
  -        Service service = doStaticCreation( classname );
  +        Service service = m_manager.createService( classname );
           try
           {
  -
  -            manager.addService( service );
  +            m_manager.addService( service );
               assertTrue( true );
           }
           catch( Throwable e )
  @@ -134,7 +131,7 @@
   
           try
           {
  -            manager.addService( service );
  +            m_manager.addService( service );
               System.out.println( "type replacement check failure" );
               assertTrue( false );
           }
  @@ -149,7 +146,7 @@
   
           try
           {
  -            service.equals( manager.getService( service.getClassname(), service.getVersion()
) );
  +            service.equals( m_manager.getService( service.getClassname(), service.getVersion()
) );
               assertTrue( true );
           }
           catch( Throwable e )
  @@ -166,7 +163,7 @@
           try
           {
               Version version = Version.getVersion( "111.111" );
  -            service.equals( manager.getService( service.getClassname(), version ) );
  +            service.equals( m_manager.getService( service.getClassname(), version ) );
               System.out.println( "service retrival by classname/version failure on bad version"
);
               assertTrue( false );
           }
  @@ -176,30 +173,10 @@
           }
       }
   
  -   /**
  -    * Validation of the creation of the default type manager implememtation.
  -    */
  -    public DefaultServiceManager createServiceManager() throws Exception
  -    {
  -        DefaultServiceManager services = new DefaultServiceManager();
  -        services.enableLogging( getLogger().getChildLogger("services") );
  -        DefaultContext serviceContext = new DefaultContext();
  -        serviceContext.put( "assembly:classloader", m_loader );
  -        serviceContext.makeReadOnly();
  -        services.contextualize( serviceContext );
  -        services.initialize();
  -        return services;
  -    }
  -
  -    private Service doStaticCreation( String classname ) throws Exception
  -    {          
  -        Class clazz = m_loader.loadClass( classname );
  -        return DefaultServiceManager.createService( clazz );
  -    }
  -
       protected void tearDown() throws Exception
       {
           m_loader = null;
  +        m_manager = null;
       }
   
   }
  
  
  
  1.2       +38 -70    jakarta-avalon-excalibur/assembly/src/test/org/apache/excalibur/assembly/type/TypeManagerTestCase.java
  
  Index: TypeManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/test/org/apache/excalibur/assembly/type/TypeManagerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeManagerTestCase.java	22 Nov 2002 23:43:03 -0000	1.1
  +++ TypeManagerTestCase.java	23 Nov 2002 16:32:01 -0000	1.2
  @@ -25,6 +25,8 @@
   public class TypeManagerTestCase extends TestCaseBase
   {
   
  +    private TypeManager m_manager;
  +
       public TypeManagerTestCase()
       {
           this( "TypeManagerTestCase" );
  @@ -35,45 +37,58 @@
           super( name );
       }
   
  -    public void testTypeManagerStaticOperationsBasic()
  +    protected void setUp() throws Exception
  +    {
  +        super.setUp();
  +        DefaultTypeManager manager = new DefaultTypeManager();
  +        manager.enableLogging( getLogger().getChildLogger("types") );
  +        DefaultContext context = new DefaultContext();
  +        context.put( "assembly:classloader", m_loader );
  +        context.makeReadOnly();
  +        manager.contextualize( context );
  +        manager.initialize();
  +        m_manager = manager;
  +    }
  +
  +    public void testBasic()
       {
           final String classname = "org.apache.excalibur.playground.BasicComponent";
             
           try
           {
  -            assertTrue( doStaticCreation( classname ) != null );
  +            assertTrue( m_manager.createType( classname ) != null );
           }
           catch( Throwable e )
           {
  -            System.out.println("static operation failure for create type using : " + classname
);
  +            System.out.println("failure to create type using : " + classname );
               assertTrue( false );
               e.printStackTrace();
           }
       }
   
  -    public void testTypeManagerStaticOperationsSimple()
  +    public void testSimple()
       {
           final String classname = "org.apache.excalibur.playground.SimpleComponent";
             
           try
           {
  -            assertTrue( doStaticCreation( classname ) != null );
  +            assertTrue( m_manager.createType( classname ) != null );
           }
           catch( Throwable e )
           {
  -            System.out.println("static operation failure for create type using : " + classname
);
  +            System.out.println("failure for create type using : " + classname );
               assertTrue( false );
               e.printStackTrace();
           }
       }
   
  -    public void testTypeManagerStaticOperationsComplex()
  +    public void testComplex()
       {
           final String classname = "org.apache.excalibur.playground.ComplexComponent";
             
           try
           {
  -            assertTrue( doStaticCreation( classname ) != null );
  +            assertTrue( m_manager.createType( classname ) != null );
           }
           catch( Throwable e )
           {
  @@ -83,11 +98,11 @@
           }
       }
   
  -    public void testTypeManagerStaticOperationsNull()
  +    public void testNull()
       {          
           try
           {
  -            doStaticCreation( null );
  +            m_manager.createType( (String) null );
               assertTrue( false );
           }
           catch( NullPointerException e )
  @@ -102,13 +117,12 @@
           }
       }
   
  -    public void testTypeManagerStaticOperationsBadType()
  +    public void testBadType()
       {          
           final String classname = "org.something.else";
           try
           {
  -            Type type = DefaultTypeManager.createType( classname, m_loader );
  -            doStaticCreation( classname );
  +            Type type = m_manager.createType( classname );
               assertTrue( false );
           }
           catch( TypeException e )
  @@ -125,37 +139,21 @@
           }
       }
   
  -   /**
  -    * Validation of the creation of the default type manager implememtation.
  -    */
  -    public void testTypeManagerCreation()
  -    {
  -        try
  -        {
  -            assertTrue( createTypeManager() != null );
  -        }
  -        catch( Throwable e )
  -        {
  -            assertTrue( false );
  -        }
  -    }
  -
       public void testTypeRegistrationAndRetrival() throws Exception
       {
           final String complex = "org.apache.excalibur.playground.ComplexComponent";
           final String basic = "org.apache.excalibur.playground.BasicComponent";
           final String simple = "org.apache.excalibur.playground.SimpleComponent";
   
  -        DefaultTypeManager manager = createTypeManager();
  -        Type complexType = doStaticCreation( complex );
  -        Type basicType = doStaticCreation( basic );
  -        Type simpleType = doStaticCreation( simple );
  +        Type complexType = m_manager.createType( complex );
  +        Type basicType = m_manager.createType( basic );
  +        Type simpleType = m_manager.createType( simple );
           try
           {
   
  -            manager.addType( complexType );
  -            manager.addType( basicType );
  -            manager.addType( simpleType );
  +            m_manager.addType( complexType );
  +            m_manager.addType( basicType );
  +            m_manager.addType( simpleType );
   
               assertTrue( true );
           }
  @@ -172,9 +170,9 @@
   
           try
           {
  -            complexType.equals( manager.getType( complex ) );
  -            basicType.equals( manager.getType( basic ) );
  -            simpleType.equals( manager.getType( simple ) );
  +            complexType.equals( m_manager.getType( complex ) );
  +            basicType.equals( m_manager.getType( basic ) );
  +            simpleType.equals( m_manager.getType( simple ) );
               assertTrue( true );
           }
           catch( Throwable e )
  @@ -189,38 +187,8 @@
           //
   
           DependencyDescriptor constraint = complexType.getDependency( "simple" );
  -        Type[] solutions = manager.getTypes( constraint );
  -
  -    }
  -
  -   /**
  -    * Validation of the creation of the default type manager implememtation.
  -    */
  -    public DefaultTypeManager createTypeManager() throws Exception
  -    {
  -        DefaultServiceManager services = new DefaultServiceManager();
  -        services.enableLogging( getLogger().getChildLogger("services") );
  -        DefaultContext serviceContext = new DefaultContext();
  -        serviceContext.put( "assembly:classloader", m_loader );
  -        serviceContext.makeReadOnly();
  -        services.contextualize( serviceContext );
  -        services.initialize();
  -
  -        DefaultTypeManager manager = new DefaultTypeManager();
  -        manager.enableLogging( getLogger().getChildLogger("types") );
  -        DefaultContext typeContext = new DefaultContext();
  -        typeContext.put( "assembly:classloader", m_loader );
  -        typeContext.put( "assembly:services", services );
  -        typeContext.makeReadOnly();
  -        manager.contextualize( typeContext );
  -        manager.initialize();
  -        return manager;
  -    }
  -
  -    private Type doStaticCreation( String classname ) throws Exception
  -    {          
  -        Class clazz = m_loader.loadClass( classname );
  -        return DefaultTypeManager.createType( clazz );
  +        Type[] solutions = m_manager.getTypes( constraint );
  +        assertTrue( solutions.length > 0 );
       }
   
       protected void tearDown() throws Exception
  
  
  

--
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