avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/model/test CategoryTestCase.java ContextDirectiveTestCase.java EntryTestCase.java ImportTestCase.java LoggingDirectiveTestCase.java ModelExceptionTestCase.java ModelRuntimeExceptionTestCase.java ParameterTestCase.java ProfileTestCase.java
Date Thu, 10 Jul 2003 19:41:21 GMT
mcconnell    2003/07/10 12:41:21

  Modified:    merlin/meta-spi/src/java/org/apache/avalon/meta/data
                        CategoriesDirective.java CategoryDirective.java
                        ContextDirective.java EntryDirective.java
                        ImportDirective.java Parameter.java
  Added:       merlin/meta-spi/src/java/org/apache/avalon/meta/data
                        ConstructorDirective.java
               merlin/meta-spi/src/test/org/apache/avalon/meta/data/test
                        CategoryDirectiveTestCase.java
                        ConstructorDirectiveTestCase.java
                        ContextDirectiveTestCase.java
                        ImportDirectiveTestCase.java
                        MetaDataExceptionTestCase.java
                        ParameterTestCase.java
  Removed:     merlin/meta-spi/src/test/org/apache/avalon/meta/model/test
                        CategoryTestCase.java ContextDirectiveTestCase.java
                        EntryTestCase.java ImportTestCase.java
                        LoggingDirectiveTestCase.java
                        ModelExceptionTestCase.java
                        ModelRuntimeExceptionTestCase.java
                        ParameterTestCase.java ProfileTestCase.java
  Log:
  Moved model test-cases to meta-data package and refactored the context entry, import and constructor directives.
  
  Revision  Changes    Path
  1.2       +9 -2      avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/CategoriesDirective.java
  
  Index: CategoriesDirective.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/CategoriesDirective.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CategoriesDirective.java	3 Jul 2003 04:28:55 -0000	1.1
  +++ CategoriesDirective.java	10 Jul 2003 19:41:21 -0000	1.2
  @@ -103,7 +103,14 @@
                                    final CategoryDirective[] categories )
       {
           super( name, priority, target );
  -        m_categories = categories;
  +        if( categories == null )
  +        {
  +            m_categories = new CategoryDirective[ 0 ]; 
  +        }
  +        else
  +        {
  +            m_categories = categories;
  +        }
       }
   
       /**
  
  
  
  1.2       +27 -11    avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/CategoryDirective.java
  
  Index: CategoryDirective.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/CategoryDirective.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CategoryDirective.java	3 Jul 2003 04:28:55 -0000	1.1
  +++ CategoryDirective.java	10 Jul 2003 19:41:21 -0000	1.2
  @@ -98,16 +98,6 @@
       public static final String ERROR = "ERROR";
   
       /**
  -     * Constant value for the default logging target name.
  -     */
  -    public static final String DEFAULT_LOGGING_TARGET = "default";
  -
  -    /**
  -     * Constant value for the default logging priority level.
  -     */
  -    public static final String DEFAULT_LOGGING_PRIORITY = INFO;
  -
  -    /**
        * The logging category name.
        */
       private String m_name;
  @@ -195,5 +185,31 @@
       public String getTarget()
       {
           return m_target;
  +    }
  +
  +    public boolean equals(Object other)
  +    {
  +        boolean isEqual = other instanceof CategoryDirective;
  +
  +        if ( isEqual )
  +        {
  +            CategoryDirective test = (CategoryDirective) other;
  +            isEqual = m_name.equals(test.m_name);
  +            if (isEqual) isEqual = m_priority.equals(test.m_priority);
  +            if (isEqual) isEqual = m_target.equals(test.m_target);
  +        }
  +
  +        return isEqual;
  +    }
  +
  +    public int hashCode()
  +    {
  +        int hash = m_name.hashCode();
  +        hash >>>= 13;
  +        hash ^= m_priority.hashCode();
  +        hash >>>= 5;
  +        hash ^= m_target.hashCode();
  +
  +        return hash;
       }
   }
  
  
  
  1.4       +21 -3     avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ContextDirective.java
  
  Index: ContextDirective.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ContextDirective.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContextDirective.java	9 Jul 2003 11:39:28 -0000	1.3
  +++ ContextDirective.java	10 Jul 2003 19:41:21 -0000	1.4
  @@ -96,10 +96,28 @@
        * @param imports the set of import directives
        * @param entries the set of entry descriptors
        */
  +    public ContextDirective( final EntryDirective[] entries )
  +    {
  +        this( null, entries );
  +    }
  +
  +    /**
  +     * Creation of a new file target.
  +     * @param classname the context implementation class
  +     * @param imports the set of import directives
  +     * @param entries the set of entry descriptors
  +     */
       public ContextDirective( final String classname, final EntryDirective[] entries )
       {
  -        m_entries = entries;
           m_classname = classname;
  +        if( entries != null )
  +        {
  +            m_entries = entries;
  +        }
  +        else
  +        {
  +            m_entries = new EntryDirective[0];
  +        }
       }
   
       /**
  @@ -115,7 +133,7 @@
        * Return the set of entry directives.
        * @return the entries
        */
  -    public EntryDirective[] getEntries()
  +    public EntryDirective[] getEntryDirectives()
       {
           return m_entries;
       }
  
  
  
  1.3       +3 -63     avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/EntryDirective.java
  
  Index: EntryDirective.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/EntryDirective.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EntryDirective.java	9 Jul 2003 11:39:28 -0000	1.2
  +++ EntryDirective.java	10 Jul 2003 19:41:21 -0000	1.3
  @@ -83,58 +83,25 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class EntryDirective implements Serializable
  +public abstract class EntryDirective implements Serializable
   {
  -     public static final int IMPORT = 0;
  -
  -     public static final int PARAM = 1;
  -
  -     public static final int PROVIDER = 2;
  -
       /**
        * The entry key.
        */
       private final String m_key;
   
  -    private final ImportDirective m_target;
  -
  -    private final Parameter m_param;
  -
  -    private final int m_mode;
  -
       /**
        * Creation of a new entry directive using a import directive.
        * @param key the entry key
        * @param target the import directive defining the target key name
        */
  -    public EntryDirective( final String key, final ImportDirective target )
  -    {
  -        if( null == key )
  -        {
  -            throw new NullPointerException( "key" );
  -        }
  -        m_key = key;
  -        m_target = target;
  -        m_mode = IMPORT;
  -        m_param = null;
  -    }
  -
  -    /**
  -     * Creation of a new entry directive using a parameter.
  -     * @param key the entry key
  -     * @param classname the classname of the entry implementation
  -     * @param parameters implementation class constructor parameter directives
  -     */
  -    public EntryDirective( final String key, final Parameter parameter )
  +    public EntryDirective( final String key )
       {
           if( null == key )
           {
               throw new NullPointerException( "key" );
           }
           m_key = key;
  -        m_param = parameter;
  -        m_mode = PARAM;
  -        m_target = null;
       }
   
       /**
  @@ -144,32 +111,5 @@
       public String getKey()
       {
           return m_key;
  -    }
  -
  -    /**
  -     * Return the entry mode (IMPORT, PARAM or PROVIDER)
  -     * @return the mode
  -     */
  -    public int getMode()
  -    {
  -        return m_mode;
  -    }
  -
  -    /**
  -     * Return the import directive if the mode is IMPORT else null.
  -     * @return the directive
  -     */
  -    public ImportDirective getImportDirective()
  -    {
  -        return m_target;
  -    }
  -
  -    /**
  -     * Return the parameter directive if the mode is PARAM else null.
  -     * @return the directive
  -     */
  -    public Parameter getParameter()
  -    {
  -        return m_param;
       }
   }
  
  
  
  1.3       +12 -11    avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ImportDirective.java
  
  Index: ImportDirective.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ImportDirective.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImportDirective.java	9 Jul 2003 11:39:28 -0000	1.2
  +++ ImportDirective.java	10 Jul 2003 19:41:21 -0000	1.3
  @@ -80,33 +80,34 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class ImportDirective implements Serializable
  +public class ImportDirective extends EntryDirective
   {
       /**
  -     * The local key.
  +     * The container scoped key.
        */
       private final String m_key;
   
       /**
        * Creation of a new entry directive.
  -     * @param key the container scope key value to import
  +     * @param component the componet entry key
  +     * @param container the container scope key value to import
        */
  -    public ImportDirective( final String key )
  +    public ImportDirective( final String key, final String containerKey )
       {
  -        if( null == key )
  +        super( key );
  +        if( null == containerKey )
           {
               throw new NullPointerException( "key" );
           }
  -        m_key = key;
  +        m_key = containerKey;
       }
   
       /**
  -     * Return the key that will be used by a client of a context object to
  -     * access the inported value.
  +     * Return the container scoped key that defines the object to be imported.
        *
  -     * @return the local context key
  +     * @return the contain scoped key
        */
  -    public String getKey()
  +    public String getImportKey()
       {
           return m_key;
       }
  
  
  
  1.2       +16 -7     avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/Parameter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Parameter.java	3 Jul 2003 04:28:55 -0000	1.1
  +++ Parameter.java	10 Jul 2003 19:41:21 -0000	1.2
  @@ -122,8 +122,13 @@
        */
       public Parameter( final String value )
       {
  +        if( null == value )
  +        {
  +            throw new NullPointerException( "value" );
  +        }
  +
  +        m_classname = "java.lang.String";
           m_parameters = new Parameter[ 0 ];
  -        m_classname = null;
           m_argument = value;
       }
   
  @@ -134,18 +139,18 @@
        */
       public Parameter( final String classname, final String value )
       {
  -        if( null == classname )
  +        if( null == value )
           {
  -            throw new NullPointerException( "classname" );
  +            throw new NullPointerException( "value" );
           }
   
  -        if( null == value )
  +        if( null == classname )
           {
  -            throw new NullPointerException( "value" );
  +            throw new NullPointerException( "classname" );
           }
   
  -        m_parameters = new Parameter[ 0 ];
           m_classname = classname;
  +        m_parameters = new Parameter[ 0 ];
           m_argument = value;
       }
   
  @@ -159,6 +164,10 @@
           if( null == classname )
           {
               throw new NullPointerException( "classname" );
  +        }
  +        if( null == parameters )
  +        {
  +            throw new NullPointerException( "parameters" );
           }
   
           m_classname = classname;
  
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ConstructorDirective.java
  
  Index: ConstructorDirective.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 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", "Apache Avalon", "Avalon Framework" 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.meta.data;
  
  
  /**
   * A entry descriptor declares the context entry import or creation criteria for
   * a single context entry instance.
   *
   * <p><b>XML</b></p>
   * <p>A entry may contain either (a) a single nested import directive, or (b) a single param constructor directives.</p>
   * <pre>
   *  <font color="gray">&lt;context&gt;</font>
   *
   *    &lt!-- option (a) nested import -->
   *    &lt;entry key="<font color="darkred">my-home-dir</font>"&gt;
   *       &lt;include key="<font color="darkred">urn:avalon:home</font>"/&gt;
   *    &lt;/entry&gt;
   *
   *    &lt!-- option (b) param constructors -->
   *    &lt;entry key="<font color="darkred">title</font>"&gt;
   *       &lt;param&gt;<font color="darkred">Lord of the Rings</font>&lt;/&gt;
   *    &lt;/entry&gt;
   *    &lt;entry key="<font color="darkred">home</font>"&gt;
   *      &lt;param class="<font color="darkred">java.io.File</font>"&gt;<font color="darkred">../home</font>&lt;/param&gt;
   *    &lt;/entry&gt;
   *
   *  <font color="gray">&lt;/context&gt;</font>
   * </pre>
   *
   * @see ImportDirective
   * @see Parameter
   * @see ContextDirective
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/07/10 19:41:21 $
   */
  public class ConstructorDirective extends EntryDirective
  {
      /**
       * The constructor classname.
       */
      private final String m_classname;
  
      /**
       * The constructor param.
       */
      private final Parameter[] m_params;
  
      /**
       * The alternative argument.
       */
      private final String m_argument;
  
      /**
       * Creation of a new entry directive using a constructor
       * classname and single argument value.
       * @param key the entry key
       * @param classname the classname of the entry implementation
       * @param value the single argument value
       */
      public ConstructorDirective( 
        final String key, final String value )
      {
          this( key, "java.lang.String", value );
      }
  
      /**
       * Creation of a new entry directive using a constructor
       * classname and single argument value.
       * @param key the entry key
       * @param classname the classname of the entry implementation
       * @param value the single argument value
       */
      public ConstructorDirective( 
        final String key, final String classname, final String value )
      {
          super( key );
          if( null == classname )
          {
              throw new NullPointerException( "classname" );
          }
          if( null == value )
          {
              throw new NullPointerException( "value" );
          }
  
          m_params = new Parameter[0];
          m_classname = "java.lang.String";
          m_argument = value;
      }
  
      /**
       * Creation of a new entry directive using a parameter.
       * @param key the entry key
       * @param classname the classname of the entry implementation
       * @param parameters implementation class constructor parameter directives
       */
      public ConstructorDirective( final String key, final Parameter[] parameters )
      {
          this( key, "java.lang.String", parameters );
      }
  
      /**
       * Creation of a new entry directive using a parameter.
       * @param key the entry key
       * @param classname the classname of the entry implementation
       * @param params implementation class constructor parameter directives
       */
      public ConstructorDirective( 
        final String key, final String classname, final Parameter[] params )
      {
          super( key );
          if( null == params )
          {
              throw new NullPointerException( "parameters" );
          }
          if( null == classname )
          {
              throw new NullPointerException( "classname" );
          }
          if( params.length == 0 )
          {
              throw new IllegalArgumentException( "parameters" );
          }
  
          m_classname = classname;
          m_params = params;
          m_argument = null;
      }
  
      /**
       * Return the constructor classname
       * @return the classname
       */
      public String getClassname()
      {
          return m_classname;
      }
  
      /**
       * Return the parameter directive if the mode is PARAM else null.
       * @return the directive
       */
      public Parameter[] getParameters()
      {
          return m_params;
      }
  
      /**
       * Return the constructor classname
       * @return the classname
       */
      public String getArgument()
      {
          return m_argument;
      }
  }
  
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/CategoryDirectiveTestCase.java
  
  Index: CategoryDirectiveTestCase.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.meta.data.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.data.CategoryDirective;
  
  import java.io.*;
  
  /**
   * CategoryTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class CategoryDirectiveTestCase extends TestCase
  {
      public CategoryDirectiveTestCase( String name )
      {
          super( name );
      }
  
      public void testCategory()
      {
          String catName = "name";
          CategoryDirective cat = new CategoryDirective(catName);
  
          testCategory( cat, catName, null, null );
      }
  
      public void testLogPriority()
      {
          String catName = "name";
          String priority = CategoryDirective.DEBUG;
          CategoryDirective cat = new CategoryDirective( catName, priority);
  
          testCategory( cat, catName, priority, null );
  
          priority = CategoryDirective.ERROR;
          cat = new CategoryDirective( catName, priority );
  
          testCategory( cat, catName, priority, null );
  
          priority = CategoryDirective.INFO;
          cat = new CategoryDirective( catName, priority );
  
          testCategory( cat, catName, priority, null );
  
          priority = CategoryDirective.WARN;
          cat = new CategoryDirective( catName, priority );
  
          testCategory( cat, catName, priority, null );
      }
  
      public void testLogTarget()
      {
          String name = "name";
          String priority = CategoryDirective.DEBUG;
          String target = "test";
          CategoryDirective cat = new CategoryDirective( name, priority, target);
  
          testCategory( cat, name, priority, target );
      }
  
      private void testCategory( CategoryDirective cat, String name, String priority, String target )
      {
          assertEquals( name, cat.getName() );
          assertEquals( priority, cat.getPriority() );
          assertEquals( target, cat.getTarget() );
      }
  
      public void testSerialization() throws IOException, ClassNotFoundException
      {
          File file = new File("name.test");
          String name = "name";
          String priority = CategoryDirective.WARN;
          String target = "test";
  
          CategoryDirective original = new CategoryDirective( name, priority, target );
  
          testCategory( original, name, priority, target );
  
          ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
          oos.writeObject(original);
          oos.close();
  
          ObjectInputStream ois = new ObjectInputStream( new FileInputStream(file));
          CategoryDirective serialized = (CategoryDirective)ois.readObject();
          ois.close();
  
          file.delete();
  
          testCategory( serialized, name, priority, target );
  
          assertEquals( original, serialized );
          assertEquals( original.hashCode(), serialized.hashCode() );
      }
  }
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/ConstructorDirectiveTestCase.java
  
  Index: ConstructorDirectiveTestCase.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.meta.data.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.data.MetaDataException;
  import org.apache.avalon.meta.data.Parameter;
  import org.apache.avalon.meta.data.EntryDirective;
  import org.apache.avalon.meta.data.ConstructorDirective;
  
  import java.util.HashMap;
  
  /**
   * ConstructorDirectiveTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class ConstructorDirectiveTestCase extends TestCase
  {
      public ConstructorDirectiveTestCase( String name )
      {
          super( name );
      }
  
      public void testEntry() throws MetaDataException
      {
          String key = "key";
  
          String className = ConstructorDirectiveTestCase.class.getName();
          String value = "val";
          Parameter param = new Parameter( value );
          Parameter[] params = new Parameter[]{ param };
  
          try
          {
              new ConstructorDirective( null, (String) null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new ConstructorDirective( null, (Parameter[]) null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new ConstructorDirective( null, (String)null, (Parameter[]) null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
  
          try
          {
              new ConstructorDirective( null, params );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new ConstructorDirective( key, (String) null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new ConstructorDirective( key, (Parameter[]) null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          ConstructorDirective entry = new ConstructorDirective( key, className, params );
          assertEquals( key, entry.getKey() );
          assertEquals( params, entry.getParameters() );
          assertEquals( className, entry.getClassname() );
      }
  }
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/ContextDirectiveTestCase.java
  
  Index: ContextDirectiveTestCase.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.meta.data.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.data.ImportDirective;
  import org.apache.avalon.meta.data.EntryDirective;
  import org.apache.avalon.meta.data.ContextDirective;
  
  /**
   * ContextDirectiveTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class ContextDirectiveTestCase extends TestCase
  {
      public ContextDirectiveTestCase( String name )
      {
          super( name );
      }
  
      public void testConstructor()
      {
          try
          {
              new ContextDirective( null );
          }
          catch(NullPointerException npe)
          {
              fail("NullPointerException should not be thrown - null indicates default");
          }
  
          try
          {
              new ContextDirective( null, new EntryDirective[0] );
          }
          catch(NullPointerException npe)
          {
              fail("NullPointerException should not be thrown - null indicates default");
          }
  
          try
          {
              new ContextDirective( null, null );
          }
          catch ( NullPointerException npe )
          {
              fail("NullPointerException should not be thrown - null indicated default");
          }
      }
  
      public void testContextDirective()
      {
          EntryDirective[] entries = new EntryDirective[0];
          ContextDirective cd = new ContextDirective( getClass().getName(), entries);
  
          assertEquals( "classname", getClass().getName(), cd.getClassname());
          assertEquals( "entries", entries, cd.getEntryDirectives());
          assertEquals( "length", entries.length, cd.getEntryDirectives().length);
      }
  
      public void testGetEntry()
      {
          String key = "key";
          String val = "val";
          ImportDirective imp = new ImportDirective( key, "xxx" );
          EntryDirective[] entries = 
            new EntryDirective[]{ imp };
          ContextDirective cd = new ContextDirective( entries );
  
          assertNull( cd.getClassname() );
          assertEquals( entries, cd.getEntryDirectives() );
          assertEquals( entries.length, cd.getEntryDirectives().length );
          assertEquals( entries[0], cd.getEntryDirective( key ) );
          assertNull( cd.getEntryDirective( val ) );
      }
  }
  
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/ImportDirectiveTestCase.java
  
  Index: ImportDirectiveTestCase.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.meta.data.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.data.MetaDataException;
  import org.apache.avalon.meta.data.ImportDirective;
  import org.apache.avalon.meta.data.EntryDirective;
  
  import java.util.HashMap;
  
  /**
   * ImportDirectiveTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class ImportDirectiveTestCase extends TestCase
  {
      public ImportDirectiveTestCase( String name )
      {
          super( name );
      }
  
      public void testEntry() throws MetaDataException
      {
          String key = "key";
          String imp = "container-scoped-key";
  
          try
          {
              new ImportDirective( null, null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new ImportDirective( null, imp );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new ImportDirective( key, null );
              fail( "Did not throw expected NullPointerException" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          ImportDirective entry = new ImportDirective( key, imp );
          assertEquals( key, entry.getKey() );
          assertEquals( imp, entry.getImportKey() );
      }
  }
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/MetaDataExceptionTestCase.java
  
  Index: MetaDataExceptionTestCase.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.meta.data.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.data.MetaDataException;
  
  /**
   * MetaDataExceptionTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class MetaDataExceptionTestCase extends TestCase
  {
      public MetaDataExceptionTestCase( String name )
      {
          super( name );
      }
  
      public void testMetaDataException()
      {
          String message = "Original Message";
          Exception parent = new Exception("Parent Exception");
          MetaDataException me = new MetaDataException( message );
  
          assertNotNull( me );
          assertNull( me.getCause() );
          assertEquals( message, me.getMessage() );
  
          me = new MetaDataException( message, parent );
  
          assertNotNull( me );
          assertEquals( parent, me.getCause() );
          assertEquals( message, me.getMessage() );
      }
  }
  
  
  1.1                  avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/ParameterTestCase.java
  
  Index: ParameterTestCase.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.meta.data.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.data.Parameter;
  import org.apache.avalon.meta.data.MetaDataException;
  
  import java.util.Map;
  import java.util.HashMap;
  import java.lang.reflect.Constructor;
  
  /**
   * ParameterTestCase does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class ParameterTestCase extends TestCase
  {
      public ParameterTestCase( String name )
      {
          super( name );
      }
  
      public void testParameters() throws MetaDataException
      {
          String className = ParameterTestCase.class.getName();
          String value = "val";
          Parameter[] params = new Parameter[] {
              new Parameter( "java.io.File", value ),
              new Parameter( ParameterTestCase.class.getName(), value )
          };
  
          try
          {
              new Parameter(null);
              fail("Did not throw expected NullPointerException/1");
          }
          catch (NullPointerException npe)
          {
              // Success!!
          }
  
          try
          {
              new Parameter( null, value );
              fail( "Did not throw expected NullPointerException/2" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new Parameter( className, (String)null );
              fail( "Did not throw expected NullPointerException/3" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new Parameter( null, params );
              fail( "Did not throw expected NullPointerException/4" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          try
          {
              new Parameter( className, (Parameter[]) null );
              fail( "Did not throw expected NullPointerException/5" );
          }
          catch ( NullPointerException npe )
          {
              // Success!!
          }
  
          Parameter param = new Parameter( value );
          assertEquals( String.class.getName(), param.getClassname());
  
          param = new Parameter( className, params );
          assertEquals( className, param.getClassname() );
          assertEquals( params.length, param.getParameters().length );
          assertEquals( params.length, param.getParameters().length );
          assertEquals( "java.io.File", param.getParameters()[0].getClassname() );
          assertEquals( ParameterTestCase.class.getName(), param.getParameters()[1].getClassname() );
  
      }
  }
  
  

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


Mime
View raw message