You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ad...@apache.org on 2002/11/21 05:31:38 UTC

cvs commit: jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test AbstractProviderTestCase.java ProviderWriteTests.java ProviderReadTests.java ProviderTestSuite.java AbstractFileSystemTestCase.java AbstractReadOnlyFileSystemTestCase.java AbstractWritableFileSystemTestCase.java

adammurdoch    2002/11/20 20:31:38

  Modified:    vfs/src/test/org/apache/commons/vfs/provider/local/test
                        FileNameTestCase.java
               vfs/src/test/org/apache/commons/vfs/test
                        ProviderReadTests.java ProviderTestSuite.java
  Added:       vfs/src/test/org/apache/commons/vfs/provider/ftp/test
                        FtpProviderTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/jar/test
                        JarProviderTestCase.java NestedJarTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/local/test
                        LocalProviderTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/smb/test
                        SmbProviderTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/temp/test
                        TemporaryProviderTestCase.java
               vfs/src/test/org/apache/commons/vfs/provider/zip/test
                        NestedZipTestCase.java ZipProviderTestCase.java
               vfs/src/test/org/apache/commons/vfs/test
                        AbstractProviderTestCase.java
                        ProviderWriteTests.java
  Removed:     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
  Log:
  Renamed a bunch of test case classes to better reflect what they test.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/ftp/test/FtpProviderTestCase.java
  
  Index: FtpProviderTestCase.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.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;
  
  /**
   * Tests for FTP file systems.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class FtpProviderTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for the ftp file system.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new FtpProviderTestCase() );
      }
  
      /**
       * Prepares the file system manager.
       */
      public void prepare( final DefaultFileSystemManager manager ) throws Exception
      {
          manager.addProvider( "ftp", new FtpFileSystemProvider() );
      }
  
      /**
       * Returns the base folder for read tests.
       */
      public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
      {
          final String uri = System.getProperty( "test.ftp.uri" ) + "/read-tests";
          return manager.resolveFile( uri );
      }
  
      /**
       * Returns true if the write tests should be run for this provider.
       */
      public boolean runWriteTests()
      {
          return true;
      }
  
      /**
       * Returns the base folder for write tests.  Should return null to
       * skip the write tests.
       */
      public FileObject getWriteTestFolder( final FileSystemManager manager ) throws Exception
      {
          final String uri = System.getProperty( "test.ftp.uri" ) + "/write-tests";
          return manager.resolveFile( uri );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/jar/test/JarProviderTestCase.java
  
  Index: JarProviderTestCase.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.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 junit.framework.Test;
  
  /**
   * Tests for the Jar file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class JarProviderTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for the jar file system.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new JarProviderTestCase() );
      }
  
      /**
       * Prepares the file system manager.
       */
      public void prepare( final DefaultFileSystemManager manager )
          throws Exception
      {
          manager.addProvider( "jar", new JarFileSystemProvider() );
      }
  
      /**
       * Returns the base folder for read tests.
       */
      public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
      {
          final File jarFile = AbstractVfsTestCase.getTestResource( "test.jar" );
          final String uri = "jar:" + jarFile.getAbsolutePath() + "!basedir";
          return manager.resolveFile( uri );
      }
  
      /**
       * 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() ) &&
                 "ImplTitle".equals( pack.getImplementationTitle() ) &&
                 "ImplVendor".equals( pack.getImplementationVendor() ) &&
                 "1.1".equals( pack.getImplementationVersion() ) &&
                 "SpecTitle".equals( pack.getSpecificationTitle() ) &&
                 "SpecVendor".equals( pack.getSpecificationVendor() ) &&
                 "1.0".equals( pack.getSpecificationVersion() ) &&
                 !pack.isSealed();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/jar/test/NestedJarTestCase.java
  
  Index: NestedJarTestCase.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.jar.test;
  
  import java.io.File;
  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.jar.JarFileSystemProvider;
  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.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class NestedJarTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for nested jar files.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new NestedJarTestCase() );
      }
  
      /**
       * Prepares the file system manager.  This implementation does nothing.
       */
      public void prepare( final DefaultFileSystemManager manager )
          throws Exception
      {
          manager.addProvider( "jar", new JarFileSystemProvider() );
      }
  
      /**
       * Returns the base folder for read tests.
       */
      public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
      {
          // 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 = manager.createFileSystem( "jar", jarFile );
          return nestedFS.resolveFile( "/basedir" );
      }
  
      /**
       * 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() ) &&
                 "ImplTitle".equals( pack.getImplementationTitle() ) &&
                 "ImplVendor".equals( pack.getImplementationVendor() ) &&
                 "1.1".equals( pack.getImplementationVersion() ) &&
                 "SpecTitle".equals( pack.getSpecificationTitle() ) &&
                 "SpecVendor".equals( pack.getSpecificationVendor() ) &&
                 "1.0".equals( pack.getSpecificationVersion() ) &&
                 !pack.isSealed();
      }
  
      /*
       * TODO - activate this
      public void testJarClassLoader() throws Exception
      {
          FileObject test = topFolder.resolveFile( "normal.jar" );
          final FileObject[] objects = { test };
          VFSClassLoader loader =
              new VFSClassLoader( objects, getManager() );
  
          Class testClass = loader.loadClass( "code.ClassToLoad" );
          assertTrue( verifyNormalPackage( testClass.getPackage() ) );
  
          Object testObject = testClass.newInstance();
          assertSame( "**PRIVATE**", testObject.toString() );
  
          URL resource = loader.getResource( "file1.txt" );
          assertNotNull( resource );
          URLConnection urlCon = resource.openConnection();
          assertSameURLContent( getCharContent(), urlCon );
      }
      */
  
      /**
       * Verify the package loaded with class loader.
       * If the provider supports attributes override this method.
       */
      protected boolean verifyNormalPackage( Package pack )
      {
          return "code".equals( pack.getName() ) &&
                 "NormalTitle".equals( pack.getImplementationTitle() ) &&
                 "NormalVendor".equals( pack.getImplementationVendor() ) &&
                 "1.2".equals( pack.getImplementationVersion() ) &&
                 "NormalSpec".equals( pack.getSpecificationTitle() ) &&
                 "NormalSpecVendor".equals( pack.getSpecificationVendor() ) &&
                 "0.1".equals( pack.getSpecificationVersion() ) &&
                 pack.isSealed();
      }
  }
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/local/test/FileNameTestCase.java
  
  Index: FileNameTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/local/test/FileNameTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileNameTestCase.java	21 Nov 2002 04:25:58 -0000	1.1
  +++ FileNameTestCase.java	21 Nov 2002 04:31:37 -0000	1.2
  @@ -57,7 +57,7 @@
   
   import java.io.File;
   import org.apache.commons.vfs.FileObject;
  -import org.apache.commons.vfs.test.AbstractFileSystemTestCase;
  +import org.apache.commons.vfs.test.AbstractProviderTestCase;
   
   /**
    * Additional naming tests for local file system.
  @@ -66,7 +66,7 @@
    * @version $Revision$ $Date$
    */
   public class FileNameTestCase
  -    extends AbstractFileSystemTestCase
  +    extends AbstractProviderTestCase
   {
       /**
        * Tests resolution of an absolute file name.
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/local/test/LocalProviderTestCase.java
  
  Index: LocalProviderTestCase.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 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;
  
  /**
   * Tests for the local file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class LocalProviderTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for the local file system.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new LocalProviderTestCase() );
      }
  
      /**
       * Prepares the file system manager.
       */
      public void prepare( final DefaultFileSystemManager manager ) throws Exception
      {
      }
  
      /**
       * 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 manager.toFileObject( testDir );
      }
  
      /**
       * Returns true if the write tests should be run for this provider.
       */
      public boolean runWriteTests()
      {
          return true;
      }
  
      /**
       * Returns the base folder for write tests.  Should return null to
       * skip the write tests.
       */
      public FileObject getWriteTestFolder( final FileSystemManager manager ) throws Exception
      {
          final File testDir = AbstractVfsTestCase.getTestDirectory( "write-tests" );
          return manager.toFileObject( testDir );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/smb/test/SmbProviderTestCase.java
  
  Index: SmbProviderTestCase.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.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 junit.framework.Test;
  
  /**
   * Tests for the SMB file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class SmbProviderTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new SmbProviderTestCase() );
      }
  
      /**
       * Prepares the file system manager.  This implementation does nothing.
       */
      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";
          return manager.resolveFile( uri );
      }
  
      /**
       * Returns true if the write tests should be run for this provider.
       */
      public boolean runWriteTests()
      {
          return true;
      }
  
      /**
       * Returns the base folder for write tests.  This implementation returns
       * null.
       */
      public FileObject getWriteTestFolder( final FileSystemManager manager )
          throws Exception
      {
          final String uri = System.getProperty( "test.smb.uri" ) + "/write-tests";
          return manager.resolveFile( uri );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/temp/test/TemporaryProviderTestCase.java
  
  Index: TemporaryProviderTestCase.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.temp.test;
  
  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;
  
  /**
   * Test cases for the tmp: file provider.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:31:37 $
   */
  public class TemporaryProviderTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for the tmp file system.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new TemporaryProviderTestCase() );
      }
  
      /**
       * 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
      {
          return manager.resolveFile( "tmp-read:/basedir" );
      }
  
      /**
       * Returns true if the write tests should be run for this provider.
       */
      public boolean runWriteTests()
      {
          return true;
      }
  
      /**
       * Returns the base folder for write tests.  This implementation returns
       * null.
       */
      public FileObject getWriteTestFolder( final FileSystemManager manager )
          throws Exception
      {
          return manager.resolveFile( "tmp-write:/write-tests" );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/NestedZipTestCase.java
  
  Index: NestedZipTestCase.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.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.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.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class NestedZipTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for nested zip files.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new NestedZipTestCase() );
      }
  
      /**
       * Prepares the file system manager.  This implementation does nothing.
       */
      public void prepare( final DefaultFileSystemManager manager )
          throws Exception
      {
          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 = AbstractVfsTestCase.getTestResource( "nested.zip" ).getAbsolutePath();
          String uri = "zip:" + zipFilePath + "!/test.zip";
          final FileObject zipFile = manager.resolveFile( uri );
  
          // Now build the nested file system
          final FileObject nestedFS = manager.createFileSystem( "zip", zipFile );
          return nestedFS.resolveFile( "/basedir" );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/provider/zip/test/ZipProviderTestCase.java
  
  Index: ZipProviderTestCase.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.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;
  
  /**
   * Tests for the Zip file system.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class ZipProviderTestCase
      extends AbstractProviderTestConfig
      implements ProviderTestConfig
  {
      /**
       * Creates the test suite for the zip file system.
       */
      public static Test suite() throws Exception
      {
          return new ProviderTestSuite( new ZipProviderTestCase() );
      }
  
      /**
       * Prepares the file system manager.
       */
      public void prepare( final DefaultFileSystemManager manager ) throws Exception
      {
          manager.addProvider( "zip", new ZipFileSystemProvider() );
      }
  
      /**
       * Returns the base folder for read tests.
       */
      public FileObject getReadTestFolder( final FileSystemManager manager ) throws Exception
      {
          final File zipFile = AbstractVfsTestCase.getTestResource( "test.zip" );
          final String uri = "zip:" + zipFile.getAbsolutePath() + "!basedir";
          return manager.resolveFile( uri );
      }
  }
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderReadTests.java
  
  Index: ProviderReadTests.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderReadTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProviderReadTests.java	21 Nov 2002 04:25:58 -0000	1.1
  +++ ProviderReadTests.java	21 Nov 2002 04:31:38 -0000	1.2
  @@ -79,7 +79,7 @@
    * @version $Revision$ $Date$
    */
   public class ProviderReadTests
  -    extends AbstractFileSystemTestCase
  +    extends AbstractProviderTestCase
   {
       // Contents of "file1.txt"
       private String charContent = "This is a test file.";
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderTestSuite.java
  
  Index: ProviderTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderTestSuite.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProviderTestSuite.java	21 Nov 2002 04:25:58 -0000	1.1
  +++ ProviderTestSuite.java	21 Nov 2002 04:31:38 -0000	1.2
  @@ -79,7 +79,7 @@
           addTestClass( ProviderReadTests.class );
           if ( providerConfig.runWriteTests() )
           {
  -            addTestClass( AbstractWritableFileSystemTestCase.class );
  +            addTestClass( ProviderWriteTests.class );
           }
       }
   
  @@ -102,7 +102,7 @@
               }
   
               // Create instance
  -            final AbstractFileSystemTestCase testCase = (AbstractFileSystemTestCase)testClass.newInstance();
  +            final AbstractProviderTestCase testCase = (AbstractProviderTestCase)testClass.newInstance();
               testCase.setConfig( providerConfig );
               testCase.setName( method.getName() );
               addTest( testCase );
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractProviderTestCase.java
  
  Index: AbstractProviderTestCase.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.io.File;
  import org.apache.commons.AbstractVfsTestCase;
  import org.apache.commons.vfs.FileObject;
  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.provider.local.DefaultLocalFileSystemProvider;
  
  /**
   * File system test cases, which verifies the structure and naming
   * functionality.
   *
   * Works from a base folder, and assumes a particular structure under
   * that base folder.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/21 04:31:38 $
   */
  public class AbstractProviderTestCase
      extends AbstractVfsTestCase
  {
      private FileObject readFolder;
      private FileObject writeFolder;
      private DefaultFileSystemManager manager;
      private ProviderTestConfig providerConfig;
      private File tempDir;
  
      /** Sets the provider test config, if any. */
      public void setConfig( final ProviderTestConfig providerConfig )
      {
          this.providerConfig = providerConfig;
      }
  
      /**
       * Returns the file system manager used by this test.
       */
      protected DefaultFileSystemManager getManager()
      {
          return manager;
      }
  
      /**
       * Returns the read test folder.
       */
      protected FileObject getReadFolder()
      {
          return readFolder;
      }
  
      /**
       * Returns the write test folder.
       */
      protected FileObject getWriteFolder()
      {
          return writeFolder;
      }
  
      /**
       * Sets up the test
       */
      protected void setUp() throws Exception
      {
          // Create the file system manager
          manager = new DefaultFileSystemManager();
          manager.addProvider( "file", new DefaultLocalFileSystemProvider() );
  
          tempDir = getTestDirectory( "temp" );
          final DefaultFileReplicator replicator = new DefaultFileReplicator( tempDir );
          manager.setReplicator( new PrivilegedFileReplicator( replicator ) );
          manager.setTemporaryFileStore( replicator );
  
          if ( providerConfig != null )
          {
              providerConfig.prepare( manager );
          }
  
          manager.init();
  
          if ( providerConfig != null )
          {
              // Locate the base folder
              readFolder = providerConfig.getReadTestFolder( manager );
              writeFolder = providerConfig.getWriteTestFolder( manager );
  
              // Make some assumptions absout the name
              assertTrue( !readFolder.getName().getPath().equals( "/" ) );
          }
      }
  
      /**
       * Cleans-up test.
       */
      protected void tearDown() throws Exception
      {
          manager.close();
  
          // Make sure temp directory is empty or gone
          assertTrue( ( ! tempDir.exists() ) || ( tempDir.isDirectory() && tempDir.list().length == 0 ) );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java
  
  Index: ProviderWriteTests.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.io.OutputStream;
  import java.util.HashSet;
  import java.util.Set;
  import java.util.ArrayList;
  import org.apache.commons.vfs.Selectors;
  import org.apache.commons.vfs.FileObject;
  import org.apache.commons.vfs.FileSystemException;
  import org.apache.commons.vfs.FileType;
  import org.apache.commons.vfs.FileSystem;
  import org.apache.commons.vfs.FileListener;
  import org.apache.commons.vfs.FileChangeEvent;
  
  /**
   * File system test that check that a file system can be modified.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   */
  public class ProviderWriteTests
      extends AbstractProviderTestCase
  {
      /**
       * Sets up a scratch folder for the test to use.
       */
      protected FileObject createScratchFolder() throws Exception
      {
          FileObject scratchFolder = getWriteFolder();
  
          // Make sure the test folder is empty
          scratchFolder.delete( Selectors.EXCLUDE_SELF );
          scratchFolder.createFolder();
  
          return scratchFolder;
      }
  
      /**
       * Tests folder creation.
       */
      public void testFolderCreate() throws Exception
      {
          FileObject scratchFolder = createScratchFolder();
  
          // Create direct child of the test folder
          FileObject folder = scratchFolder.resolveFile( "dir1" );
          assertTrue( !folder.exists() );
          folder.createFolder();
          assertTrue( folder.exists() );
          assertSame( FileType.FOLDER, folder.getType() );
          assertEquals( 0, folder.getChildren().length );
  
          // Create a descendant, where the intermediate folders don't exist
          folder = scratchFolder.resolveFile( "dir2/dir1/dir1" );
          assertTrue( !folder.exists() );
          assertTrue( !folder.getParent().exists() );
          assertTrue( !folder.getParent().getParent().exists() );
          folder.createFolder();
          assertTrue( folder.exists() );
          assertSame( FileType.FOLDER, folder.getType() );
          assertEquals( 0, folder.getChildren().length );
          assertTrue( folder.getParent().exists() );
          assertTrue( folder.getParent().getParent().exists() );
  
          // Test creating a folder that already exists
          assertTrue( folder.exists() );
          folder.createFolder();
      }
  
      /**
       * Tests file creation
       */
      public void testFileCreate() throws Exception
      {
          FileObject scratchFolder = createScratchFolder();
  
          // Create direct child of the test folder
          FileObject file = scratchFolder.resolveFile( "file1.txt" );
          assertTrue( !file.exists() );
          file.createFile();
          assertTrue( file.exists() );
          assertSame( FileType.FILE, file.getType() );
          assertEquals( 0, file.getContent().getSize() );
  
          // Create a descendant, where the intermediate folders don't exist
          file = scratchFolder.resolveFile( "dir1/dir1/file1.txt" );
          assertTrue( !file.exists() );
          assertTrue( !file.getParent().exists() );
          assertTrue( !file.getParent().getParent().exists() );
          file.createFile();
          assertTrue( file.exists() );
          assertSame( FileType.FILE, file.getType() );
          assertEquals( 0, file.getContent().getSize() );
          assertTrue( file.getParent().exists() );
          assertTrue( file.getParent().getParent().exists() );
  
          // Test creating a file that already exists
          assertTrue( file.exists() );
          file.createFile();
      }
  
      /**
       * Tests file/folder creation with mismatched types.
       */
      public void testFileCreateMismatched() throws Exception
      {
          FileObject scratchFolder = createScratchFolder();
  
          // Create a test file and folder
          FileObject file = scratchFolder.resolveFile( "dir1/file1.txt" );
          file.createFile();
          assertEquals( FileType.FILE, file.getType() );
  
          FileObject folder = scratchFolder.resolveFile( "dir1/dir2" );
          folder.createFolder();
          assertEquals( FileType.FOLDER, folder.getType() );
  
          // Attempt to create a file that already exists as a folder
          try
          {
              folder.createFile();
              fail();
          }
          catch( FileSystemException exc )
          {
          }
  
          // Attempt to create a folder that already exists as a file
          try
          {
              file.createFolder();
              fail();
          }
          catch( FileSystemException exc )
          {
          }
  
          // Attempt to create a folder as a child of a file
          FileObject folder2 = file.resolveFile( "some-child" );
          try
          {
              folder2.createFolder();
              fail();
          }
          catch( FileSystemException exc )
          {
          }
      }
  
      /**
       * Tests deletion
       */
      public void testDelete() throws Exception
      {
          // Set-up the test structure
          FileObject folder = createScratchFolder();
          folder.resolveFile( "file1.txt" ).createFile();
          folder.resolveFile( "emptydir" ).createFolder();
          folder.resolveFile( "dir1/file1.txt" ).createFile();
          folder.resolveFile( "dir1/dir2/file2.txt" ).createFile();
  
          // Delete a file
          FileObject file = folder.resolveFile( "file1.txt" );
          assertTrue( file.exists() );
          file.delete( Selectors.SELECT_ALL );
          assertTrue( !file.exists() );
  
          // Delete an empty folder
          file = folder.resolveFile( "emptydir" );
          assertTrue( file.exists() );
          file.delete( Selectors.SELECT_ALL );
          assertTrue( !file.exists() );
  
          // Recursive delete
          file = folder.resolveFile( "dir1" );
          FileObject file2 = file.resolveFile( "dir2/file2.txt" );
          assertTrue( file.exists() );
          assertTrue( file2.exists() );
          file.delete( Selectors.SELECT_ALL );
          assertTrue( !file.exists() );
          assertTrue( !file2.exists() );
  
          // Delete a file that does not exist
          file = folder.resolveFile( "some-folder/some-file" );
          assertTrue( !file.exists() );
          file.delete( Selectors.SELECT_ALL );
          assertTrue( !file.exists() );
      }
  
      /**
       * Test that children are handled correctly by create and delete.
       */
      public void testListChildren() throws Exception
      {
          FileObject folder = createScratchFolder();
          HashSet names = new HashSet();
  
          // Make sure the folder is empty
          assertEquals( 0, folder.getChildren().length );
  
          // Create a child folder
          folder.resolveFile( "dir1" ).createFolder();
          names.add( "dir1" );
          assertSameFileSet( names, folder.getChildren() );
  
          // Create a child file
          folder.resolveFile( "file1.html" ).createFile();
          names.add( "file1.html" );
          assertSameFileSet( names, folder.getChildren() );
  
          // Create a descendent
          folder.resolveFile( "dir2/file1.txt" ).createFile();
          names.add( "dir2" );
          assertSameFileSet( names, folder.getChildren() );
  
          // Create a child file via an output stream
          OutputStream outstr = folder.resolveFile( "file2.txt" ).getContent().getOutputStream();
          outstr.close();
          names.add( "file2.txt" );
          assertSameFileSet( names, folder.getChildren() );
  
          // Delete a child folder
          folder.resolveFile( "dir1" ).delete( Selectors.SELECT_ALL );
          names.remove( "dir1" );
          assertSameFileSet( names, folder.getChildren() );
  
          // Delete a child file
          folder.resolveFile( "file1.html" ).delete( Selectors.SELECT_ALL );
          names.remove( "file1.html" );
          assertSameFileSet( names, folder.getChildren() );
  
          // Recreate the folder
          folder.delete( Selectors.SELECT_ALL );
          folder.createFolder();
          assertEquals( 0, folder.getChildren().length );
      }
  
      /**
       * Check listeners are notified of changes.
       */
      public void testListener() throws Exception
      {
          final FileObject baseFile = createScratchFolder();
  
          FileObject child = baseFile.resolveFile( "newfile.txt" );
          assertTrue( !child.exists() );
  
          FileSystem fs = baseFile.getFileSystem();
          TestListener listener = new TestListener( child );
          fs.addListener( child, listener );
  
          // Create as a folder
          listener.addCreateEvent();
          child.createFolder();
          listener.assertFinished();
  
          // Create the folder again.  Should not get an event.
          child.createFolder();
  
          // Delete
          listener.addDeleteEvent();
          child.delete();
          listener.assertFinished();
  
          // Delete again.  Should not get an event
          child.delete();
  
          // Create as a file
          listener.addCreateEvent();
          child.createFile();
          listener.assertFinished();
  
          // Create the file again.  Should not get an event
          child.createFile();
  
          listener.addDeleteEvent();
          child.delete();
  
          // Create as a file, by writing to it.
          listener.addCreateEvent();
          child.getContent().getOutputStream().close();
          listener.assertFinished();
  
          // Recreate the file by writing to it
          child.getContent().getOutputStream().close();
  
          // Copy another file over the top
          final FileObject otherChild = baseFile.resolveFile( "folder1" );
          otherChild.createFolder();
          listener.addDeleteEvent();
          listener.addCreateEvent();
          child.copyFrom( otherChild, Selectors.SELECT_SELF );
          listener.assertFinished();
  
          fs.removeListener( child, listener );
      }
  
      /**
       * Ensures the names of a set of files match an expected set.
       */
      private void assertSameFileSet( Set names, FileObject[] files )
      {
          // Make sure the sets are the same length
          assertEquals( names.size(), files.length );
  
          // Check for unexpected names
          for( int i = 0; i < files.length; i++ )
          {
              FileObject file = files[ i ];
              assertTrue( names.contains( file.getName().getBaseName() ) );
          }
      }
  
      /**
       * A test listener.
       */
      private static class TestListener
          implements FileListener
      {
          private final FileObject file;
          private final ArrayList events = new ArrayList();
          private static final Object CREATE = "create";
          private static final Object DELETE = "delete";
  
          public TestListener( final FileObject file )
          {
              this.file = file;
          }
  
          /**
           * Called when a file is created.
           */
          public void fileCreated( final FileChangeEvent event )
          {
              assertTrue( events.size() > 0 && events.remove( 0 ) == CREATE );
              assertSame( file, event.getFile() );
              try
              {
                  assertTrue( file.exists() );
              }
              catch ( FileSystemException e )
              {
                  fail();
              }
          }
  
          /**
           * Called when a file is deleted.
           */
          public void fileDeleted( final FileChangeEvent event )
          {
              assertTrue( events.size() > 0 && events.remove( 0 ) == DELETE );
              assertSame( file, event.getFile() );
              try
              {
                  assertTrue( !file.exists() );
              }
              catch ( FileSystemException e )
              {
                  fail();
              }
          }
  
          public void addCreateEvent()
          {
              events.add( CREATE );
          }
  
          public void addDeleteEvent()
          {
              events.add( DELETE );
          }
  
          public void assertFinished()
          {
              assertEquals( "Missing event", 0, events.size() );
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>