commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test FileSystemManagerFactoryTestCase.java
Date Mon, 24 Feb 2003 07:31:09 GMT
adammurdoch    2003/02/23 23:31:09

  Modified:    vfs/src/java/org/apache/commons/vfs/impl
                        StandardFileSystemManager.java providers.xml
               vfs/src/test/org/apache/commons/vfs/test
                        FileSystemManagerFactoryTestCase.java
  Log:
  Load mappings from mime-type and extension to URI scheme from config file.
  
  Revision  Changes    Path
  1.13      +37 -1     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java
  
  Index: StandardFileSystemManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StandardFileSystemManager.java	21 Feb 2003 05:12:03 -0000	1.12
  +++ StandardFileSystemManager.java	24 Feb 2003 07:31:08 -0000	1.13
  @@ -162,11 +162,47 @@
                   final Element provider = (Element)defProviders.item( 0 );
                   addProvider( provider, true );
               }
  +
  +            // Add the mime-type maps
  +            final NodeList mimeTypes = config.getElementsByTagName( "mime-type-map" );
  +            for ( int i = 0; i < mimeTypes.getLength(); i++ )
  +            {
  +                final Element map = (Element)mimeTypes.item( i );
  +                addMimeTypeMap( map );
  +            }
  +
  +            // Add the extension maps
  +            final NodeList extensions = config.getElementsByTagName( "extension-map" );
  +            for ( int i = 0; i < extensions.getLength(); i++ )
  +            {
  +                final Element map = (Element)extensions.item( i );
  +                addExtensionMap( map );
  +            }
           }
           catch ( final Exception e )
           {
               throw new FileSystemException( "vfs.impl/load-config.error", configUri, e );
           }
  +    }
  +
  +    /**
  +     * Adds an extension map.
  +     */
  +    private void addExtensionMap( final Element map )
  +    {
  +        final String extension = map.getAttribute( "extension" );
  +        final String scheme = map.getAttribute( "scheme" );
  +        addExtensionMap( extension, scheme );
  +    }
  +
  +    /**
  +     * Adds a mime-type map.
  +     */
  +    private void addMimeTypeMap( final Element map )
  +    {
  +        final String mimeType = map.getAttribute( "mime-type" );
  +        final String scheme = map.getAttribute( "scheme" );
  +        addMimeTypeMap( mimeType, scheme );
       }
   
       /**
  
  
  
  1.3       +4 -1      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/providers.xml
  
  Index: providers.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/providers.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- providers.xml	21 Feb 2003 13:16:59 -0000	1.2
  +++ providers.xml	24 Feb 2003 07:31:08 -0000	1.3
  @@ -26,7 +26,10 @@
       </provider>
       <provider class-name="org.apache.commons.vfs.provider.sftp.SftpFileProvider">
           <scheme name="sftp"/>
  -        <if-available class-name="javax.crypto.Cypher"/>
  +        <if-available class-name="javax.crypto.Cipher"/>
           <if-available class-name="com.jcraft.jsch.JSch"/>
       </provider>
  +    <extension-map extension="zip" scheme="zip"/>
  +    <mime-type-map mimetype="application/zip" scheme="zip"/>
  +    <extension-map extension="jar" scheme="jar"/>
   </providers>
  
  
  
  1.9       +12 -4     jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/FileSystemManagerFactoryTestCase.java
  
  Index: FileSystemManagerFactoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/FileSystemManagerFactoryTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FileSystemManagerFactoryTestCase.java	12 Feb 2003 07:56:19 -0000	1.8
  +++ FileSystemManagerFactoryTestCase.java	24 Feb 2003 07:31:09 -0000	1.9
  @@ -60,6 +60,7 @@
   import org.apache.commons.vfs.FileObject;
   import org.apache.commons.vfs.FileSystemManager;
   import org.apache.commons.vfs.VFS;
  +import org.apache.commons.vfs.FileType;
   
   /**
    * Test cases for the VFS factory.
  @@ -78,11 +79,18 @@
           // Locate the default manager
           final FileSystemManager manager = VFS.getManager();
   
  -        // Lookup a test file
  -        final File testDir = getTestResource( "read-tests" );
  -        final FileObject file = manager.toFileObject( testDir );
  +        // Lookup a test jar file
  +        final File jarFile = getTestResource( "test.jar" );
  +        FileObject file = manager.toFileObject( jarFile );
           assertNotNull( file );
           assertTrue( file.exists() );
  +        assertSame( FileType.FILE, file.getType() );
  +
  +        // Expand it
  +        file = manager.createFileSystem( file );
  +        assertNotNull( file );
  +        assertTrue( file.exists() );
  +        assertSame( FileType.FOLDER, file.getType() );
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message