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 AbstractProviderTestConfig.java ProviderReadTests.java ProviderTestConfig.java ProviderTestSuite.java AbstractFileSystemTestCase.java AbstractReadOnlyFileSystemTestCase.java AbstractWritableFileSystemTestCase.java FileSystemManagerFactoryTestCase.java
Date Thu, 21 Nov 2002 04:25:58 GMT
adammurdoch    2002/11/20 20:25:58

  Modified:    vfs/src/test/org/apache/commons AbstractVfsTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/ftp/test
                        FtpFileSystemTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/jar/test
                        JarFileSystemTestCase.java
                        NestedJarFileSystemTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/local/test
                        LocalFileSystemTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/smb/test
                        SmbFileSystemTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/temp/test
                        TemporaryFileProiderTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/zip/test
                        NestedZipFileSystemTestCase.java
                        ZipFileSystemTestCase.java
               vfs/src/test/org/apache/commons/vfs/test
                        AbstractFileSystemTestCase.java
                        AbstractReadOnlyFileSystemTestCase.java
                        AbstractWritableFileSystemTestCase.java
                        FileSystemManagerFactoryTestCase.java
  Added:       vfs/src/test/org/apache/commons/vfs/provider/local/test
                        FileNameTestCase.java
               vfs/src/test/org/apache/commons/vfs/test
                        AbstractProviderTestConfig.java
                        ProviderReadTests.java ProviderTestConfig.java
                        ProviderTestSuite.java
  Log:
  Reorganised tests, so that provider test cases are assembled dynamically
  based on the provider's capabilities.  This replaces using test case inheritance
  to statically assemble test cases, which was getting unwieldy as more combinations
  of capabilities were added.
  
  Revision  Changes    Path
  1.9       +33 -35    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/AbstractVfsTestCase.java
  
  Index: AbstractVfsTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/AbstractVfsTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractVfsTestCase.java	23 Oct 2002 11:59:38 -0000	1.8
  +++ AbstractVfsTestCase.java	21 Nov 2002 04:25:57 -0000	1.9
  @@ -72,14 +72,7 @@
   public abstract class AbstractVfsTestCase
       extends TestCase
   {
  -    private final File baseDir;
  -
  -    public AbstractVfsTestCase( final String name )
  -    {
  -        super( name );
  -        final String baseDirProp = System.getProperty( "test.basedir" );
  -        baseDir = getCanonicalFile( new File( baseDirProp ) );
  -    }
  +    private static File baseDir;
   
       /**
        * Returns the name of the package containing a class.
  @@ -87,16 +80,16 @@
        * @return The . delimited package name, or an empty string if the class
        *         is in the default package.
        */
  -    protected static String getPackageName( final Class clazz )
  +    public static String getPackageName( final Class clazz )
       {
           final Package pkg = clazz.getPackage();
  -        if( null != pkg )
  +        if ( null != pkg )
           {
               return pkg.getName();
           }
   
           final String name = clazz.getName();
  -        if( -1 == name.lastIndexOf( "." ) )
  +        if ( -1 == name.lastIndexOf( "." ) )
           {
               return "";
           }
  @@ -111,7 +104,7 @@
        *
        * @param name path of the resource, relative to this test's base directory.
        */
  -    protected File getTestResource( final String name )
  +    public static File getTestResource( final String name )
       {
           return getTestResource( name, true );
       }
  @@ -121,11 +114,11 @@
        *
        * @param name path of the resource, relative to this test's base directory.
        */
  -    protected File getTestResource( final String name, final boolean mustExist )
  +    public static File getTestResource( final String name, final boolean mustExist )
       {
  -        File file = new File( baseDir, name );
  +        File file = new File( getTestDirectory(), name );
           file = getCanonicalFile( file );
  -        if( mustExist )
  +        if ( mustExist )
           {
               assertTrue( "Test file \"" + file + "\" does not exist.", file.exists() );
           }
  @@ -140,8 +133,13 @@
       /**
        * Locates the base directory for this test.
        */
  -    protected File getTestDirectory()
  +    public static File getTestDirectory()
       {
  +        if ( baseDir == null )
  +        {
  +            final String baseDirProp = System.getProperty( "test.basedir" );
  +            baseDir = getCanonicalFile( new File( baseDirProp ) );
  +        }
           return baseDir;
       }
   
  @@ -150,9 +148,9 @@
        *
        * @param name path of the directory, relative to this test's base directory.
        */
  -    protected File getTestDirectory( final String name )
  +    public static File getTestDirectory( final String name )
       {
  -        File file = new File( baseDir, name );
  +        File file = new File( getTestDirectory(), name );
           file = getCanonicalFile( file );
           assertTrue( "Test directory \"" + file + "\" does not exist or is not a directory.",
                       file.isDirectory() || file.mkdirs() );
  @@ -162,13 +160,13 @@
       /**
        * Makes a file canonical
        */
  -    private File getCanonicalFile( final File file )
  +    public static File getCanonicalFile( final File file )
       {
           try
           {
               return file.getCanonicalFile();
           }
  -        catch( IOException e )
  +        catch ( IOException e )
           {
               return file.getAbsoluteFile();
           }
  @@ -180,14 +178,14 @@
        * @param messages The messages, in order.  A null entry in this array
        *                 indicates that the message should be ignored.
        */
  -    protected void assertSameMessage( final String[] messages, final Throwable throwable )
  +    public static void assertSameMessage( final String[] messages, final Throwable throwable )
       {
           Throwable current = throwable;
  -        for( int i = 0; i < messages.length; i++ )
  +        for ( int i = 0; i < messages.length; i++ )
           {
               String message = messages[ i ];
               assertNotNull( current );
  -            if( message != null )
  +            if ( message != null )
               {
                   assertEquals( message, current.getMessage() );
               }
  @@ -200,7 +198,7 @@
       /**
        * Returns the cause of an exception.
        */
  -    private Throwable getCause( Throwable throwable )
  +    public static Throwable getCause( Throwable throwable )
       {
           try
           {
  @@ -216,8 +214,8 @@
       /**
        * Asserts that an exception contains the expected message.
        */
  -    protected void assertSameMessage( final String code,
  -                                      final Throwable throwable )
  +    public static void assertSameMessage( final String code,
  +                                          final Throwable throwable )
       {
           assertSameMessage( code, new Object[ 0 ], throwable );
       }
  @@ -225,9 +223,9 @@
       /**
        * Asserts that an exception contains the expected message.
        */
  -    protected void assertSameMessage( final String code,
  -                                      final Object[] params,
  -                                      final Throwable throwable )
  +    public static void assertSameMessage( final String code,
  +                                          final Object[] params,
  +                                          final Throwable throwable )
       {
           if ( throwable instanceof FileSystemException )
           {
  @@ -251,11 +249,11 @@
       /**
        * Asserts that an exception contains the expected message.
        */
  -    protected void assertSameMessage( final String code,
  -                                      final Object param,
  -                                      final Throwable throwable )
  +    public static void assertSameMessage( final String code,
  +                                          final Object param,
  +                                          final Throwable throwable )
       {
  -        assertSameMessage( code, new Object[] { param }, throwable );
  +        assertSameMessage( code, new Object[]{param}, throwable );
       }
   
       /**
  @@ -264,11 +262,11 @@
        */
       public static boolean equals( final Object o1, final Object o2 )
       {
  -        if( o1 == null && o2 == null )
  +        if ( o1 == null && o2 == null )
           {
               return true;
           }
  -        if( o1 == null || o2 == null )
  +        if ( o1 == null || o2 == null )
           {
               return false;
           }
  
  
  
  1.4       +36 -11    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/ftp/test/FtpFileSystemTestCase.java
  
  Index: FtpFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/ftp/test/FtpFileSystemTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FtpFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.3
  +++ FtpFileSystemTestCase.java	21 Nov 2002 04:25:57 -0000	1.4
  @@ -55,9 +55,14 @@
    */
   package org.apache.commons.vfs.provider.ftp.test;
   
  +import junit.framework.Test;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.ftp.FtpFileSystemProvider;
  -import org.apache.commons.vfs.test.AbstractWritableFileSystemTestCase;
   
   /**
    * Tests for FTP file systems.
  @@ -65,29 +70,49 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
   public class FtpFileSystemTestCase
  -    extends AbstractWritableFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public FtpFileSystemTestCase( String name )
  +    /**
  +     * Creates the test suite for the ftp file system.
  +     */
  +    public static Test suite() throws Exception
  +    {
  +        return new ProviderTestSuite( new FtpFileSystemTestCase() );
  +    }
  +
  +    /**
  +     * Prepares the file system manager.
  +     */
  +    public void prepare( final DefaultFileSystemManager manager ) throws Exception
       {
  -        super( name );
  +        manager.addProvider( "ftp", new FtpFileSystemProvider() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Returns the base folder for read tests.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
       {
           final String uri = System.getProperty( "test.ftp.uri" ) + "/read-tests";
  -        getManager().addProvider( "ftp", new FtpFileSystemProvider() );
  -        return getManager().resolveFile( uri );
  +        return manager.resolveFile( uri );
  +    }
  +
  +    /**
  +     * Returns true if the write tests should be run for this provider.
  +     */
  +    public boolean runWriteTests()
  +    {
  +        return true;
       }
   
       /**
  -     * Returns the URI for the area to do tests in.
  +     * Returns the base folder for write tests.  Should return null to
  +     * skip the write tests.
        */
  -    protected FileObject getWriteFolder() throws Exception
  +    public FileObject getWriteTestFolder( final FileSystemManager manager ) throws Exception
       {
           final String uri = System.getProperty( "test.ftp.uri" ) + "/write-tests";
  -        return getManager().resolveFile( uri );
  +        return manager.resolveFile( uri );
       }
   }
  
  
  
  1.4       +28 -10    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/jar/test/JarFileSystemTestCase.java
  
  Index: JarFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/jar/test/JarFileSystemTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JarFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.3
  +++ JarFileSystemTestCase.java	21 Nov 2002 04:25:57 -0000	1.4
  @@ -56,9 +56,15 @@
   package org.apache.commons.vfs.provider.jar.test;
   
   import java.io.File;
  +import org.apache.commons.AbstractVfsTestCase;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.jar.JarFileSystemProvider;
  -import org.apache.commons.vfs.test.AbstractReadOnlyFileSystemTestCase;
  +import junit.framework.Test;
   
   /**
    * Tests for the Jar file system.
  @@ -66,22 +72,34 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
   public class JarFileSystemTestCase
  -    extends AbstractReadOnlyFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public JarFileSystemTestCase( String name )
  +    /**
  +     * Creates the test suite for the jar file system.
  +     */
  +    public static Test suite() throws Exception
  +    {
  +        return new ProviderTestSuite( new JarFileSystemTestCase() );
  +    }
  +
  +    /**
  +     * Prepares the file system manager.
  +     */
  +    public void prepare( final DefaultFileSystemManager manager )
  +        throws Exception
       {
  -        super( name );
  +        manager.addProvider( "jar", new JarFileSystemProvider() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Returns the base folder for read tests.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
       {
  -        File jarFile = getTestResource( "test.jar" );
  -        String uri = "jar:" + jarFile.getAbsolutePath() + "!basedir";
  -        getManager().addProvider( "jar", new JarFileSystemProvider() );
  -        return getManager().resolveFile( uri );
  +        final File jarFile = AbstractVfsTestCase.getTestResource( "test.jar" );
  +        final String uri = "jar:" + jarFile.getAbsolutePath() + "!basedir";
  +        return manager.resolveFile( uri );
       }
   
       /**
  
  
  
  1.4       +33 -24    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/jar/test/NestedJarFileSystemTestCase.java
  
  Index: NestedJarFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/jar/test/NestedJarFileSystemTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NestedJarFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.3
  +++ NestedJarFileSystemTestCase.java	21 Nov 2002 04:25:57 -0000	1.4
  @@ -56,12 +56,15 @@
   package org.apache.commons.vfs.provider.jar.test;
   
   import java.io.File;
  -import java.net.URL;
  -import java.net.URLConnection;
  +import junit.framework.Test;
  +import org.apache.commons.AbstractVfsTestCase;
   import org.apache.commons.vfs.FileObject;
  -import org.apache.commons.vfs.impl.VFSClassLoader;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.jar.JarFileSystemProvider;
  -import org.apache.commons.vfs.test.AbstractReadOnlyFileSystemTestCase;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
   
   /**
    * Tests for the Zip file system.
  @@ -69,34 +72,38 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
   public class NestedJarFileSystemTestCase
  -        extends AbstractReadOnlyFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public NestedJarFileSystemTestCase( String name )
  +    /**
  +     * Creates the test suite for nested jar files.
  +     */
  +    public static Test suite() throws Exception
       {
  -        super( name );
  +        return new ProviderTestSuite( new NestedJarFileSystemTestCase() );
       }
   
  -    protected FileObject topFolder;
  -
  -    protected FileObject getTopFolder() throws Exception
  +    /**
  +     * Prepares the file system manager.  This implementation does nothing.
  +     */
  +    public void prepare( final DefaultFileSystemManager manager )
  +        throws Exception
       {
  -        getManager().addProvider( "jar", new JarFileSystemProvider() );
  -
  -        File jarFile = getTestResource( "nested.jar" );
  -        String uri = "jar:" + jarFile.getAbsolutePath() + "!/";
  -        return getManager().resolveFile( uri );
  +        manager.addProvider( "jar", new JarFileSystemProvider() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Returns the base folder for read tests.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
       {
  -        topFolder = getTopFolder();
  -        final FileObject jarFile = topFolder.resolveFile( "test.jar" );
  +        // Locate the Jar file
  +        final File outerFile = AbstractVfsTestCase.getTestResource( "nested.jar" );
  +        final String uri = "jar:" + outerFile.getAbsolutePath() + "!/test.jar";
  +        final FileObject jarFile = manager.resolveFile( uri );
  +
           // Now build the nested file system
  -        final FileObject nestedFS =
  -            getManager().createFileSystem( "jar", jarFile );
  +        final FileObject nestedFS = manager.createFileSystem( "jar", jarFile );
           return nestedFS.resolveFile( "/basedir" );
       }
   
  @@ -116,9 +123,10 @@
                  !pack.isSealed();
       }
   
  -
  +    /*
  +     * TODO - activate this
       public void testJarClassLoader() throws Exception
  -    { 
  +    {
           FileObject test = topFolder.resolveFile( "normal.jar" );
           final FileObject[] objects = { test };
           VFSClassLoader loader =
  @@ -126,7 +134,7 @@
   
           Class testClass = loader.loadClass( "code.ClassToLoad" );
           assertTrue( verifyNormalPackage( testClass.getPackage() ) );
  -        
  +
           Object testObject = testClass.newInstance();
           assertSame( "**PRIVATE**", testObject.toString() );
   
  @@ -135,6 +143,7 @@
           URLConnection urlCon = resource.openConnection();
           assertSameURLContent( getCharContent(), urlCon );
       }
  +    */
   
       /**
        * Verify the package loaded with class loader.
  
  
  
  1.7       +33 -23    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/local/test/LocalFileSystemTestCase.java
  
  Index: LocalFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/local/test/LocalFileSystemTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalFileSystemTestCase.java	25 Oct 2002 11:11:51 -0000	1.6
  +++ LocalFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.7
  @@ -56,8 +56,14 @@
   package org.apache.commons.vfs.provider.local.test;
   
   import java.io.File;
  +import junit.framework.Test;
  +import org.apache.commons.AbstractVfsTestCase;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
   import org.apache.commons.vfs.FileObject;
  -import org.apache.commons.vfs.test.AbstractWritableFileSystemTestCase;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   
   /**
    * Tests for the local file system.
  @@ -65,46 +71,50 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
   public class LocalFileSystemTestCase
  -    extends AbstractWritableFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public LocalFileSystemTestCase( String name )
  +    /**
  +     * Creates the test suite for the local file system.
  +     */
  +    public static Test suite() throws Exception
       {
  -        super( name );
  +        return new ProviderTestSuite( new LocalFileSystemTestCase() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Prepares the file system manager.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public void prepare( final DefaultFileSystemManager manager ) throws Exception
       {
  -        final File testDir = getTestDirectory( "basedir" );
  +    }
  +
  +    /**
  +     * Returns the base folder for read tests.
  +     */
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
  +    {
  +        final File testDir = AbstractVfsTestCase.getTestDirectory( "basedir" );
           final File emptyDir = new File( testDir, "emptydir" );
           emptyDir.mkdirs();
  -        return getManager().toFileObject( testDir );
  +        return manager.toFileObject( testDir );
       }
   
       /**
  -     * Returns the URI for the area to do tests in.
  +     * Returns true if the write tests should be run for this provider.
        */
  -    protected FileObject getWriteFolder() throws Exception
  +    public boolean runWriteTests()
       {
  -        final File testDir = getTestDirectory( "write-tests" );
  -        return getManager().toFileObject( testDir );
  +        return true;
       }
   
       /**
  -     * Tests resolution of an absolute file name.
  +     * Returns the base folder for write tests.  Should return null to
  +     * skip the write tests.
        */
  -    public void testAbsoluteFileName() throws Exception
  +    public FileObject getWriteTestFolder( final FileSystemManager manager ) throws Exception
       {
  -        // Locate file by absolute file name
  -        String fileName = new File( "testdir" ).getAbsolutePath();
  -        FileObject absFile = getManager().resolveFile( fileName );
  -
  -        // Locate file by URI
  -        String uri = "file://" + fileName.replace( File.separatorChar, '/' );
  -        FileObject uriFile = getManager().resolveFile( uri );
  -
  -        assertSame( "file object", absFile, uriFile );
  +        final File testDir = AbstractVfsTestCase.getTestDirectory( "write-tests" );
  +        return manager.toFileObject( testDir );
       }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/local/test/FileNameTestCase.java
  
  Index: FileNameTestCase.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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 (INCLUDING, 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.commons.vfs.provider.local.test;
  
  import java.io.File;
  import org.apache.commons.vfs.FileObject;
  import org.apache.commons.vfs.test.AbstractFileSystemTestCase;
  
  /**
   * Additional naming tests for local file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:25:58 $
   */
  public class FileNameTestCase
      extends AbstractFileSystemTestCase
  {
      /**
       * Tests resolution of an absolute file name.
       */
      public void testAbsoluteFileName() throws Exception
      {
          // Locate file by absolute file name
          String fileName = new File( "testdir" ).getAbsolutePath();
          FileObject absFile = getManager().resolveFile( fileName );
  
          // Locate file by URI
          String uri = "file://" + fileName.replace( File.separatorChar, '/' );
          FileObject uriFile = getManager().resolveFile( uri );
  
          assertSame( "file object", absFile, uriFile );
      }
  }
  
  
  
  1.4       +36 -11    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/smb/test/SmbFileSystemTestCase.java
  
  Index: SmbFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/smb/test/SmbFileSystemTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SmbFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.3
  +++ SmbFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.4
  @@ -55,38 +55,63 @@
    */
   package org.apache.commons.vfs.provider.smb.test;
   
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.smb.SmbFileSystemProvider;
  -import org.apache.commons.vfs.test.AbstractWritableFileSystemTestCase;
  +import junit.framework.Test;
   
   /**
    * Tests for the SMB file system.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
  -public class SmbFileSystemTestCase extends AbstractWritableFileSystemTestCase
  +public class SmbFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public SmbFileSystemTestCase( String name )
  +    public static Test suite() throws Exception
       {
  -        super( name );
  +        return new ProviderTestSuite( new SmbFileSystemTestCase() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Prepares the file system manager.  This implementation does nothing.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public void prepare( final DefaultFileSystemManager manager )
  +        throws Exception
  +    {
  +        manager.addProvider( "smb", new SmbFileSystemProvider() );
  +    }
  +
  +    /**
  +     * Returns the base folder for read tests.
  +     */
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
       {
           final String uri = System.getProperty( "test.smb.uri" ) + "/read-tests";
  -        getManager().addProvider( "smb", new SmbFileSystemProvider() );
  -        return getManager().resolveFile( uri );
  +        return manager.resolveFile( uri );
  +    }
  +
  +    /**
  +     * Returns true if the write tests should be run for this provider.
  +     */
  +    public boolean runWriteTests()
  +    {
  +        return true;
       }
   
       /**
  -     * Returns the URI for the area to do tests in.
  +     * Returns the base folder for write tests.  This implementation returns
  +     * null.
        */
  -    protected FileObject getWriteFolder() throws Exception
  +    public FileObject getWriteTestFolder( final FileSystemManager manager )
  +        throws Exception
       {
           final String uri = System.getProperty( "test.smb.uri" ) + "/write-tests";
  -        return getManager().resolveFile( uri );
  +        return manager.resolveFile( uri );
       }
   }
  
  
  
  1.2       +43 -15    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/temp/test/TemporaryFileProiderTestCase.java
  
  Index: TemporaryFileProiderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/temp/test/TemporaryFileProiderTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemporaryFileProiderTestCase.java	25 Oct 2002 11:11:51 -0000	1.1
  +++ TemporaryFileProiderTestCase.java	21 Nov 2002 04:25:58 -0000	1.2
  @@ -55,10 +55,16 @@
    */
   package org.apache.commons.vfs.provider.temp.test;
   
  -import org.apache.commons.vfs.test.AbstractWritableFileSystemTestCase;
  +import java.io.File;
  +import junit.framework.Test;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
  +import org.apache.commons.AbstractVfsTestCase;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.temp.TemporaryFileProvider;
  -import java.io.File;
   
   /**
    * Test cases for the tmp: file provider.
  @@ -67,29 +73,51 @@
    * @version $Revision$ $Date$
    */
   public class TemporaryFileProiderTestCase
  -    extends AbstractWritableFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public TemporaryFileProiderTestCase( String name )
  +    /**
  +     * Creates the test suite for the tmp file system.
  +     */
  +    public static Test suite() throws Exception
  +    {
  +        return new ProviderTestSuite( new TemporaryFileProiderTestCase() );
  +    }
  +
  +    /**
  +     * Prepares the file system manager.  This implementation does nothing.
  +     */
  +    public void prepare( final DefaultFileSystemManager manager )
  +        throws Exception
  +    {
  +        final File baseDir = AbstractVfsTestCase.getTestDirectory();
  +        manager.addProvider( "tmp-read", new TemporaryFileProvider( baseDir ) );
  +        manager.addProvider( "tmp-write", new TemporaryFileProvider() );
  +    }
  +
  +    /**
  +     * Returns the base folder for read tests.
  +     */
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
       {
  -        super( name );
  +        return manager.resolveFile( "tmp-read:/basedir" );
       }
   
       /**
  -     * Returns the base folder to run the tests against.
  +     * Returns true if the write tests should be run for this provider.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public boolean runWriteTests()
       {
  -        final File baseDir = getTestDirectory();
  -        getManager().addProvider( "tmp-read", new TemporaryFileProvider( baseDir ) );
  -        return getManager().resolveFile( "tmp-read:/basedir" );
  +        return true;
       }
   
       /**
  -     * Returns the URI for the area to do tests in.
  +     * Returns the base folder for write tests.  This implementation returns
  +     * null.
        */
  -    protected FileObject getWriteFolder() throws Exception
  +    public FileObject getWriteTestFolder( final FileSystemManager manager )
  +        throws Exception
       {
  -        getManager().addProvider( "tmp", new TemporaryFileProvider() );
  -        return getManager().resolveFile( "tmp:/write-tests" );
  +        return manager.resolveFile( "tmp-write:/write-tests" );
       }
   }
  
  
  
  1.4       +27 -10    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/NestedZipFileSystemTestCase.java
  
  Index: NestedZipFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/NestedZipFileSystemTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NestedZipFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.3
  +++ NestedZipFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.4
  @@ -55,9 +55,15 @@
    */
   package org.apache.commons.vfs.provider.zip.test;
   
  +import junit.framework.Test;
  +import org.apache.commons.AbstractVfsTestCase;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.zip.ZipFileSystemProvider;
  -import org.apache.commons.vfs.test.AbstractReadOnlyFileSystemTestCase;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
   
   /**
    * Tests for the Zip file system, using a zip file nested inside another zip file.
  @@ -65,27 +71,38 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
   public class NestedZipFileSystemTestCase
  -    extends AbstractReadOnlyFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public NestedZipFileSystemTestCase( String name )
  +    /**
  +     * Creates the test suite for nested zip files.
  +     */
  +    public static Test suite() throws Exception
       {
  -        super( name );
  +        return new ProviderTestSuite( new NestedZipFileSystemTestCase() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Prepares the file system manager.  This implementation does nothing.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public void prepare( final DefaultFileSystemManager manager )
  +        throws Exception
       {
  -        getManager().addProvider( "zip", new ZipFileSystemProvider() );
  +        manager.addProvider( "zip", new ZipFileSystemProvider() );
  +    }
   
  +    /**
  +     * Returns the base folder for read tests.
  +     */
  +    public FileObject getReadTestFolder( FileSystemManager manager ) throws Exception
  +    {
           // Locate the base Zip file
  -        final String zipFilePath = getTestResource( "nested.zip" ).getAbsolutePath();
  +        final String zipFilePath = AbstractVfsTestCase.getTestResource( "nested.zip" ).getAbsolutePath();
           String uri = "zip:" + zipFilePath + "!/test.zip";
  -        final FileObject zipFile = getManager().resolveFile( uri );
  +        final FileObject zipFile = manager.resolveFile( uri );
   
           // Now build the nested file system
  -        final FileObject nestedFS = getManager().createFileSystem( "zip", zipFile );
  +        final FileObject nestedFS = manager.createFileSystem( "zip", zipFile );
           return nestedFS.resolveFile( "/basedir" );
       }
   }
  
  
  
  1.4       +28 -10    jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/ZipFileSystemTestCase.java
  
  Index: ZipFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/ZipFileSystemTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ZipFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.3
  +++ ZipFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.4
  @@ -56,30 +56,48 @@
   package org.apache.commons.vfs.provider.zip.test;
   
   import java.io.File;
  +import junit.framework.Test;
  +import org.apache.commons.AbstractVfsTestCase;
  +import org.apache.commons.vfs.test.ProviderTestConfig;
  +import org.apache.commons.vfs.test.ProviderTestSuite;
  +import org.apache.commons.vfs.test.AbstractProviderTestConfig;
   import org.apache.commons.vfs.FileObject;
  +import org.apache.commons.vfs.FileSystemManager;
  +import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.provider.zip.ZipFileSystemProvider;
  -import org.apache.commons.vfs.test.AbstractReadOnlyFileSystemTestCase;
   
   /**
    * Tests for the Zip file system.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
  -public class ZipFileSystemTestCase extends AbstractReadOnlyFileSystemTestCase
  +public class ZipFileSystemTestCase
  +    extends AbstractProviderTestConfig
  +    implements ProviderTestConfig
   {
  -    public ZipFileSystemTestCase( String name )
  +    /**
  +     * Creates the test suite for the zip file system.
  +     */
  +    public static Test suite() throws Exception
  +    {
  +        return new ProviderTestSuite( new ZipFileSystemTestCase() );
  +    }
  +
  +    /**
  +     * Prepares the file system manager.
  +     */
  +    public void prepare( final DefaultFileSystemManager manager ) throws Exception
       {
  -        super( name );
  +        manager.addProvider( "zip", new ZipFileSystemProvider() );
       }
   
       /**
  -     * Returns the URI for the base folder.
  +     * Returns the base folder for read tests.
        */
  -    protected FileObject getBaseFolder() throws Exception
  +    public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
       {
  -        File zipFile = getTestResource( "test.zip" );
  -        String uri = "zip:" + zipFile.getAbsolutePath() + "!basedir";
  -        getManager().addProvider( "zip", new ZipFileSystemProvider() );
  -        return getManager().resolveFile( uri );
  +        final File zipFile = AbstractVfsTestCase.getTestResource( "test.zip" );
  +        final String uri = "zip:" + zipFile.getAbsolutePath() + "!basedir";
  +        return manager.resolveFile( uri );
       }
   }
  
  
  
  1.19      +26 -981   jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractFileSystemTestCase.java
  
  Index: AbstractFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractFileSystemTestCase.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AbstractFileSystemTestCase.java	20 Nov 2002 23:57:13 -0000	1.18
  +++ AbstractFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.19
  @@ -55,27 +55,12 @@
    */
   package org.apache.commons.vfs.test;
   
  -import java.io.ByteArrayOutputStream;
  -import java.io.IOException;
  -import java.io.InputStream;
   import java.io.File;
  -import java.net.URL;
  -import java.net.URLConnection;
  -import java.util.ArrayList;
  -import java.util.Arrays;
  -import java.util.List;
   import org.apache.commons.AbstractVfsTestCase;
  -import org.apache.commons.vfs.FileContent;
  -import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.FileObject;
  -import org.apache.commons.vfs.FileSystem;
  -import org.apache.commons.vfs.FileSystemException;
  -import org.apache.commons.vfs.FileType;
  -import org.apache.commons.vfs.NameScope;
   import org.apache.commons.vfs.impl.DefaultFileReplicator;
   import org.apache.commons.vfs.impl.DefaultFileSystemManager;
   import org.apache.commons.vfs.impl.PrivilegedFileReplicator;
  -import org.apache.commons.vfs.impl.VFSClassLoader;
   import org.apache.commons.vfs.provider.local.DefaultLocalFileSystemProvider;
   
   /**
  @@ -88,27 +73,19 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
    */
  -public abstract class AbstractFileSystemTestCase
  +public class AbstractFileSystemTestCase
       extends AbstractVfsTestCase
   {
  -    private FileObject baseFolder;
  +    private FileObject readFolder;
  +    private FileObject writeFolder;
       private DefaultFileSystemManager manager;
  -
  -    // Contents of "file1.txt"
  -    private String charContent;
  +    private ProviderTestConfig providerConfig;
       private File tempDir;
   
  -    public AbstractFileSystemTestCase( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Returns the expected contents of "file1.txt".
  -     */
  -    protected String getCharContent()
  +    /** Sets the provider test config, if any. */
  +    public void setConfig( final ProviderTestConfig providerConfig )
       {
  -        return charContent;
  +        this.providerConfig = providerConfig;
       }
   
       /**
  @@ -120,59 +97,22 @@
       }
   
       /**
  -     * Returns the name of the package containing a class.
  -     *
  -     * @return The . delimited package name, or an empty string if the class
  -     *         is in the default package.
  +     * Returns the read test folder.
        */
  -    protected static String getPackageName( final Class clazz )
  +    protected FileObject getReadFolder()
       {
  -        final Package pkg = clazz.getPackage();
  -        if( null != pkg )
  -        {
  -            return pkg.getName();
  -        }
  -
  -        final String name = clazz.getName();
  -        if( -1 == name.lastIndexOf( "." ) )
  -        {
  -            return "";
  -        }
  -        else
  -        {
  -            return name.substring( 0, name.lastIndexOf( "." ) );
  -        }
  +        return readFolder;
       }
   
       /**
  -     * Builds the expected folder structure.
  +     * Returns the write test folder.
        */
  -    private FileInfo buildExpectedStructure()
  +    protected FileObject getWriteFolder()
       {
  -        // Build the expected structure
  -        final FileInfo base = new FileInfo( baseFolder.getName().getBaseName(), FileType.FOLDER );
  -        base.addChild( "file1.txt", FileType.FILE );
  -        base.addChild( "empty.txt", FileType.FILE );
  -        base.addChild( "emptydir", FileType.FOLDER );
  -
  -        final FileInfo dir = new FileInfo( "dir1", FileType.FOLDER );
  -        base.addChild( dir );
  -        dir.addChild( "file1.txt", FileType.FILE );
  -        dir.addChild( "file2.txt", FileType.FILE );
  -        dir.addChild( "file3.txt", FileType.FILE );
  -
  -        final FileInfo code = new FileInfo( "code", FileType.FOLDER );
  -        base.addChild( code );
  -        code.addChild( "ClassToLoad.class", FileType.FILE );
  -        return base;
  +        return writeFolder;
       }
   
       /**
  -     * Returns the base folder to run the tests against.
  -     */
  -    protected abstract FileObject getBaseFolder() throws Exception;
  -
  -    /**
        * Sets up the test
        */
       protected void setUp() throws Exception
  @@ -186,16 +126,22 @@
           manager.setReplicator( new PrivilegedFileReplicator( replicator ) );
           manager.setTemporaryFileStore( replicator );
   
  -        manager.init();
  +        if ( providerConfig != null )
  +        {
  +            providerConfig.prepare( manager );
  +        }
   
  -        // Locate the base folder
  -        baseFolder = getBaseFolder();
  +        manager.init();
   
  -        // Make some assumptions absout the name
  -        assertTrue( !baseFolder.getName().getPath().equals( "/" ) );
  +        if ( providerConfig != null )
  +        {
  +            // Locate the base folder
  +            readFolder = providerConfig.getReadTestFolder( manager );
  +            writeFolder = providerConfig.getWriteTestFolder( manager );
   
  -        // Build the expected content of "file1.txt"
  -        charContent = "This is a test file.";
  +            // Make some assumptions absout the name
  +            assertTrue( !readFolder.getName().getPath().equals( "/" ) );
  +        }
       }
   
       /**
  @@ -207,906 +153,5 @@
   
           // Make sure temp directory is empty or gone
           assertTrue( ( ! tempDir.exists() ) || ( tempDir.isDirectory() && tempDir.list().length == 0 ) );
  -    }
  -
  -    /**
  -     * Tests resolution of absolute URI.
  -     */
  -    public void testAbsoluteURI() throws Exception
  -    {
  -        // Try fetching base folder again by its URI
  -        final String uri = baseFolder.getName().getURI();
  -        final FileObject file = manager.resolveFile( uri );
  -
  -        assertSame( "file object", baseFolder, file );
  -    }
  -
  -    /**
  -     * Tests resolution of relative file names via the FS manager
  -     */
  -    public void testRelativeURI() throws Exception
  -    {
  -        // Build base dir
  -        manager.setBaseFile( baseFolder );
  -
  -        // Locate the base dir
  -        FileObject file = manager.resolveFile( "." );
  -        assertSame( "file object", baseFolder, file );
  -
  -        // Locate a child
  -        file = manager.resolveFile( "some-child" );
  -        assertSame( "file object", baseFolder, file.getParent() );
  -
  -        // Locate a descendent
  -        file = manager.resolveFile( "some-folder/some-file" );
  -        assertSame( "file object", baseFolder, file.getParent().getParent() );
  -
  -        // Locate parent
  -        file = manager.resolveFile( ".." );
  -        assertSame( "file object", baseFolder.getParent(), file );
  -    }
  -
  -    /**
  -     * Tests encoding of relative URI.
  -     */
  -    public void testRelativeUriEncoding() throws Exception
  -    {
  -        // Build base dir
  -        manager.setBaseFile( baseFolder );
  -        final String path = baseFolder.getName().getPath();
  -
  -        // Encode "some file"
  -        FileObject file = manager.resolveFile( "%73%6f%6d%65%20%66%69%6c%65" );
  -        assertEquals( path + "/some file", file.getName().getPath() );
  -
  -        // Encode "."
  -        file = manager.resolveFile( "%2e" );
  -        assertEquals( path, file.getName().getPath() );
  -
  -        // Encode '%'
  -        file = manager.resolveFile( "a%25" );
  -        assertEquals( path + "/a%", file.getName().getPath() );
  -
  -        // Encode /
  -        file = manager.resolveFile( "dir%2fchild" );
  -        assertEquals( path + "/dir/child", file.getName().getPath() );
  -
  -        // Encode \
  -        file = manager.resolveFile( "dir%5cchild" );
  -        assertEquals( path + "/dir/child", file.getName().getPath() );
  -
  -        // Use "%" literal
  -        try
  -        {
  -            manager.resolveFile( "%" );
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -        }
  -
  -        // Not enough digits in encoded char
  -        try
  -        {
  -            manager.resolveFile( "%5" );
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -        }
  -
  -        // Invalid digit in encoded char
  -        try
  -        {
  -            manager.resolveFile( "%q" );
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -        }
  -    }
  -
  -    /**
  -     * Tests the root file name.
  -     */
  -    public void testRootFileName() throws Exception
  -    {
  -        // Locate the root file
  -        final FileName rootName = baseFolder.getFileSystem().getRoot().getName();
  -
  -        // Test that the root path is "/"
  -        assertEquals( "root path", "/", rootName.getPath() );
  -
  -        // Test that the root basname is ""
  -        assertEquals( "root base name", "", rootName.getBaseName() );
  -
  -        // Test that the root name has no parent
  -        assertNull( "root parent", rootName.getParent() );
  -    }
  -
  -    /**
  -     * Tests child file names.
  -     */
  -    public void testChildName() throws Exception
  -    {
  -        final FileName baseName = baseFolder.getName();
  -        final String basePath = baseName.getPath();
  -        final FileName name = baseName.resolveName( "some-child", NameScope.CHILD );
  -
  -        // Test path is absolute
  -        assertTrue( "is absolute", basePath.startsWith( "/" ) );
  -
  -        // Test base name
  -        assertEquals( "base name", "some-child", name.getBaseName() );
  -
  -        // Test absolute path
  -        assertEquals( "absolute path", basePath + "/some-child", name.getPath() );
  -
  -        // Test parent path
  -        assertEquals( "parent absolute path", basePath, name.getParent().getPath() );
  -
  -        // Try using a compound name to find a child
  -        assertBadName( name, "a/b", NameScope.CHILD );
  -
  -        // Check other invalid names
  -        checkDescendentNames( name, NameScope.CHILD );
  -    }
  -
  -    /**
  -     * Name resolution tests that are common for CHILD or DESCENDENT scope.
  -     */
  -    private void checkDescendentNames( final FileName name,
  -                                       final NameScope scope )
  -        throws Exception
  -    {
  -        // Make some assumptions about the name
  -        assertTrue( !name.getPath().equals( "/" ) );
  -        assertTrue( !name.getPath().endsWith( "/a" ) );
  -        assertTrue( !name.getPath().endsWith( "/a/b" ) );
  -
  -        // Test names with the same prefix
  -        String path = name.getPath() + "/a";
  -        assertSameName( path, name, path, scope );
  -        assertSameName( path, name, "../" + name.getBaseName() + "/a", scope );
  -
  -        // Test an empty name
  -        assertBadName( name, "", scope );
  -
  -        // Test . name
  -        assertBadName( name, ".", scope );
  -        assertBadName( name, "./", scope );
  -
  -        // Test ancestor names
  -        assertBadName( name, "..", scope );
  -        assertBadName( name, "../a", scope );
  -        assertBadName( name, "../" + name.getBaseName() + "a", scope );
  -        assertBadName( name, "a/..", scope );
  -
  -        // Test absolute names
  -        assertBadName( name, "/", scope );
  -        assertBadName( name, "/a", scope );
  -        assertBadName( name, "/a/b", scope );
  -        assertBadName( name, name.getPath(), scope );
  -        assertBadName( name, name.getPath() + "a", scope );
  -    }
  -
  -    /**
  -     * Checks that a relative name resolves to the expected absolute path.
  -     * Tests both forward and back slashes.
  -     */
  -    private void assertSameName( final String expectedPath,
  -                                 final FileName baseName,
  -                                 final String relName,
  -                                 final NameScope scope )
  -        throws Exception
  -    {
  -        // Try the supplied name
  -        FileName name = baseName.resolveName( relName, scope );
  -        assertEquals( expectedPath, name.getPath() );
  -
  -        // Replace the separators
  -        relName.replace( '\\', '/' );
  -        name = baseName.resolveName( relName, scope );
  -        assertEquals( expectedPath, name.getPath() );
  -
  -        // And again
  -        relName.replace( '/', '\\' );
  -        name = baseName.resolveName( relName, scope );
  -        assertEquals( expectedPath, name.getPath() );
  -    }
  -
  -    /**
  -     * Checks that a relative name resolves to the expected absolute path.
  -     * Tests both forward and back slashes.
  -     */
  -    private void assertSameName( String expectedPath,
  -                                 FileName baseName,
  -                                 String relName ) throws Exception
  -    {
  -        assertSameName( expectedPath, baseName, relName, NameScope.FILE_SYSTEM );
  -    }
  -
  -    /**
  -     * Tests relative name resolution, relative to the base folder.
  -     */
  -    public void testNameResolution() throws Exception
  -    {
  -        final FileName baseName = baseFolder.getName();
  -        final String parentPath = baseName.getParent().getPath();
  -        final String path = baseName.getPath();
  -        final String childPath = path + "/some-child";
  -
  -        // Test empty relative path
  -        assertSameName( path, baseName, "" );
  -
  -        // Test . relative path
  -        assertSameName( path, baseName, "." );
  -
  -        // Test ./ relative path
  -        assertSameName( path, baseName, "./" );
  -
  -        // Test .// relative path
  -        assertSameName( path, baseName, ".//" );
  -
  -        // Test .///.///. relative path
  -        assertSameName( path, baseName, ".///.///." );
  -        assertSameName( path, baseName, "./\\/.\\//." );
  -
  -        // Test <elem>/.. relative path
  -        assertSameName( path, baseName, "a/.." );
  -
  -        // Test .. relative path
  -        assertSameName( parentPath, baseName, ".." );
  -
  -        // Test ../ relative path
  -        assertSameName( parentPath, baseName, "../" );
  -
  -        // Test ..//./ relative path
  -        assertSameName( parentPath, baseName, "..//./" );
  -        assertSameName( parentPath, baseName, "..//.\\" );
  -
  -        // Test <elem>/../.. relative path
  -        assertSameName( parentPath, baseName, "a/../.." );
  -
  -        // Test <elem> relative path
  -        assertSameName( childPath, baseName, "some-child" );
  -
  -        // Test ./<elem> relative path
  -        assertSameName( childPath, baseName, "./some-child" );
  -
  -        // Test ./<elem>/ relative path
  -        assertSameName( childPath, baseName, "./some-child/" );
  -
  -        // Test <elem>/././././ relative path
  -        assertSameName( childPath, baseName, "./some-child/././././" );
  -
  -        // Test <elem>/../<elem> relative path
  -        assertSameName( childPath, baseName, "a/../some-child" );
  -
  -        // Test <elem>/<elem>/../../<elem> relative path
  -        assertSameName( childPath, baseName, "a/b/../../some-child" );
  -    }
  -
  -    /**
  -     * Tests descendent name resolution.
  -     */
  -    public void testDescendentName()
  -        throws Exception
  -    {
  -        final FileName baseName = baseFolder.getName();
  -
  -        // Test direct child
  -        String path = baseName.getPath() + "/some-child";
  -        assertSameName( path, baseName, "some-child", NameScope.DESCENDENT );
  -
  -        // Test compound name
  -        path = path + "/grand-child";
  -        assertSameName( path, baseName, "some-child/grand-child", NameScope.DESCENDENT );
  -
  -        // Test relative names
  -        assertSameName( path, baseName, "./some-child/grand-child", NameScope.DESCENDENT );
  -        assertSameName( path, baseName, "./nada/../some-child/grand-child", NameScope.DESCENDENT );
  -        assertSameName( path, baseName, "some-child/./grand-child", NameScope.DESCENDENT );
  -
  -        // Test badly formed descendent names
  -        checkDescendentNames( baseName, NameScope.DESCENDENT );
  -    }
  -
  -    /**
  -     * Tests resolution of absolute names.
  -     */
  -    public void testAbsoluteNames() throws Exception
  -    {
  -        // Test against the base folder
  -        FileName name = baseFolder.getName();
  -        checkAbsoluteNames( name );
  -
  -        // Test against the root
  -        name = baseFolder.getFileSystem().getRoot().getName();
  -        checkAbsoluteNames( name );
  -
  -        // Test against some unknown file
  -        name = name.resolveName( "a/b/unknown" );
  -        checkAbsoluteNames( name );
  -    }
  -
  -    /**
  -     * Tests resolution of absolute names.
  -     */
  -    private void checkAbsoluteNames( final FileName name ) throws Exception
  -    {
  -        // Root
  -        assertSameName( "/", name, "/" );
  -        assertSameName( "/", name, "//" );
  -        assertSameName( "/", name, "/." );
  -        assertSameName( "/", name, "/some file/.." );
  -
  -        // Some absolute names
  -        assertSameName( "/a", name, "/a" );
  -        assertSameName( "/a", name, "/./a" );
  -        assertSameName( "/a", name, "/a/." );
  -        assertSameName( "/a/b", name, "/a/b" );
  -
  -        // Some bad names
  -        assertBadName( name, "/..", NameScope.FILE_SYSTEM );
  -        assertBadName( name, "/a/../..", NameScope.FILE_SYSTEM );
  -    }
  -
  -    /**
  -     * Asserts that a particular relative name is invalid for a particular
  -     * scope.
  -     */
  -    private void assertBadName( final FileName name,
  -                                final String relName,
  -                                final NameScope scope )
  -    {
  -        try
  -        {
  -            name.resolveName( relName, scope );
  -            fail( "expected failure" );
  -        }
  -        catch( FileSystemException e )
  -        {
  -            // TODO - should check error message
  -        }
  -    }
  -
  -    /**
  -     * Tests conversion from absolute to relative names.
  -     */
  -    public void testAbsoluteNameConvert() throws Exception
  -    {
  -        final FileName baseName = baseFolder.getName();
  -
  -        String path = "/test1/test2";
  -        FileName name = baseName.resolveName( path );
  -        assertEquals( path, name.getPath() );
  -
  -        // Try child and descendent names
  -        testRelName( name, "child" );
  -        testRelName( name, "child1/child2" );
  -
  -        // Try own name
  -        testRelName( name, "." );
  -
  -        // Try parent, and root
  -        testRelName( name, ".." );
  -        testRelName( name, "../.." );
  -
  -        // Try sibling and descendent of sibling
  -        testRelName( name, "../sibling" );
  -        testRelName( name, "../sibling/child" );
  -
  -        // Try siblings with similar names
  -        testRelName( name, "../test2_not" );
  -        testRelName( name, "../test2_not/child" );
  -        testRelName( name, "../test" );
  -        testRelName( name, "../test/child" );
  -
  -        // Try unrelated
  -        testRelName( name, "../../unrelated" );
  -        testRelName( name, "../../test" );
  -        testRelName( name, "../../test/child" );
  -
  -        // Test against root
  -        path = "/";
  -        name = baseName.resolveName( path );
  -        assertEquals( path, name.getPath() );
  -
  -        // Try child and descendent names (against root)
  -        testRelName( name, "child" );
  -        testRelName( name, "child1/child2" );
  -
  -        // Try own name (against root)
  -        testRelName( name, "." );
  -    }
  -
  -    /**
  -     * Checks that a file name converts to an expected relative path
  -     */
  -    private void testRelName( final FileName baseName,
  -                              final String relPath )
  -        throws Exception
  -    {
  -        final FileName expectedName = baseName.resolveName( relPath );
  -
  -        // Convert to relative path, and check
  -        final String actualRelPath = baseName.getRelativeName( expectedName );
  -        assertEquals( relPath, actualRelPath );
  -    }
  -
  -    /**
  -     * Walks the base folder structure, asserting it contains exactly the
  -     * expected files and folders.
  -     */
  -    public void testStructure() throws Exception
  -    {
  -        final FileInfo baseInfo = buildExpectedStructure();
  -        assertSameStructure( baseFolder, baseInfo );
  -    }
  -
  -    /**
  -     * Walks a folder structure, asserting it contains exactly the
  -     * expected files and folders.
  -     */
  -    protected void assertSameStructure( final FileObject folder,
  -                                        final FileInfo expected )
  -        throws Exception
  -    {
  -        // Setup the structure
  -        final List queueExpected = new ArrayList();
  -        queueExpected.add( expected );
  -
  -        final List queueActual = new ArrayList();
  -        queueActual.add( folder );
  -
  -        while( queueActual.size() > 0 )
  -        {
  -            final FileObject file = (FileObject)queueActual.remove( 0 );
  -            final FileInfo info = (FileInfo)queueExpected.remove( 0 );
  -
  -            // Check the type is correct
  -            assertSame( file.getType(), info.type );
  -
  -            if( info.type == FileType.FILE )
  -            {
  -                continue;
  -            }
  -
  -            // Check children
  -            final FileObject[] children = file.getChildren();
  -
  -            // Make sure all children were found
  -            assertNotNull( children );
  -            assertEquals( "count children of \"" + file.getName() + "\"", info.children.size(), children.length );
  -
  -            // Recursively check each child
  -            for( int i = 0; i < children.length; i++ )
  -            {
  -                final FileObject child = children[ i ];
  -                final FileInfo childInfo = (FileInfo)info.children.get( child.getName().getBaseName() );
  -
  -                // Make sure the child is expected
  -                assertNotNull( childInfo );
  -
  -                // Add to the queue of files to check
  -                queueExpected.add( childInfo );
  -                queueActual.add( child );
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Tests existence determination.
  -     */
  -    public void testExists() throws Exception
  -    {
  -        // Test a file
  -        FileObject file = baseFolder.resolveFile( "file1.txt" );
  -        assertTrue( "file exists", file.exists() );
  -
  -        // Test a folder
  -        file = baseFolder.resolveFile( "dir1" );
  -        assertTrue( "folder exists", file.exists() );
  -
  -        // Test an unknown file
  -        file = baseFolder.resolveFile( "unknown-child" );
  -        assertTrue( "unknown file does not exist", !file.exists() );
  -
  -        // Test an unknown file in an unknown folder
  -        file = baseFolder.resolveFile( "unknown-folder/unknown-child" );
  -        assertTrue( "unknown file does not exist", !file.exists() );
  -    }
  -
  -    /**
  -     * Tests type determination.
  -     */
  -    public void testType() throws Exception
  -    {
  -        // Test a file
  -        FileObject file = baseFolder.resolveFile( "file1.txt" );
  -        assertSame( FileType.FILE, file.getType() );
  -
  -        // Test a folder
  -        file = baseFolder.resolveFile( "dir1" );
  -        assertSame( FileType.FOLDER, file.getType() );
  -
  -        // Test an unknown file
  -        file = baseFolder.resolveFile( "unknown-child" );
  -        try
  -        {
  -            file.getType();
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -            assertSameMessage( "vfs.provider/get-type-no-exist.error", file, e );
  -        }
  -    }
  -
  -    /**
  -     * Tests parent identity
  -     */
  -    public void testParent() throws FileSystemException
  -    {
  -        // Test when both exist
  -        FileObject folder = baseFolder.resolveFile( "dir1" );
  -        FileObject child = folder.resolveFile( "file3.txt" );
  -        assertTrue( "folder exists", folder.exists() );
  -        assertTrue( "child exists", child.exists() );
  -        assertSame( folder, child.getParent() );
  -
  -        // Test when file does not exist
  -        child = folder.resolveFile( "unknown-file" );
  -        assertTrue( "folder exists", folder.exists() );
  -        assertTrue( "child does not exist", !child.exists() );
  -        assertSame( folder, child.getParent() );
  -
  -        // Test when neither exists
  -        folder = baseFolder.resolveFile( "unknown-folder" );
  -        child = folder.resolveFile( "unknown-file" );
  -        assertTrue( "folder does not exist", !folder.exists() );
  -        assertTrue( "child does not exist", !child.exists() );
  -        assertSame( folder, child.getParent() );
  -
  -        // Test the parent of the root of the file system
  -        // TODO - refactor out test cases for layered vs originating fs
  -        final FileSystem fileSystem = baseFolder.getFileSystem();
  -        FileObject root = fileSystem.getRoot();
  -        if ( fileSystem.getParentLayer() == null )
  -        {
  -            // No parent layer, so parent should be null
  -            assertNull( "root has null parent", root.getParent() );
  -        }
  -        else
  -        {
  -            // Parent should be parent of parent layer.
  -            assertSame( fileSystem.getParentLayer().getParent(), root.getParent() );
  -        }
  -    }
  -
  -    /**
  -     * Tests that children cannot be listed for non-folders.
  -     */
  -    public void testChildren() throws FileSystemException
  -    {
  -        // Check for file
  -        FileObject file = baseFolder.resolveFile( "file1.txt" );
  -        assertSame( FileType.FILE, file.getType() );
  -        try
  -        {
  -            file.getChildren();
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -            assertSameMessage( "vfs.provider/list-children-not-folder.error", file, e );
  -        }
  -
  -        // Should be able to get child by name
  -        file = file.resolveFile( "some-child" );
  -        assertNotNull( file );
  -
  -        // Check for unknown file
  -        file = baseFolder.resolveFile( "unknown-file" );
  -        assertTrue( !file.exists() );
  -        try
  -        {
  -            file.getChildren();
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -            assertSameMessage( "vfs.provider/list-children-no-exist.error", file, e );
  -        }
  -
  -        // Should be able to get child by name
  -        FileObject child = file.resolveFile( "some-child" );
  -        assertNotNull( child );
  -    }
  -
  -    /**
  -     * Tests VFSClassLoader.
  -     */
  -    public void testVFSClassLoader() throws Exception
  -    {
  -        final FileObject[] objects = { baseFolder };
  -        VFSClassLoader loader =
  -            new VFSClassLoader( objects, manager );
  -
  -        Class testClass = loader.loadClass( "code.ClassToLoad" );
  -        assertTrue( verifyPackage( testClass.getPackage() ) );
  -
  -        Object testObject = testClass.newInstance();
  -        assertSame( "**PRIVATE**", testObject.toString() );
  -
  -        URL resource = loader.getResource( "file1.txt" );
  -        assertNotNull( resource );
  -        URLConnection urlCon = resource.openConnection();
  -        assertSameURLContent( charContent, urlCon );
  -    }
  -
  -    /**
  -     * Verify the package loaded with class loader.
  -     * If the provider supports attributes override this method.
  -     */
  -    protected boolean verifyPackage( Package pack )
  -    {
  -        return "code".equals( pack.getName() ) &&
  -               pack.getImplementationTitle() == null &&
  -               pack.getImplementationVendor() == null &&
  -               pack.getImplementationVersion() == null &&
  -               pack.getSpecificationTitle() == null &&
  -               pack.getSpecificationVendor() == null &&
  -               pack.getSpecificationVersion() == null &&
  -               !pack.isSealed();
  -    }
  -
  -    /**
  -     * Tests url.
  -     */
  -    public void testURL() throws Exception
  -    {
  -        FileObject file = baseFolder.resolveFile( "some-dir/" );
  -        URL url = file.getURL();
  -
  -        assertEquals( file.getName().getURI(), url.toExternalForm() );
  -
  -        URL parentURL = new URL( url, ".." );
  -        assertEquals( baseFolder.getURL(), parentURL );
  -
  -        URL rootURL = new URL( url, "/" );
  -        assertEquals( file.getFileSystem().getRoot().getURL(), rootURL );
  -    }
  -
  -    /**
  -     * Tests content.
  -     */
  -    public void testURLContent() throws Exception
  -    {
  -        // Test non-empty file
  -        FileObject file = baseFolder.resolveFile( "file1.txt" );
  -        URLConnection urlCon = file.getURL().openConnection();
  -        assertSameURLContent( charContent, urlCon );
  -
  -        // Test empty file
  -        file = baseFolder.resolveFile( "empty.txt" );
  -        urlCon = file.getURL().openConnection();
  -        assertSameURLContent( "", urlCon );
  -    }
  -
  -    /**
  -     * Asserts that the content of a file is the same as expected. Checks the
  -     * length reported by getContentLength() is correct, then reads the content
  -     * as a byte stream and compares the result with the expected content.
  -     * Assumes files are encoded using UTF-8.
  -     */
  -    protected void assertSameURLContent( final String expected,
  -                                         final URLConnection connection )
  -        throws Exception
  -    {
  -        // Get file content as a binary stream
  -        final byte[] expectedBin = expected.getBytes( "utf-8" );
  -
  -        // Check lengths
  -        assertEquals( "same content length", expectedBin.length, connection.getContentLength() );
  -
  -        // Read content into byte array
  -        final InputStream instr = connection.getInputStream();
  -        final ByteArrayOutputStream outstr;
  -        try
  -        {
  -            outstr = new ByteArrayOutputStream();
  -            final byte[] buffer = new byte[ 256 ];
  -            int nread = 0;
  -            while( nread >= 0 )
  -            {
  -                outstr.write( buffer, 0, nread );
  -                nread = instr.read( buffer );
  -            }
  -        }
  -        finally
  -        {
  -            instr.close();
  -        }
  -
  -        // Compare
  -        assertTrue( "same binary content", Arrays.equals( expectedBin, outstr.toByteArray() ) );
  -    }
  -
  -    /**
  -     * Tests that folders and unknown files have no content.
  -     */
  -    public void testNoURLContent() throws Exception
  -    {
  -        // Try getting the content of a folder
  -        FileObject folder = baseFolder.resolveFile( "dir1" );
  -        try
  -        {
  -            folder.getURL().openConnection().getInputStream();
  -            fail();
  -        }
  -        catch( IOException e )
  -        {
  -            assertSameMessage( "vfs.provider/read-folder.error", folder, e );
  -        }
  -
  -        // Try getting the content of an unknown file
  -        FileObject unknownFile = baseFolder.resolveFile( "unknown-file" );
  -        URLConnection connection = unknownFile.getURL().openConnection();
  -        try
  -        {
  -            connection.getInputStream();
  -            fail();
  -        }
  -        catch( IOException e )
  -        {
  -            assertSameMessage( "vfs.provider/read-no-exist.error", unknownFile, e );
  -        }
  -        assertEquals( -1, connection.getContentLength() );
  -    }
  -
  -    /**
  -     * Tests content.
  -     */
  -    public void testContent() throws Exception
  -    {
  -        // Test non-empty file
  -        FileObject file = baseFolder.resolveFile( "file1.txt" );
  -        FileContent content = file.getContent();
  -        assertSameContent( charContent, content );
  -
  -        // Test empty file
  -        file = baseFolder.resolveFile( "empty.txt" );
  -        content = file.getContent();
  -        assertSameContent( "", content );
  -    }
  -
  -    /**
  -     * Asserts that the content of a file is the same as expected. Checks the
  -     * length reported by getSize() is correct, then reads the content as
  -     * a byte stream and compares the result with the expected content.
  -     * Assumes files are encoded using UTF-8.
  -     */
  -    protected void assertSameContent( final String expected,
  -                                      final FileContent content )
  -        throws Exception
  -    {
  -        // Get file content as a binary stream
  -        final byte[] expectedBin = expected.getBytes( "utf-8" );
  -
  -        // Check lengths
  -        assertEquals( "same content length", expectedBin.length, content.getSize() );
  -
  -        // Read content into byte array
  -        final InputStream instr = content.getInputStream();
  -        final ByteArrayOutputStream outstr;
  -        try
  -        {
  -            outstr = new ByteArrayOutputStream();
  -            final byte[] buffer = new byte[ 256 ];
  -            int nread = 0;
  -            while( nread >= 0 )
  -            {
  -                outstr.write( buffer, 0, nread );
  -                nread = instr.read( buffer );
  -            }
  -        }
  -        finally
  -        {
  -            instr.close();
  -        }
  -
  -        // Compare
  -        assertTrue( "same binary content", Arrays.equals( expectedBin, outstr.toByteArray() ) );
  -    }
  -
  -    /**
  -     * Tests that folders and unknown files have no content.
  -     */
  -    public void testNoContent() throws Exception
  -    {
  -        // Try getting the content of a folder
  -        FileObject folder = baseFolder.resolveFile( "dir1" );
  -        try
  -        {
  -            folder.getContent().getInputStream();
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -            assertSameMessage( "vfs.provider/read-folder.error", folder, e );
  -        }
  -
  -        // Try getting the content of an unknown file
  -        FileObject unknownFile = baseFolder.resolveFile( "unknown-file" );
  -        FileContent content = unknownFile.getContent();
  -        try
  -        {
  -            content.getInputStream();
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -            assertSameMessage( "vfs.provider/read-no-exist.error", unknownFile, e );
  -        }
  -        try
  -        {
  -            content.getSize();
  -            fail();
  -        }
  -        catch( FileSystemException e )
  -        {
  -            assertSameMessage( "vfs.provider/get-size-no-exist.error", unknownFile, e );
  -        }
  -    }
  -
  -    /**
  -     * Tests that content and file objects are usable after being closed.
  -     */
  -    public void testReuse() throws Exception
  -    {
  -        // Get the test file
  -        FileObject file = baseFolder.resolveFile( "file1.txt" );
  -        assertEquals( FileType.FILE, file.getType() );
  -
  -        // Get the file content
  -        FileContent content = file.getContent();
  -        assertSameContent( charContent, content );
  -
  -        // Read the content again
  -        content = file.getContent();
  -        assertSameContent( charContent, content );
  -
  -        // Close the content + file
  -        content.close();
  -        file.close();
  -
  -        // Read the content again
  -        content = file.getContent();
  -        assertSameContent( charContent, content );
  -    }
  -
  -    /**
  -     * Tests that findFiles() works.
  -     */
  -    public void testFindFiles() throws Exception
  -    {
  -        final FileInfo fileInfo = buildExpectedStructure();
  -        final VerifyingFileSelector selector = new VerifyingFileSelector( fileInfo );
  -
  -        // Find the files
  -        final FileObject[] actualFiles = baseFolder.findFiles( selector );
  -
  -        // Compare actual and expected list of files
  -        final List expectedFiles = selector.finish();
  -        assertEquals( expectedFiles.size(), actualFiles.length );
  -        final int count = expectedFiles.size();
  -        for ( int i = 0; i < count; i++ )
  -        {
  -            final FileObject expected = (FileObject)expectedFiles.get( i );
  -            final FileObject actual = actualFiles[ i ];
  -            assertEquals( expected, actual );
  -        }
       }
   }
  
  
  
  1.3       +0 -4      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractReadOnlyFileSystemTestCase.java
  
  Index: AbstractReadOnlyFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractReadOnlyFileSystemTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractReadOnlyFileSystemTestCase.java	23 Oct 2002 11:59:39 -0000	1.2
  +++ AbstractReadOnlyFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.3
  @@ -63,8 +63,4 @@
    */
   public abstract class AbstractReadOnlyFileSystemTestCase extends AbstractFileSystemTestCase
   {
  -    public AbstractReadOnlyFileSystemTestCase( String name )
  -    {
  -        super( name );
  -    }
   }
  
  
  
  1.5       +1 -11     jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractWritableFileSystemTestCase.java
  
  Index: AbstractWritableFileSystemTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractWritableFileSystemTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractWritableFileSystemTestCase.java	25 Oct 2002 03:59:10 -0000	1.4
  +++ AbstractWritableFileSystemTestCase.java	21 Nov 2002 04:25:58 -0000	1.5
  @@ -72,19 +72,9 @@
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    */
  -public abstract class AbstractWritableFileSystemTestCase
  +public class AbstractWritableFileSystemTestCase
       extends AbstractFileSystemTestCase
   {
  -    public AbstractWritableFileSystemTestCase( String name )
  -    {
  -        super( name );
  -    }
  -
  -    /**
  -     * Returns the URI for the area to do tests in.
  -     */
  -    protected abstract FileObject getWriteFolder() throws Exception;
  -
       /**
        * Sets up a scratch folder for the test to use.
        */
  
  
  
  1.5       +1 -6      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileSystemManagerFactoryTestCase.java	23 Oct 2002 13:12:15 -0000	1.4
  +++ FileSystemManagerFactoryTestCase.java	21 Nov 2002 04:25:58 -0000	1.5
  @@ -70,11 +70,6 @@
   public class FileSystemManagerFactoryTestCase
       extends AbstractVfsTestCase
   {
  -    public FileSystemManagerFactoryTestCase( String name )
  -    {
  -        super( name );
  -    }
  -
       /**
        * Sanity test.
        */
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractProviderTestConfig.java
  
  Index: AbstractProviderTestConfig.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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 (INCLUDING, 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.commons.vfs.test;
  
  import org.apache.commons.vfs.impl.DefaultFileSystemManager;
  import org.apache.commons.vfs.FileObject;
  import org.apache.commons.vfs.FileSystemManager;
  
  /**
   * A partial {@link org.apache.commons.vfs.test.ProviderTestConfig} implementation.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:25:58 $
   */
  public abstract class AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Prepares the file system manager.  This implementation does nothing.
       */
      public void prepare( final DefaultFileSystemManager manager )
          throws Exception
      {
      }
  
      /**
       * Returns true if the write tests should be run for this provider.
       */
      public boolean runWriteTests()
      {
          return false;
      }
  
      /**
       * Returns the base folder for write tests.  This implementation returns
       * null.
       */
      public FileObject getWriteTestFolder( final FileSystemManager manager )
          throws Exception
      {
          return null;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderReadTests.java
  
  Index: ProviderReadTests.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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 (INCLUDING, 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.commons.vfs.test;
  
  import org.apache.commons.vfs.FileObject;
  import org.apache.commons.vfs.FileSystemException;
  import org.apache.commons.vfs.FileName;
  import org.apache.commons.vfs.NameScope;
  import org.apache.commons.vfs.FileType;
  import org.apache.commons.vfs.FileSystem;
  import org.apache.commons.vfs.FileContent;
  import org.apache.commons.vfs.impl.VFSClassLoader;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.net.URL;
  import java.net.URLConnection;
  import java.io.InputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  
  /**
   * Read-only test cases for file providers.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:25:58 $
   */
  public class ProviderReadTests
      extends AbstractFileSystemTestCase
  {
      // Contents of "file1.txt"
      private String charContent = "This is a test file.";
  
      /**
       * Tests resolution of absolute URI.
       */
      public void testAbsoluteURI() throws Exception
      {
          // Try fetching base folder again by its URI
          final String uri = getReadFolder().getName().getURI();
          final FileObject file = getManager().resolveFile( uri );
  
          assertSame( "file object", getReadFolder(), file );
      }
  
      /**
       * Tests resolution of relative file names via the FS manager
       */
      public void testRelativeURI() throws Exception
      {
          // Build base dir
          getManager().setBaseFile( getReadFolder() );
  
          // Locate the base dir
          FileObject file = getManager().resolveFile( "." );
          assertSame( "file object", getReadFolder(), file );
  
          // Locate a child
          file = getManager().resolveFile( "some-child" );
          assertSame( "file object", getReadFolder(), file.getParent() );
  
          // Locate a descendent
          file = getManager().resolveFile( "some-folder/some-file" );
          assertSame( "file object", getReadFolder(), file.getParent().getParent() );
  
          // Locate parent
          file = getManager().resolveFile( ".." );
          assertSame( "file object", getReadFolder().getParent(), file );
      }
  
      /**
       * Tests encoding of relative URI.
       */
      public void testRelativeUriEncoding() throws Exception
      {
          // Build base dir
          getManager().setBaseFile( getReadFolder() );
          final String path = getReadFolder().getName().getPath();
  
          // Encode "some file"
          FileObject file = getManager().resolveFile( "%73%6f%6d%65%20%66%69%6c%65" );
          assertEquals( path + "/some file", file.getName().getPath() );
  
          // Encode "."
          file = getManager().resolveFile( "%2e" );
          assertEquals( path, file.getName().getPath() );
  
          // Encode '%'
          file = getManager().resolveFile( "a%25" );
          assertEquals( path + "/a%", file.getName().getPath() );
  
          // Encode /
          file = getManager().resolveFile( "dir%2fchild" );
          assertEquals( path + "/dir/child", file.getName().getPath() );
  
          // Encode \
          file = getManager().resolveFile( "dir%5cchild" );
          assertEquals( path + "/dir/child", file.getName().getPath() );
  
          // Use "%" literal
          try
          {
              getManager().resolveFile( "%" );
              fail();
          }
          catch ( FileSystemException e )
          {
          }
  
          // Not enough digits in encoded char
          try
          {
              getManager().resolveFile( "%5" );
              fail();
          }
          catch ( FileSystemException e )
          {
          }
  
          // Invalid digit in encoded char
          try
          {
              getManager().resolveFile( "%q" );
              fail();
          }
          catch ( FileSystemException e )
          {
          }
      }
  
      /**
       * Tests the root file name.
       */
      public void testRootFileName() throws Exception
      {
          // Locate the root file
          final FileName rootName = getReadFolder().getFileSystem().getRoot().getName();
  
          // Test that the root path is "/"
          assertEquals( "root path", "/", rootName.getPath() );
  
          // Test that the root basname is ""
          assertEquals( "root base name", "", rootName.getBaseName() );
  
          // Test that the root name has no parent
          assertNull( "root parent", rootName.getParent() );
      }
  
      /**
       * Tests child file names.
       */
      public void testChildName() throws Exception
      {
          final FileName baseName = getReadFolder().getName();
          final String basePath = baseName.getPath();
          final FileName name = baseName.resolveName( "some-child", NameScope.CHILD );
  
          // Test path is absolute
          assertTrue( "is absolute", basePath.startsWith( "/" ) );
  
          // Test base name
          assertEquals( "base name", "some-child", name.getBaseName() );
  
          // Test absolute path
          assertEquals( "absolute path", basePath + "/some-child", name.getPath() );
  
          // Test parent path
          assertEquals( "parent absolute path", basePath, name.getParent().getPath() );
  
          // Try using a compound name to find a child
          assertBadName( name, "a/b", NameScope.CHILD );
  
          // Check other invalid names
          checkDescendentNames( name, NameScope.CHILD );
      }
  
      /**
       * Name resolution tests that are common for CHILD or DESCENDENT scope.
       */
      private void checkDescendentNames( final FileName name,
                                         final NameScope scope )
          throws Exception
      {
          // Make some assumptions about the name
          assertTrue( !name.getPath().equals( "/" ) );
          assertTrue( !name.getPath().endsWith( "/a" ) );
          assertTrue( !name.getPath().endsWith( "/a/b" ) );
  
          // Test names with the same prefix
          String path = name.getPath() + "/a";
          assertSameName( path, name, path, scope );
          assertSameName( path, name, "../" + name.getBaseName() + "/a", scope );
  
          // Test an empty name
          assertBadName( name, "", scope );
  
          // Test . name
          assertBadName( name, ".", scope );
          assertBadName( name, "./", scope );
  
          // Test ancestor names
          assertBadName( name, "..", scope );
          assertBadName( name, "../a", scope );
          assertBadName( name, "../" + name.getBaseName() + "a", scope );
          assertBadName( name, "a/..", scope );
  
          // Test absolute names
          assertBadName( name, "/", scope );
          assertBadName( name, "/a", scope );
          assertBadName( name, "/a/b", scope );
          assertBadName( name, name.getPath(), scope );
          assertBadName( name, name.getPath() + "a", scope );
      }
  
      /**
       * Checks that a relative name resolves to the expected absolute path.
       * Tests both forward and back slashes.
       */
      private void assertSameName( final String expectedPath,
                                   final FileName baseName,
                                   final String relName,
                                   final NameScope scope )
          throws Exception
      {
          // Try the supplied name
          FileName name = baseName.resolveName( relName, scope );
          assertEquals( expectedPath, name.getPath() );
  
          // Replace the separators
          relName.replace( '\\', '/' );
          name = baseName.resolveName( relName, scope );
          assertEquals( expectedPath, name.getPath() );
  
          // And again
          relName.replace( '/', '\\' );
          name = baseName.resolveName( relName, scope );
          assertEquals( expectedPath, name.getPath() );
      }
  
      /**
       * Checks that a relative name resolves to the expected absolute path.
       * Tests both forward and back slashes.
       */
      private void assertSameName( String expectedPath,
                                   FileName baseName,
                                   String relName ) throws Exception
      {
          assertSameName( expectedPath, baseName, relName, NameScope.FILE_SYSTEM );
      }
  
      /**
       * Tests relative name resolution, relative to the base folder.
       */
      public void testNameResolution() throws Exception
      {
          final FileName baseName = getReadFolder().getName();
          final String parentPath = baseName.getParent().getPath();
          final String path = baseName.getPath();
          final String childPath = path + "/some-child";
  
          // Test empty relative path
          assertSameName( path, baseName, "" );
  
          // Test . relative path
          assertSameName( path, baseName, "." );
  
          // Test ./ relative path
          assertSameName( path, baseName, "./" );
  
          // Test .// relative path
          assertSameName( path, baseName, ".//" );
  
          // Test .///.///. relative path
          assertSameName( path, baseName, ".///.///." );
          assertSameName( path, baseName, "./\\/.\\//." );
  
          // Test <elem>/.. relative path
          assertSameName( path, baseName, "a/.." );
  
          // Test .. relative path
          assertSameName( parentPath, baseName, ".." );
  
          // Test ../ relative path
          assertSameName( parentPath, baseName, "../" );
  
          // Test ..//./ relative path
          assertSameName( parentPath, baseName, "..//./" );
          assertSameName( parentPath, baseName, "..//.\\" );
  
          // Test <elem>/../.. relative path
          assertSameName( parentPath, baseName, "a/../.." );
  
          // Test <elem> relative path
          assertSameName( childPath, baseName, "some-child" );
  
          // Test ./<elem> relative path
          assertSameName( childPath, baseName, "./some-child" );
  
          // Test ./<elem>/ relative path
          assertSameName( childPath, baseName, "./some-child/" );
  
          // Test <elem>/././././ relative path
          assertSameName( childPath, baseName, "./some-child/././././" );
  
          // Test <elem>/../<elem> relative path
          assertSameName( childPath, baseName, "a/../some-child" );
  
          // Test <elem>/<elem>/../../<elem> relative path
          assertSameName( childPath, baseName, "a/b/../../some-child" );
      }
  
      /**
       * Tests descendent name resolution.
       */
      public void testDescendentName()
          throws Exception
      {
          final FileName baseName = getReadFolder().getName();
  
          // Test direct child
          String path = baseName.getPath() + "/some-child";
          assertSameName( path, baseName, "some-child", NameScope.DESCENDENT );
  
          // Test compound name
          path = path + "/grand-child";
          assertSameName( path, baseName, "some-child/grand-child", NameScope.DESCENDENT );
  
          // Test relative names
          assertSameName( path, baseName, "./some-child/grand-child", NameScope.DESCENDENT );
          assertSameName( path, baseName, "./nada/../some-child/grand-child", NameScope.DESCENDENT );
          assertSameName( path, baseName, "some-child/./grand-child", NameScope.DESCENDENT );
  
          // Test badly formed descendent names
          checkDescendentNames( baseName, NameScope.DESCENDENT );
      }
  
      /**
       * Tests resolution of absolute names.
       */
      public void testAbsoluteNames() throws Exception
      {
          // Test against the base folder
          FileName name = getReadFolder().getName();
          checkAbsoluteNames( name );
  
          // Test against the root
          name = getReadFolder().getFileSystem().getRoot().getName();
          checkAbsoluteNames( name );
  
          // Test against some unknown file
          name = name.resolveName( "a/b/unknown" );
          checkAbsoluteNames( name );
      }
  
      /**
       * Tests resolution of absolute names.
       */
      private void checkAbsoluteNames( final FileName name ) throws Exception
      {
          // Root
          assertSameName( "/", name, "/" );
          assertSameName( "/", name, "//" );
          assertSameName( "/", name, "/." );
          assertSameName( "/", name, "/some file/.." );
  
          // Some absolute names
          assertSameName( "/a", name, "/a" );
          assertSameName( "/a", name, "/./a" );
          assertSameName( "/a", name, "/a/." );
          assertSameName( "/a/b", name, "/a/b" );
  
          // Some bad names
          assertBadName( name, "/..", NameScope.FILE_SYSTEM );
          assertBadName( name, "/a/../..", NameScope.FILE_SYSTEM );
      }
  
      /**
       * Asserts that a particular relative name is invalid for a particular
       * scope.
       */
      private void assertBadName( final FileName name,
                                  final String relName,
                                  final NameScope scope )
      {
          try
          {
              name.resolveName( relName, scope );
              fail( "expected failure" );
          }
          catch ( FileSystemException e )
          {
              // TODO - should check error message
          }
      }
  
      /**
       * Tests conversion from absolute to relative names.
       */
      public void testAbsoluteNameConvert() throws Exception
      {
          final FileName baseName = getReadFolder().getName();
  
          String path = "/test1/test2";
          FileName name = baseName.resolveName( path );
          assertEquals( path, name.getPath() );
  
          // Try child and descendent names
          testRelName( name, "child" );
          testRelName( name, "child1/child2" );
  
          // Try own name
          testRelName( name, "." );
  
          // Try parent, and root
          testRelName( name, ".." );
          testRelName( name, "../.." );
  
          // Try sibling and descendent of sibling
          testRelName( name, "../sibling" );
          testRelName( name, "../sibling/child" );
  
          // Try siblings with similar names
          testRelName( name, "../test2_not" );
          testRelName( name, "../test2_not/child" );
          testRelName( name, "../test" );
          testRelName( name, "../test/child" );
  
          // Try unrelated
          testRelName( name, "../../unrelated" );
          testRelName( name, "../../test" );
          testRelName( name, "../../test/child" );
  
          // Test against root
          path = "/";
          name = baseName.resolveName( path );
          assertEquals( path, name.getPath() );
  
          // Try child and descendent names (against root)
          testRelName( name, "child" );
          testRelName( name, "child1/child2" );
  
          // Try own name (against root)
          testRelName( name, "." );
      }
  
      /**
       * Checks that a file name converts to an expected relative path
       */
      private void testRelName( final FileName baseName,
                                final String relPath )
          throws Exception
      {
          final FileName expectedName = baseName.resolveName( relPath );
  
          // Convert to relative path, and check
          final String actualRelPath = baseName.getRelativeName( expectedName );
          assertEquals( relPath, actualRelPath );
      }
  
      /**
       * Walks the base folder structure, asserting it contains exactly the
       * expected files and folders.
       */
      public void testStructure() throws Exception
      {
          final FileInfo baseInfo = buildExpectedStructure();
          assertSameStructure( getReadFolder(), baseInfo );
      }
  
      /**
       * Builds the expected folder structure.
       */
      private FileInfo buildExpectedStructure()
      {
          // Build the expected structure
          final FileInfo base = new FileInfo( getReadFolder().getName().getBaseName(), FileType.FOLDER );
          base.addChild( "file1.txt", FileType.FILE );
          base.addChild( "empty.txt", FileType.FILE );
          base.addChild( "emptydir", FileType.FOLDER );
  
          final FileInfo dir = new FileInfo( "dir1", FileType.FOLDER );
          base.addChild( dir );
          dir.addChild( "file1.txt", FileType.FILE );
          dir.addChild( "file2.txt", FileType.FILE );
          dir.addChild( "file3.txt", FileType.FILE );
  
          final FileInfo code = new FileInfo( "code", FileType.FOLDER );
          base.addChild( code );
          code.addChild( "ClassToLoad.class", FileType.FILE );
          return base;
      }
  
      /**
       * Walks a folder structure, asserting it contains exactly the
       * expected files and folders.
       */
      protected void assertSameStructure( final FileObject folder,
                                          final FileInfo expected )
          throws Exception
      {
          // Setup the structure
          final List queueExpected = new ArrayList();
          queueExpected.add( expected );
  
          final List queueActual = new ArrayList();
          queueActual.add( folder );
  
          while ( queueActual.size() > 0 )
          {
              final FileObject file = (FileObject)queueActual.remove( 0 );
              final FileInfo info = (FileInfo)queueExpected.remove( 0 );
  
              // Check the type is correct
              assertSame( file.getType(), info.type );
  
              if ( info.type == FileType.FILE )
              {
                  continue;
              }
  
              // Check children
              final FileObject[] children = file.getChildren();
  
              // Make sure all children were found
              assertNotNull( children );
              assertEquals( "count children of \"" + file.getName() + "\"", info.children.size(), children.length );
  
              // Recursively check each child
              for ( int i = 0; i < children.length; i++ )
              {
                  final FileObject child = children[ i ];
                  final FileInfo childInfo = (FileInfo)info.children.get( child.getName().getBaseName() );
  
                  // Make sure the child is expected
                  assertNotNull( childInfo );
  
                  // Add to the queue of files to check
                  queueExpected.add( childInfo );
                  queueActual.add( child );
              }
          }
      }
  
      /**
       * Tests existence determination.
       */
      public void testExists() throws Exception
      {
          // Test a file
          FileObject file = getReadFolder().resolveFile( "file1.txt" );
          assertTrue( "file exists", file.exists() );
  
          // Test a folder
          file = getReadFolder().resolveFile( "dir1" );
          assertTrue( "folder exists", file.exists() );
  
          // Test an unknown file
          file = getReadFolder().resolveFile( "unknown-child" );
          assertTrue( "unknown file does not exist", !file.exists() );
  
          // Test an unknown file in an unknown folder
          file = getReadFolder().resolveFile( "unknown-folder/unknown-child" );
          assertTrue( "unknown file does not exist", !file.exists() );
      }
  
      /**
       * Tests type determination.
       */
      public void testType() throws Exception
      {
          // Test a file
          FileObject file = getReadFolder().resolveFile( "file1.txt" );
          assertSame( FileType.FILE, file.getType() );
  
          // Test a folder
          file = getReadFolder().resolveFile( "dir1" );
          assertSame( FileType.FOLDER, file.getType() );
  
          // Test an unknown file
          file = getReadFolder().resolveFile( "unknown-child" );
          try
          {
              file.getType();
              fail();
          }
          catch ( FileSystemException e )
          {
              assertSameMessage( "vfs.provider/get-type-no-exist.error", file, e );
          }
      }
  
      /**
       * Tests parent identity
       */
      public void testParent() throws FileSystemException
      {
          // Test when both exist
          FileObject folder = getReadFolder().resolveFile( "dir1" );
          FileObject child = folder.resolveFile( "file3.txt" );
          assertTrue( "folder exists", folder.exists() );
          assertTrue( "child exists", child.exists() );
          assertSame( folder, child.getParent() );
  
          // Test when file does not exist
          child = folder.resolveFile( "unknown-file" );
          assertTrue( "folder exists", folder.exists() );
          assertTrue( "child does not exist", !child.exists() );
          assertSame( folder, child.getParent() );
  
          // Test when neither exists
          folder = getReadFolder().resolveFile( "unknown-folder" );
          child = folder.resolveFile( "unknown-file" );
          assertTrue( "folder does not exist", !folder.exists() );
          assertTrue( "child does not exist", !child.exists() );
          assertSame( folder, child.getParent() );
  
          // Test the parent of the root of the file system
          // TODO - refactor out test cases for layered vs originating fs
          final FileSystem fileSystem = getReadFolder().getFileSystem();
          FileObject root = fileSystem.getRoot();
          if ( fileSystem.getParentLayer() == null )
          {
              // No parent layer, so parent should be null
              assertNull( "root has null parent", root.getParent() );
          }
          else
          {
              // Parent should be parent of parent layer.
              assertSame( fileSystem.getParentLayer().getParent(), root.getParent() );
          }
      }
  
      /**
       * Tests that children cannot be listed for non-folders.
       */
      public void testChildren() throws FileSystemException
      {
          // Check for file
          FileObject file = getReadFolder().resolveFile( "file1.txt" );
          assertSame( FileType.FILE, file.getType() );
          try
          {
              file.getChildren();
              fail();
          }
          catch ( FileSystemException e )
          {
              assertSameMessage( "vfs.provider/list-children-not-folder.error", file, e );
          }
  
          // Should be able to get child by name
          file = file.resolveFile( "some-child" );
          assertNotNull( file );
  
          // Check for unknown file
          file = getReadFolder().resolveFile( "unknown-file" );
          assertTrue( !file.exists() );
          try
          {
              file.getChildren();
              fail();
          }
          catch ( FileSystemException e )
          {
              assertSameMessage( "vfs.provider/list-children-no-exist.error", file, e );
          }
  
          // Should be able to get child by name
          FileObject child = file.resolveFile( "some-child" );
          assertNotNull( child );
      }
  
      /**
       * Tests VFSClassLoader.
       */
      public void testVFSClassLoader() throws Exception
      {
          final FileObject[] objects = {getReadFolder()};
          VFSClassLoader loader =
              new VFSClassLoader( objects, getManager() );
  
          Class testClass = loader.loadClass( "code.ClassToLoad" );
          assertTrue( verifyPackage( testClass.getPackage() ) );
  
          Object testObject = testClass.newInstance();
          assertSame( "**PRIVATE**", testObject.toString() );
  
          URL resource = loader.getResource( "file1.txt" );
          assertNotNull( resource );
          URLConnection urlCon = resource.openConnection();
          assertSameURLContent( charContent, urlCon );
      }
  
      /**
       * Verify the package loaded with class loader.
       * If the provider supports attributes override this method.
       */
      protected boolean verifyPackage( Package pack )
      {
          return "code".equals( pack.getName() ) &&
              pack.getImplementationTitle() == null &&
              pack.getImplementationVendor() == null &&
              pack.getImplementationVersion() == null &&
              pack.getSpecificationTitle() == null &&
              pack.getSpecificationVendor() == null &&
              pack.getSpecificationVersion() == null &&
              !pack.isSealed();
      }
  
      /**
       * Tests url.
       */
      public void testURL() throws Exception
      {
          FileObject file = getReadFolder().resolveFile( "some-dir/" );
          URL url = file.getURL();
  
          assertEquals( file.getName().getURI(), url.toExternalForm() );
  
          URL parentURL = new URL( url, ".." );
          assertEquals( getReadFolder().getURL(), parentURL );
  
          URL rootURL = new URL( url, "/" );
          assertEquals( file.getFileSystem().getRoot().getURL(), rootURL );
      }
  
      /**
       * Tests content.
       */
      public void testURLContent() throws Exception
      {
          // Test non-empty file
          FileObject file = getReadFolder().resolveFile( "file1.txt" );
          URLConnection urlCon = file.getURL().openConnection();
          assertSameURLContent( charContent, urlCon );
  
          // Test empty file
          file = getReadFolder().resolveFile( "empty.txt" );
          urlCon = file.getURL().openConnection();
          assertSameURLContent( "", urlCon );
      }
  
      /**
       * Asserts that the content of a file is the same as expected. Checks the
       * length reported by getContentLength() is correct, then reads the content
       * as a byte stream and compares the result with the expected content.
       * Assumes files are encoded using UTF-8.
       */
      protected void assertSameURLContent( final String expected,
                                           final URLConnection connection )
          throws Exception
      {
          // Get file content as a binary stream
          final byte[] expectedBin = expected.getBytes( "utf-8" );
  
          // Check lengths
          assertEquals( "same content length", expectedBin.length, connection.getContentLength() );
  
          // Read content into byte array
          final InputStream instr = connection.getInputStream();
          final ByteArrayOutputStream outstr;
          try
          {
              outstr = new ByteArrayOutputStream();
              final byte[] buffer = new byte[ 256 ];
              int nread = 0;
              while ( nread >= 0 )
              {
                  outstr.write( buffer, 0, nread );
                  nread = instr.read( buffer );
              }
          }
          finally
          {
              instr.close();
          }
  
          // Compare
          assertTrue( "same binary content", Arrays.equals( expectedBin, outstr.toByteArray() ) );
      }
  
      /**
       * Tests that folders and unknown files have no content.
       */
      public void testNoURLContent() throws Exception
      {
          // Try getting the content of a folder
          FileObject folder = getReadFolder().resolveFile( "dir1" );
          try
          {
              folder.getURL().openConnection().getInputStream();
              fail();
          }
          catch ( IOException e )
          {
              assertSameMessage( "vfs.provider/read-folder.error", folder, e );
          }
  
          // Try getting the content of an unknown file
          FileObject unknownFile = getReadFolder().resolveFile( "unknown-file" );
          URLConnection connection = unknownFile.getURL().openConnection();
          try
          {
              connection.getInputStream();
              fail();
          }
          catch ( IOException e )
          {
              assertSameMessage( "vfs.provider/read-no-exist.error", unknownFile, e );
          }
          assertEquals( -1, connection.getContentLength() );
      }
  
      /**
       * Tests content.
       */
      public void testContent() throws Exception
      {
          // Test non-empty file
          FileObject file = getReadFolder().resolveFile( "file1.txt" );
          FileContent content = file.getContent();
          assertSameContent( charContent, content );
  
          // Test empty file
          file = getReadFolder().resolveFile( "empty.txt" );
          content = file.getContent();
          assertSameContent( "", content );
      }
  
      /**
       * Asserts that the content of a file is the same as expected. Checks the
       * length reported by getSize() is correct, then reads the content as
       * a byte stream and compares the result with the expected content.
       * Assumes files are encoded using UTF-8.
       */
      protected void assertSameContent( final String expected,
                                        final FileContent content )
          throws Exception
      {
          // Get file content as a binary stream
          final byte[] expectedBin = expected.getBytes( "utf-8" );
  
          // Check lengths
          assertEquals( "same content length", expectedBin.length, content.getSize() );
  
          // Read content into byte array
          final InputStream instr = content.getInputStream();
          final ByteArrayOutputStream outstr;
          try
          {
              outstr = new ByteArrayOutputStream();
              final byte[] buffer = new byte[ 256 ];
              int nread = 0;
              while ( nread >= 0 )
              {
                  outstr.write( buffer, 0, nread );
                  nread = instr.read( buffer );
              }
          }
          finally
          {
              instr.close();
          }
  
          // Compare
          assertTrue( "same binary content", Arrays.equals( expectedBin, outstr.toByteArray() ) );
      }
  
      /**
       * Tests that folders and unknown files have no content.
       */
      public void testNoContent() throws Exception
      {
          // Try getting the content of a folder
          FileObject folder = getReadFolder().resolveFile( "dir1" );
          try
          {
              folder.getContent().getInputStream();
              fail();
          }
          catch ( FileSystemException e )
          {
              assertSameMessage( "vfs.provider/read-folder.error", folder, e );
          }
  
          // Try getting the content of an unknown file
          FileObject unknownFile = getReadFolder().resolveFile( "unknown-file" );
          FileContent content = unknownFile.getContent();
          try
          {
              content.getInputStream();
              fail();
          }
          catch ( FileSystemException e )
          {
              assertSameMessage( "vfs.provider/read-no-exist.error", unknownFile, e );
          }
          try
          {
              content.getSize();
              fail();
          }
          catch ( FileSystemException e )
          {
              assertSameMessage( "vfs.provider/get-size-no-exist.error", unknownFile, e );
          }
      }
  
      /**
       * Tests that content and file objects are usable after being closed.
       */
      public void testReuse() throws Exception
      {
          // Get the test file
          FileObject file = getReadFolder().resolveFile( "file1.txt" );
          assertEquals( FileType.FILE, file.getType() );
  
          // Get the file content
          FileContent content = file.getContent();
          assertSameContent( charContent, content );
  
          // Read the content again
          content = file.getContent();
          assertSameContent( charContent, content );
  
          // Close the content + file
          content.close();
          file.close();
  
          // Read the content again
          content = file.getContent();
          assertSameContent( charContent, content );
      }
  
      /**
       * Tests that findFiles() works.
       */
      public void testFindFiles() throws Exception
      {
          final FileInfo fileInfo = buildExpectedStructure();
          final VerifyingFileSelector selector = new VerifyingFileSelector( fileInfo );
  
          // Find the files
          final FileObject[] actualFiles = getReadFolder().findFiles( selector );
  
          // Compare actual and expected list of files
          final List expectedFiles = selector.finish();
          assertEquals( expectedFiles.size(), actualFiles.length );
          final int count = expectedFiles.size();
          for ( int i = 0; i < count; i++ )
          {
              final FileObject expected = (FileObject)expectedFiles.get( i );
              final FileObject actual = actualFiles[ i ];
              assertEquals( expected, actual );
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderTestConfig.java
  
  Index: ProviderTestConfig.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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 (INCLUDING, 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.commons.vfs.test;
  
  import org.apache.commons.vfs.FileObject;
  import org.apache.commons.vfs.FileSystemManager;
  import org.apache.commons.vfs.impl.DefaultFileSystemManager;
  
  /**
   * Test configuration for a file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:25:58 $
   */
  public interface ProviderTestConfig
  {
      /**
       * Prepares the file system manager.
       */
      void prepare( DefaultFileSystemManager manager ) throws Exception;
  
      /**
       * Returns the base folder for read tests.
       */
      FileObject getReadTestFolder( FileSystemManager manager ) throws Exception;
  
      /**
       * Returns true if the write tests should be run for this provider.
       */
      boolean runWriteTests();
  
      /**
       * Returns the base folder for write tests.
       */
      FileObject getWriteTestFolder( FileSystemManager manager ) throws Exception;
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderTestSuite.java
  
  Index: ProviderTestSuite.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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 (INCLUDING, 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.commons.vfs.test;
  
  import java.lang.reflect.Method;
  import java.lang.reflect.Modifier;
  import junit.framework.TestSuite;
  
  /**
   * The suite of tests for a file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:25:58 $
   */
  public class ProviderTestSuite
      extends TestSuite
  {
      private final ProviderTestConfig providerConfig;
  
      /**
       * Adds the tests for a file system to this suite.
       */
      public ProviderTestSuite( final ProviderTestConfig fsConfig ) throws Exception
      {
          providerConfig = fsConfig;
          addTestClass( ProviderReadTests.class );
          if ( providerConfig.runWriteTests() )
          {
              addTestClass( AbstractWritableFileSystemTestCase.class );
          }
      }
  
      /**
       * Adds the tests from a class to this suite.  Looks for a no-args constructor
       * which it uses to create instances of the test class.  Adds an instance
       * for each public test method provided by the class.
       */
      private void addTestClass( final Class testClass ) throws Exception
      {
          // Locate the test methods
          final Method[] methods = testClass.getMethods();
          for ( int i = 0; i < methods.length; i++ )
          {
              final Method method = methods[ i ];
              if ( ! method.getName().startsWith( "test")
                  || Modifier.isStatic( method.getModifiers() ) )
              {
                  continue;
              }
  
              // Create instance
              final AbstractFileSystemTestCase testCase = (AbstractFileSystemTestCase)testClass.newInstance();
              testCase.setConfig( providerConfig );
              testCase.setName( method.getName() );
              addTest( testCase );
          }
      }
  }
  
  
  

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


Mime
View raw message