mcconnell    2002/11/29 05:24:45

  Added:       assembly/src/test/org/apache/avalon/assembly/engine
                        EngineTestCase.java
  Log:
  Updating unit tests.
  
  Revision  Changes    Path
  1.1                  
avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java
  
  Index: EngineTestCase.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.assembly.engine;
  
  import java.io.File;
  import junit.framework.TestCase;
  import org.apache.avalon.framework.Version;
  import org.apache.avalon.framework.context.*;
  import org.apache.avalon.framework.logger.*;
  import org.apache.avalon.assembly.service.*;
  import org.apache.avalon.assembly.type.*;
  import org.apache.avalon.meta.info.*;
  import org.apache.avalon.assembly.TestCaseBase;
  import org.apache.avalon.assembly.engine.*;
  import org.apache.avalon.assembly.appliance.*;
  import org.apache.avalon.assembly.util.ExceptionHelper;
  
  /**
   * A testcase for the [EMAIL PROTECTED] DefaultEngine} implementation.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org";>Avalon Development 
Team</a>
   */
  public class EngineTestCase extends TestCaseBase
  {
  
      private Engine m_engine;
  
      public EngineTestCase()
      {
          this( "EngineTestCase" );
      }
  
      public EngineTestCase( String name )
      {
          super( name );
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
          DefaultEngine engine = new DefaultEngine();
          engine.enableLogging( getLogger() );
          engine.initialize();
          m_engine = engine;
      }
  
     /**
      * Test a component with custom context type and profile based import and 
entry creation directives.
      */
      public void testBasicComponent()
      {
          final String classname = 
"org.apache.avalon.playground.BasicComponent";
  
          ReferenceDescriptor reference = 
            new ReferenceDescriptor(
              "org.apache.avalon.playground.BasicService",
              Version.getVersion( "1.1" ) );
  
          DependencyDescriptor dependency = 
            new DependencyDescriptor( "test", reference );
            
          Appliance appliance = null;
          try
          {
              m_engine.register( classname );
              assertTrue( true );
              appliance = m_engine.resolve( dependency );
              assertTrue( appliance != null );
          }
          catch( Throwable e )
          {
              ExceptionHelper.printException( "Resolution failure.", e, 
appliance, true );
              assertTrue( false );
          }
  
          try
          {
              Object object = appliance.access( dependency );
              assertTrue( true );
          }
          catch( Throwable e )
          {
              ExceptionHelper.printException( "Access failure.", e, appliance, 
true );
              assertTrue( false );
          }
      }
  
     /**
      * Test a component with custom context type and profile based import and 
entry creation directives.
      */
      public void testSimpleComponent()
      {
          final String basic = "org.apache.avalon.playground.BasicComponent";
          final String simple = "org.apache.avalon.playground.SimpleComponent";
          final String exploiter = 
"org.apache.avalon.playground.ExploitationManager";
          final String demo = "org.apache.avalon.playground.DemoManager";
  
          ReferenceDescriptor reference = 
            new ReferenceDescriptor(
              "org.apache.avalon.playground.SimpleService",
              Version.getVersion( "1.1" ) );
  
          DependencyDescriptor dependency = 
            new DependencyDescriptor( "test", reference );
            
          Appliance appliance = null;
          try
          {
              m_engine.register( basic );
              m_engine.register( exploiter );
              m_engine.register( demo );
              m_engine.register( simple );
              assertTrue( true );
              appliance = m_engine.resolve( dependency );
              assertTrue( appliance != null );
          }
          catch( Throwable e )
          {
              System.out.println("failed to resolve : " + reference );
              ExceptionHelper.printException( "Resolution failure.", e, 
appliance, true );
              assertTrue( false );
          }
  
          try
          {
              Object object = appliance.access( dependency );
              assertTrue( true );
          }
          catch( Throwable e )
          {
              System.out.println("appliance access failure : " + reference );
              ExceptionHelper.printException( "Access failure.", e, appliance, 
true );
              assertTrue( false );
          }
      }
  
      protected void tearDown() throws Exception
      {
          m_loader = null;
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to