adammurdoch 2002/10/25 04:11:51
Modified: vfs/src/test/org/apache/commons/vfs/test
AbstractFileSystemTestCase.java
vfs/src/test/org/apache/commons/vfs/provider/local/test
LocalFileSystemTestCase.java
Added: vfs/src/test/org/apache/commons/vfs/provider/temp/test
TemporaryFileProiderTestCase.java
Log:
Temp file system unit tests.
Revision Changes Path
1.16 +10 -1
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- AbstractFileSystemTestCase.java 23 Oct 2002 11:59:39 -0000 1.15
+++ AbstractFileSystemTestCase.java 25 Oct 2002 11:11:51 -0000 1.16
@@ -58,6 +58,7 @@
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;
@@ -95,6 +96,7 @@
// Contents of "file1.txt"
private String charContent;
+ private File tempDir;
public AbstractFileSystemTestCase( String name )
{
@@ -178,7 +180,11 @@
// Create the file system manager
manager = new DefaultFileSystemManager();
manager.addProvider( "file", new DefaultLocalFileSystemProvider() );
- manager.setReplicator( new PrivilegedFileReplicator( new
DefaultFileReplicator() ) );
+
+ tempDir = getTestDirectory( "temp" );
+ final DefaultFileReplicator replicator = new DefaultFileReplicator( tempDir
);
+ manager.setReplicator( new PrivilegedFileReplicator( replicator ) );
+ manager.setTemporaryFileStore( replicator );
// Locate the base folder
baseFolder = getBaseFolder();
@@ -196,6 +202,9 @@
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/provider/temp/test/TemporaryFileProiderTestCase.java
Index: TemporaryFileProiderTestCase.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 [EMAIL PROTECTED]
*
* 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 org.apache.commons.vfs.test.AbstractWritableFileSystemTestCase;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.provider.temp.TemporaryFileProvider;
import java.io.File;
/**
* Test cases for the tmp: file provider.
*
* @author <a href="mailto:adammurdoch@;apache.org">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/10/25 11:11:51 $
*/
public class TemporaryFileProiderTestCase
extends AbstractWritableFileSystemTestCase
{
public TemporaryFileProiderTestCase( String name )
{
super( name );
}
/**
* Returns the base folder to run the tests against.
*/
protected FileObject getBaseFolder() throws Exception
{
final File baseDir = getTestDirectory();
getManager().addProvider( "tmp-read", new TemporaryFileProvider( baseDir ) );
return getManager().resolveFile( "tmp-read:/basedir" );
}
/**
* Returns the URI for the area to do tests in.
*/
protected FileObject getWriteFolder() throws Exception
{
getManager().addProvider( "tmp", new TemporaryFileProvider() );
return getManager().resolveFile( "tmp:/write-tests" );
}
}
1.6 +1 -1
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LocalFileSystemTestCase.java 23 Oct 2002 11:59:39 -0000 1.5
+++ LocalFileSystemTestCase.java 25 Oct 2002 11:11:51 -0000 1.6
@@ -77,7 +77,7 @@
*/
protected FileObject getBaseFolder() throws Exception
{
- final File testDir = getTestResource( "basedir" );
+ final File testDir = getTestDirectory( "basedir" );
final File emptyDir = new File( testDir, "emptydir" );
emptyDir.mkdirs();
return getManager().toFileObject( testDir );
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>