ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test DefaultDeployerTestCase.java
Date Thu, 23 May 2002 09:36:37 GMT
adammurdoch    02/05/23 02:36:37

  Modified:    antlib/src/java/org/apache/antlib/runtime ConverterDef.java
                        TypeDef.java
               container/src/java/org/apache/myrmidon/components/deployer
                        CompoundTypeDeployer.java DefaultDeployer.java
                        DefaultTypeLibraryDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        Deployer.java TypeLibraryDeployer.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java
  Log:
  Moved deployType( TypeDefinition ) from TypeLibraryDeployer to Deployer,
  since TypeDefinition is now fully self-contained.
  
  Revision  Changes    Path
  1.5       +1 -3      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java
  
  Index: ConverterDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConverterDef.java	22 May 2002 07:44:02 -0000	1.4
  +++ ConverterDef.java	23 May 2002 09:36:36 -0000	1.5
  @@ -13,7 +13,6 @@
   import org.apache.myrmidon.framework.AbstractTypeDef;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.library.Library;
   import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  @@ -63,7 +62,6 @@
           final TypeDefinition typeDef = new TypeDefinition( name, Converter.ROLE, typeFactory,
attrs );
   
           final Deployer deployer = (Deployer)getService( Deployer.class );
  -        final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library, null
);
  -        typeDeployer.deployType( typeDef );
  +        deployer.deployType( null, typeDef );
       }
   }
  
  
  
  1.5       +1 -3      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java
  
  Index: TypeDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TypeDef.java	22 May 2002 07:44:02 -0000	1.4
  +++ TypeDef.java	23 May 2002 09:36:36 -0000	1.5
  @@ -10,7 +10,6 @@
   import org.apache.myrmidon.framework.AbstractTypeDef;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.library.Library;
   import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
   
  @@ -60,8 +59,7 @@
           typeFactory.addNameClassMapping( m_name, getClassname() );
   
           final Deployer deployer = (Deployer)getService( Deployer.class );
  -        final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library, m_namespace
);
           final TypeDefinition typeDef = new TypeDefinition( m_name, m_role, typeFactory
);
  -        typeDeployer.deployType( typeDef );
  +        deployer.deployType( m_namespace, typeDef );
       }
   }
  
  
  
  1.6       +21 -3     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java
  
  Index: CompoundTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CompoundTypeDeployer.java	22 May 2002 07:36:22 -0000	1.5
  +++ CompoundTypeDeployer.java	23 May 2002 09:36:36 -0000	1.6
  @@ -7,21 +7,25 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  -import java.util.Map;
   import java.util.HashMap;
  +import java.util.Map;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  -import org.apache.myrmidon.interfaces.type.TypeFactory;
   
   /**
    * A type deployer that delegates to a type deployer per role.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/05/22 07:36:22 $
  + * @version $Revision: 1.6 $ $Date: 2002/05/23 09:36:36 $
    */
   class CompoundTypeDeployer
       implements TypeDeployer
   {
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( CompoundTypeDeployer.class );
  +
       private final Map m_deployers = new HashMap();
       private final TypeDeployer m_defaultDeployer;
   
  @@ -45,6 +49,20 @@
                               final TypeDefinition typeDefinition )
           throws Exception
       {
  +        // Validate the type definition
  +        final String typeName = typeDefinition.getName();
  +        final String roleName = typeDefinition.getRole();
  +        if( null == roleName )
  +        {
  +            final String message = REZ.getString( "typedef.no-role.error" );
  +            throw new Exception( message );
  +        }
  +        if( null == typeName )
  +        {
  +            final String message = REZ.getString( "typedef.no-name.error" );
  +            throw new Exception( message );
  +        }
  +
           // Use the deployer for the type's role, if any.  Otherwise use the
           // default deployer
           TypeDeployer deployer = (TypeDeployer)m_deployers.get( typeDefinition.getRole()
);
  
  
  
  1.45      +22 -1     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java
  
  Index: DefaultDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- DefaultDeployer.java	23 May 2002 04:26:26 -0000	1.44
  +++ DefaultDeployer.java	23 May 2002 09:36:36 -0000	1.45
  @@ -19,6 +19,7 @@
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
   import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
  +import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.library.Library;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
   import org.apache.myrmidon.interfaces.service.ScopedService;
  @@ -28,7 +29,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.44 $ $Date: 2002/05/23 04:26:26 $
  + * @version $Revision: 1.45 $ $Date: 2002/05/23 09:36:36 $
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  @@ -98,4 +99,24 @@
               throw new DeploymentException( message, e );
           }
       }
  +
  +    /**
  +     * Deploys a single type from the type library.
  +     */
  +    public void deployType( final String namespace,
  +                            final TypeDefinition typeDef )
  +        throws DeploymentException
  +    {
  +        try
  +        {
  +            m_typeDeployer.deployType( namespace, typeDef );
  +        }
  +        catch( Exception e )
  +        {
  +            final String message = REZ.getString( "deploy-type.error",
  +                                                  typeDef.getRole(), typeDef.getName()
);
  +            throw new DeploymentException( message, e );
  +        }
  +    }
  +
   }
  
  
  
  1.8       +2 -35     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java
  
  Index: DefaultTypeLibraryDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultTypeLibraryDeployer.java	22 May 2002 07:36:22 -0000	1.7
  +++ DefaultTypeLibraryDeployer.java	23 May 2002 09:36:36 -0000	1.8
  @@ -32,7 +32,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.7 $ $Date: 2002/05/22 07:36:22 $
  + * @version $Revision: 1.8 $ $Date: 2002/05/23 09:36:36 $
    *
    * @todo Keep track of which types have been deployed, and don't redeploy them.
    */
  @@ -185,50 +185,17 @@
       }
   
       /**
  -     * Deploys a single type from the type library.
  -     */
  -    public void deployType( final TypeDefinition typeDef )
  -        throws DeploymentException
  -    {
  -        try
  -        {
  -            doDeployType( typeDef );
  -        }
  -        catch( Exception e )
  -        {
  -            final String message = REZ.getString( "deploy-type.error",
  -                                                  typeDef.getRole(), typeDef.getName()
);
  -            throw new DeploymentException( message, e );
  -        }
  -    }
  -
  -    /**
        * Deploys a type.
        */
       private void doDeployType( final TypeDefinition typeDef )
           throws Exception
       {
  -        // Validate the type definition
  -        final String typeName = typeDef.getName();
  -        final String roleName = typeDef.getRole();
  -        if( null == roleName )
  -        {
  -            final String message = REZ.getString( "typedef.no-role.error" );
  -            throw new DeploymentException( message );
  -        }
  -        if( null == typeName )
  -        {
  -            final String message = REZ.getString( "typedef.no-name.error" );
  -            throw new DeploymentException( message );
  -        }
  -
  -        // Deploy
           m_typeDeployer.deployType( m_namespace, typeDef );
   
           if( getLogger().isDebugEnabled() )
           {
               final String message =
  -                REZ.getString( "register-type.notice", roleName, typeName );
  +                REZ.getString( "register-type.notice", typeDef.getRole(), typeDef.getName()
);
               getLogger().debug( message );
           }
       }
  
  
  
  1.14      +16 -3     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/Deployer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Deployer.java	23 May 2002 04:26:26 -0000	1.13
  +++ Deployer.java	23 May 2002 09:36:36 -0000	1.14
  @@ -7,8 +7,6 @@
    */
   package org.apache.myrmidon.interfaces.deployer;
   
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.interfaces.library.Library;
   
   /**
  @@ -16,7 +14,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.13 $ $Date: 2002/05/23 04:26:26 $
  + * @version $Revision: 1.14 $ $Date: 2002/05/23 09:36:36 $
    */
   public interface Deployer
   {
  @@ -33,5 +31,20 @@
        * @throws DeploymentException if an error occurs.
        */
       TypeLibraryDeployer createDeployer( Library library, String namespace )
  +        throws DeploymentException;
  +
  +    /**
  +     * Deploys a single type.
  +     *
  +     * @param namespace
  +     *      The namespace to deploy the type into.  Use null to deploy into
  +     *      the default namespace.
  +     * @param typeDef
  +     *      The type definition.
  +     *
  +     * @throws DeploymentException
  +     *      If the type cannot be deployed.
  +     */
  +    void deployType( String namespace, TypeDefinition typeDef )
           throws DeploymentException;
   }
  
  
  
  1.4       +1 -13     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeLibraryDeployer.java
  
  Index: TypeLibraryDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeLibraryDeployer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypeLibraryDeployer.java	9 May 2002 07:54:32 -0000	1.3
  +++ TypeLibraryDeployer.java	23 May 2002 09:36:36 -0000	1.4
  @@ -13,7 +13,7 @@
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/09 07:54:32 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/23 09:36:36 $
    */
   public interface TypeLibraryDeployer
   {
  @@ -40,17 +40,5 @@
        *      If the type cannot be deployed.
        */
       void deployType( String roleName, String typeName )
  -        throws DeploymentException;
  -
  -    /**
  -     * Deploys a single type from the type library.
  -     *
  -     * @param typeDef
  -     *      The type definition.
  -     *
  -     * @throws DeploymentException
  -     *      If the type cannot be deployed.
  -     */
  -    void deployType( TypeDefinition typeDef )
           throws DeploymentException;
   }
  
  
  
  1.13      +31 -30    jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java
  
  Index: DefaultDeployerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultDeployerTestCase.java	22 May 2002 07:36:23 -0000	1.12
  +++ DefaultDeployerTestCase.java	23 May 2002 09:36:37 -0000	1.13
  @@ -55,6 +55,7 @@
           super.setUp();
           m_deployer = (Deployer)getServiceManager().lookup( Deployer.ROLE );
           m_converter = (Converter)getServiceManager().lookup( Converter.ROLE );
  +        registerRole( new RoleInfo( TestDataType.ROLE, TestDataType.class ) );
       }
   
       /**
  @@ -96,17 +97,15 @@
           final String typeName = TEST_TYPE1_NAME;
   
           // Create the type definition
  -        final TypeFactory typeFactory = new DefaultTypeFactory( TEST_TYPE1_NAME, TestType1.class
);
  +        final TypeFactory typeFactory = new DefaultTypeFactory( typeName, TestType1.class
);
           final TypeDefinition typeDef = new TypeDefinition( typeName, TestDataType.ROLE,
typeFactory );
   
  -        final TypeLibraryDeployer typeDeployer = getTestDeployer();
  -
           // Make sure the test types have not been deployed.  Do this after
           // the deployer has been created
           assertTypesNotRegistered();
   
           // Deploy the type
  -        typeDeployer.deployType( typeDef );
  +        m_deployer.deployType( TEST_NAMESPACE, typeDef );
   
           // Check the type has been registered
           assertTypeRegistered( TestDataType.ROLE, typeName, TestType1.class );
  @@ -128,14 +127,12 @@
           final TypeFactory typeFactory = new DefaultTypeFactory( converterName, TestConverter1.class
);
           final TypeDefinition typeDef = new TypeDefinition( converterName, Converter.ROLE,
typeFactory, typeDefAttrs );
   
  -        final TypeLibraryDeployer typeDeployer = getTestDeployer();
  -
           // Make sure the test types have not been deployed.  Do this after
           // the deployer has been created
           assertTypesNotRegistered();
   
           // Deploy the type
  -        typeDeployer.deployType( typeDef );
  +        m_deployer.deployType( TEST_NAMESPACE, typeDef );
   
           // Try to convert from string to test type
           final Object result = m_converter.convert( TestType1.class, "some-string", null
);
  @@ -161,45 +158,49 @@
       }
   
       /**
  -     * Ensures that the test types have not ben deployed.
  +     * Ensures that the test types have not been deployed.
        */
       private void assertTypesNotRegistered() throws Exception
       {
           // Check the data-type
  -        TypeFactory typeFactory = getTypeManager().getFactory( TestDataType.ROLE );
  -        try
  -        {
  -            typeFactory.create( TEST_TYPE1_NAME );
  -            fail();
  -        }
  -        catch( TypeException e )
  -        {
  -            // TODO - check error message
  -        }
  +        assertTypeNotRegistered( TestDataType.ROLE, TEST_TYPE1_NAME );
  +
  +        // Check the custom role implementation
  +        assertTypeNotRegistered( TestRole1.ROLE, TEST_TYPE1_NAME );
  +
  +        // Check the converter
           try
           {
  -            typeFactory.create( getQualifiedName( TEST_TYPE1_NAME ) );
  +            m_converter.convert( TestType1.class, "some string", null );
               fail();
           }
  -        catch( TypeException e )
  +        catch( ConverterException e )
           {
               // TODO - check error message
           }
  +    }
   
  -        // Check the custom role implementation
  -        typeFactory = getTypeManager().getFactory( TestRole1.ROLE );
  +    /**
  +     * Ensures that a test tyoe has not been deployed.
  +     */
  +    private void assertTypeNotRegistered( final String role, final String typeName )
  +        throws Exception
  +    {
  +        TypeFactory typeFactory;
           try
           {
  -            typeFactory.create( TEST_TYPE1_NAME );
  -            fail();
  +            typeFactory = getTypeManager().getFactory( role );
           }
  -        catch( TypeException e )
  +        catch( final Exception e )
           {
  -            // TODO - check error message
  +            // Role is not registered
  +            return;
           }
  +
  +        // Check unqualified name
           try
           {
  -            typeFactory.create( getQualifiedName( TEST_TYPE1_NAME ) );
  +            typeFactory.create( typeName );
               fail();
           }
           catch( TypeException e )
  @@ -207,13 +208,13 @@
               // TODO - check error message
           }
   
  -        // Check the converter
  +        // Check qualified name
           try
           {
  -            m_converter.convert( TestType1.class, "some string", null );
  +            typeFactory.create( getQualifiedName( typeName ) );
               fail();
           }
  -        catch( ConverterException e )
  +        catch( TypeException e )
           {
               // TODO - check error message
           }
  
  
  

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


Mime
View raw message