avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/test PackageRepositoryTestCase.java
Date Sat, 17 Nov 2001 01:02:31 GMT
donaldp     01/11/16 17:02:31

  Modified:    src/scratchpad/org/apache/avalon/excalibur/extension/test
                        PackageRepositoryTestCase.java
  Log:
  Update unit test to test for a few more cases and to use the new API.
  
  Revision  Changes    Path
  1.5       +55 -4     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/test/PackageRepositoryTestCase.java
  
  Index: PackageRepositoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/test/PackageRepositoryTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PackageRepositoryTestCase.java	2001/11/12 13:04:49	1.4
  +++ PackageRepositoryTestCase.java	2001/11/17 01:02:31	1.5
  @@ -8,6 +8,7 @@
   package org.apache.avalon.excalibur.extension.test;
   
   import java.io.File;
  +import java.io.IOException;
   import java.io.InputStream;
   import java.util.ArrayList;
   import java.util.jar.Manifest;
  @@ -23,20 +24,70 @@
    * TestCases for PackageRepository.
    *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
  - * @version $Revision: 1.4 $ $Date: 2001/11/12 13:04:49 $
  + * @version $Revision: 1.5 $ $Date: 2001/11/17 01:02:31 $
    */
   public class PackageRepositoryTestCase
       extends TestCase
   {
  +    private File m_baseDirectory;
  +    private File m_pathElement1;
  +    private File m_pathElement2;
  +    private File[] m_path;
  +
       public PackageRepositoryTestCase( String name )
  +        throws IOException
       {
           super( name );
  +
  +        m_baseDirectory = 
  +            (new File( "../../src/scratchpad/org/apache/avalon/excalibur/extension/test/"
)).getCanonicalFile();
  +        
  +        m_pathElement1 = new File( m_baseDirectory, "path1" );
  +        m_pathElement2 = new File( m_baseDirectory, "path2" );
  +        m_path = new File[] { m_pathElement1, m_pathElement2 };
  +    }
  +
  +    public void testGoodPath()
  +        throws Exception
  +    {
  +        final DefaultPackageRepository repository = new DefaultPackageRepository( m_path
);
       }
   
  -    public void testScanDependencies()
  +    public void testBadPath()
           throws Exception
       {
  +        try
  +        {
  +            final File pathElement3 = new File( m_baseDirectory, "path3" );
  +            final File[] path = new File[] { m_pathElement1, m_pathElement2, pathElement3
};
  +            final DefaultPackageRepository repository = 
  +                new DefaultPackageRepository( path );
  +        }
  +        catch( final IllegalArgumentException iae )
  +        {
  +            return;
  +        }
  +        
  +        assertTrue( "Exceptected to fail with bad path element", false );
  +    }
  +
  +    public void testBasicScanDependencies()
  +        throws Exception
  +    {
           final PackageRepository repository = newPackagerepository();
  +        doRepositoryTest( repository );
  +    }
  +
  +    public void testFSScanDependencies()
  +        throws Exception
  +    {
  +        final PackageRepository repository = new DefaultPackageRepository( m_path );
  +        doRepositoryTest( repository );
  +    }
  +    
  +    private void doRepositoryTest( final PackageRepository repository )
  +        throws Exception
  +    {
           final PackageRepository[] repositorys = new PackageRepository[] { repository };
           final PackageManager manager = new PackageManager( repositorys );
   
  @@ -46,7 +97,7 @@
           final ArrayList dependencies = new ArrayList();
           final ArrayList unsatisfied = new ArrayList();
   
  -        manager.scanDependencies( extension1, dependencies, unsatisfied );
  +        manager.scanDependencies( extension1, new Extension[ 0 ], dependencies, unsatisfied
);
           System.out.println( "dependencies: " + dependencies );
           
           assertEquals( "dependencies Count", 2, dependencies.size() );
  @@ -98,7 +149,7 @@
       TestPackageRepository()
           throws Exception
       {
  -        super( new File( "." ) );
  +        super( new File[ 0 ] );
       }
   
       void addEntry( final String manifestLocation )
  @@ -110,6 +161,6 @@
           final Extension[] available = Extension.getAvailableExtensions( manifest );
           final Extension[] required = Extension.getRequiredExtensions( manifest );
   
  -        cacheOptionalPackage( new OptionalPackage( file, available, required ) );
  +        addOptionalPackage( new OptionalPackage( file, available, required ) );
       }
   }
  
  
  

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