You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/03/07 20:35:47 UTC

cvs commit: avalon-excalibur/component/src/test/org/apache/avalon/excalibur/testcase/test ComponentTestCase.java

bloritsch    2003/03/07 11:35:47

  Modified:    component build.xml default.properties
  Added:       component/src/test/org/apache/avalon/excalibur/testcase/test
                        ComponentTestCase.java
  Log:
  finish merge of component and testcase
  
  Revision  Changes    Path
  1.38      +27 -4     avalon-excalibur/component/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/component/build.xml,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- build.xml	7 Mar 2003 17:35:45 -0000	1.37
  +++ build.xml	7 Mar 2003 19:35:47 -0000	1.38
  @@ -40,7 +40,6 @@
       <path id="test.class.path">
           <pathelement location="${build.testclasses}"/>
           <pathelement location="${junit.jar}"/>
  -        <pathelement location="${excalibur-testcase.jar}"/>
           <pathelement location="${excalibur-i18n.jar}"/>
           <path refid="project.class.path"/>
       </path>
  @@ -85,7 +84,6 @@
           <!-- Need the jar to prevent recursive deps. -->
   
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkJUnit"/>
  -        <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkTestcase"/>
       </target>
   
       <target name="servlet-warn" unless="servlet.present"
  @@ -172,6 +170,29 @@
                   <filter token="year" value="${year}"/>
               </filterset>
           </copy>
  +</target>
  +
  +    <target name="jar-testcase" depends="compile, prepare-conf" description="Generates the testlet jar file">
  +        <mkdir dir="${build.lib}"/>
  +
  +        <jar jarfile="${build.lib}/${jar.testcase.name}"
  +            basedir="${build.classes}"
  +            compress="${build.compress}">
  +            <manifest>
  +              <attribute name="Extension-Name" value="${name.testcase}"/>
  +              <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
  +              <attribute name="Specification-Version" value="1.0"/>
  +              <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
  +              <attribute name="Implementation-Vendor-Id" value="ASF"/>
  +              <attribute name="Implementation-Version" value="${package-version}"/>
  +            </manifest>
  +	    <include name="**/testcase/**"/>
  +	    <exclude name="**/component/servlet/**"/>
  +            <exclude name="**/test/**"/>
  +            <zipfileset dir="${build.conf}" prefix="META-INF/">
  +                <include name="LICENSE.txt"/>
  +            </zipfileset>
  +        </jar>
       </target>
   
       <!-- Creates all the servlet .jar file -->
  @@ -191,6 +212,7 @@
                 <attribute name="Implementation-Vendor-Id" value="ASF"/>
                 <attribute name="Implementation-Version" value="${package-version}"/>
               </manifest>
  +	    <exclude name="**/testcase/**"/>
               <include name="**/component/servlet/**"/>
               <exclude name="**/test/**"/>
               <zipfileset dir="${build.conf}" prefix="META-INF/">
  @@ -200,7 +222,7 @@
       </target>
   
       <!-- Creates all the .jar file -->
  -    <target name="jar" depends="compile, prepare-conf, jar-servlet" description="Generates the jar files">
  +    <target name="jar" depends="compile, prepare-conf, jar-servlet, jar-testcase" description="Generates the jar files">
   
           <mkdir dir="${build.lib}"/>
   
  @@ -215,7 +237,8 @@
                 <attribute name="Implementation-Vendor-Id" value="ASF"/>
                 <attribute name="Implementation-Version" value="${package-version}"/>
               </manifest>
  -            <exclude name="**/component/servlet/**"/>
  +	    <exclude name="**/component/servlet/**"/>
  +	    <exclude name="**/testcase/**"/>
               <exclude name="**/test/**"/>
               <zipfileset dir="${build.conf}" prefix="META-INF/">
                   <include name="LICENSE.txt"/>
  
  
  
  1.26      +2 -5      avalon-excalibur/component/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/component/default.properties,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- default.properties	5 Mar 2003 04:03:23 -0000	1.25
  +++ default.properties	7 Mar 2003 19:35:47 -0000	1.26
  @@ -7,6 +7,7 @@
   
   name=excalibur-component
   name.servlet=excalibur-component-servlet
  +name.testcase=excalibur-testcase
   Name=Excalibur Component
   dir-name=component
   version=1.1
  @@ -79,11 +80,6 @@
   
   # For unit testing:
   
  -# ----- Excalibur testcase, version 1.0 or later -----
  -excalibur-testcase.home=${basedir}/../testcase/dist
  -excalibur-testcase.lib=${excalibur-testcase.home}
  -excalibur-testcase.jar=${excalibur-testcase.lib}/excalibur-testcase-1.0.jar
  -
   # --------------------------------------------------
   
   #  Settings used to configure compile environment
  @@ -129,6 +125,7 @@
   #  name of jar file
   jar.name = ${name}-${version}.jar
   jar.servlet.name = ${name}-servlet-${version}.jar
  +jar.testcase.name = ${name.testcase}-${version}.jar
   
   #  property indicating directory where all distribution archives are placed
   dist.base = distributions
  
  
  
  1.1                  avalon-excalibur/component/src/test/org/apache/avalon/excalibur/testcase/test/ComponentTestCase.java
  
  Index: ComponentTestCase.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.testcase.test;
  
  import junit.framework.TestCase;
  
  import org.apache.avalon.excalibur.testcase.FullLifecycleComponent;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.logger.NullLogger;
  import org.apache.avalon.framework.parameters.Parameters;
  
  /**
   * This class provides basic facilities for enforcing Avalon's contracts
   * within your own code.
   *
   * @author <a href="bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/03/07 19:35:47 $
   */
  public final class ComponentTestCase
      extends TestCase
  {
      public ComponentTestCase( String test )
      {
          super( test );
      }
  
      public void testCorrectLifecycle()
          throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          component.contextualize( new DefaultContext() );
          component.configure( new DefaultConfiguration( "", "" ) );
          component.parameterize( new Parameters() );
          component.initialize();
          component.start();
          component.suspend();
          component.resume();
          component.stop();
          component.dispose();
      }
  
      public void testMissingLogger()
          throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          try
          {
              component.contextualize( new DefaultContext() );
          }
          catch( Exception e )
          {
              return;
          }
          fail( "Did not detect missing logger" );
      }
  
      public void testOutOfOrderInitialize()
          throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          component.contextualize( new DefaultContext() );
          try
          {
              component.initialize();
              component.parameterize( new Parameters() );
          }
          catch( Exception e )
          {
              return;
          }
          fail( "Did not detect out of order initialization" );
      }
  
      public void testOutOfOrderDispose()
          throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          component.contextualize( new DefaultContext() );
          component.configure( new DefaultConfiguration( "", "" ) );
          component.parameterize( new Parameters() );
          component.initialize();
          component.start();
          component.suspend();
          component.resume();
  
          try
          {
              component.dispose();
              component.stop();
          }
          catch( Exception e )
          {
              return;
          }
          fail( "Did not detect out of order disposal" );
      }
  
      public void testDoubleAssignOfLogger()
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          try
          {
              component.enableLogging( new NullLogger() );
              component.enableLogging( new NullLogger() );
          }
          catch( Exception e )
          {
              // test successfull
              return;
          }
  
          fail( "Did not detect double assignment of Logger" );
      }
  
      public void testDoubleAssignOfContext()
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          try
          {
              component.contextualize( new DefaultContext() );
              component.contextualize( new DefaultContext() );
          }
          catch( Exception e )
          {
              // test successfull
              return;
          }
  
          fail( "Did not detect double assignment of Context" );
      }
  
      public void testDoubleAssignOfParameters()
          throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          component.contextualize( new DefaultContext() );
          component.configure( new DefaultConfiguration( "", "" ) );
  
          try
          {
              component.parameterize( new Parameters() );
              component.parameterize( new Parameters() );
          }
          catch( Exception e )
          {
              // test successfull
              return;
          }
  
          fail( "Did not detect double assignment of Parameters" );
      }
  
      public void testDoubleAssignOfConfiguration() throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          component.contextualize( new DefaultContext() );
          try
          {
              component.configure( new DefaultConfiguration( "", "" ) );
              component.configure( new DefaultConfiguration( "", "" ) );
          }
          catch( Exception e )
          {
              // test successfull
              return;
          }
  
          fail( "Did not detect double assignment of Configuration" );
      }
  
      /*public void testDoubleAssignOfComponentManger()
          throws Exception
      {
          FullLifecycleComponent component = new FullLifecycleComponent();
  
          component.enableLogging( new NullLogger() );
          component.contextualize( new DefaultContext() );
          try
          {
              component.compose( new DefaultComponentManager() );
              component.compose( new DefaultComponentManager() );
          }
          catch( Exception e )
          {
              // test successfull
              return;
          }
  
          fail( "Did not detect double assignment of ComponentLocator" );
      }*/
  }
  
  
  

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