edtFTPj

com.enterprisedt.net.ftp.test
Class FTPTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.enterprisedt.net.ftp.test.FTPTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
TestAutoModeTransfer, TestBigTransfer, TestBulkTransfer, TestDirOperations, TestExists, TestFeatures, TestFileOperations, TestGeneral, TestListings, TestMLST, TestPortRange, TestResume, TestTimeout, TestTransfer, VMSTests

public abstract class FTPTestCase
extends junit.framework.TestCase

Generic JUnit test class for FTP, that provides some useful methods for subclasses that implement the actual test cases

Version:
$Revision: 1.22 $
Author:
Bruce Blackshaw

Field Summary
protected  int bulkCount
          Number of operations for stress testing
static String cvsId
          Revision control id
protected  FTPClientInterface ftp
          Reference to the FTP client
protected  int highPort
          Highest port
protected  String localBigFile
          Big local file for testing
protected  String localBigTextFile
          Big local text file for testing
protected  String localBinaryFile
          Local binary file
protected  String localDataDir
          Local data directory
protected  String localEmptyFile
          Local empty file
protected  String localTestDir
          Local test dir
protected  String localTextFile
          Local text file
protected  String localUnixTextFile
          Local text file
protected  Logger log
          Log stream
protected  String logDir
          Log directory
protected  int lowPort
          Lowest port
protected  Properties props
          Loaded properties
protected  String remoteBinaryFile
          Remote binary file
protected  String remoteEmptyDir
          Remote empty dir
protected  String remoteEmptyFile
          Remote empty file
protected  String remoteTextFile
          Remote text file
protected  String testdir
          Remote directory that remote test files/dirs are in
protected  TestTools tools
          Server specific tools
 
Constructor Summary
FTPTestCase()
          Initialize test properties
 
Method Summary
protected  void assertIdentical(byte[] buf1, byte[] buf2)
          Test to see if two buffers are identical, byte for byte
protected  void assertIdentical(File file1, File file2)
          Test to see if two files are identical, byte for byte
protected  void assertIdentical(String file1, String file2)
          Test to see if two files are identical, byte for byte
protected  void bulkTransfer(String localFile)
          Transfer back and forth multiple times
protected  void connect()
          Connect to the server and setup log stream
protected  String generateRandomFilename()
          Generate a random file name for testing
protected abstract  String getLogName()
          Get name of log file
protected  void print(File[] list)
          Helper method for dumping a listing
protected  void print(FTPFile[] list)
          Helper method for dumping a listing
protected  void print(String[] list)
          Helper method for dumping a listing
protected  void setUp()
          Setup is called before running each test
protected  void tearDown()
          Deallocate resources at close of each test
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cvsId

public static String cvsId
Revision control id


log

protected Logger log
Log stream


ftp

protected FTPClientInterface ftp
Reference to the FTP client


lowPort

protected int lowPort
Lowest port


highPort

protected int highPort
Highest port


testdir

protected String testdir
Remote directory that remote test files/dirs are in


remoteTextFile

protected String remoteTextFile
Remote text file


localTextFile

protected String localTextFile
Local text file


localUnixTextFile

protected String localUnixTextFile
Local text file


remoteBinaryFile

protected String remoteBinaryFile
Remote binary file


localBinaryFile

protected String localBinaryFile
Local binary file


localEmptyFile

protected String localEmptyFile
Local empty file


remoteEmptyFile

protected String remoteEmptyFile
Remote empty file


remoteEmptyDir

protected String remoteEmptyDir
Remote empty dir


localBigFile

protected String localBigFile
Big local file for testing


localBigTextFile

protected String localBigTextFile
Big local text file for testing


localTestDir

protected String localTestDir
Local test dir


logDir

protected String logDir
Log directory


localDataDir

protected String localDataDir
Local data directory


bulkCount

protected int bulkCount
Number of operations for stress testing


props

protected Properties props
Loaded properties


tools

protected TestTools tools
Server specific tools

Constructor Detail

FTPTestCase

public FTPTestCase()
Initialize test properties

Method Detail

setUp

protected void setUp()
              throws Exception
Setup is called before running each test

Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Deallocate resources at close of each test

Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

connect

protected void connect()
                throws Exception
Connect to the server and setup log stream

Throws:
Exception

generateRandomFilename

protected String generateRandomFilename()
Generate a random file name for testing

Returns:
random filename

assertIdentical

protected void assertIdentical(byte[] buf1,
                               byte[] buf2)
                        throws Exception
Test to see if two buffers are identical, byte for byte

Parameters:
buf1 - first buffer
buf2 - second buffer
Throws:
Exception

assertIdentical

protected void assertIdentical(String file1,
                               String file2)
                        throws Exception
Test to see if two files are identical, byte for byte

Parameters:
file1 - name of first file
file2 - name of second file
Throws:
Exception

assertIdentical

protected void assertIdentical(File file1,
                               File file2)
                        throws Exception
Test to see if two files are identical, byte for byte

Parameters:
file1 - first file object
file2 - second file object
Throws:
Exception

bulkTransfer

protected void bulkTransfer(String localFile)
                     throws Exception
Transfer back and forth multiple times

Throws:
Exception

print

protected void print(String[] list)
Helper method for dumping a listing

Parameters:
list - directory listing to print

print

protected void print(File[] list)
Helper method for dumping a listing

Parameters:
list - directory listing to print

print

protected void print(FTPFile[] list)
Helper method for dumping a listing

Parameters:
list - directory listing to print

getLogName

protected abstract String getLogName()
Get name of log file

Returns:
name of file to log to

edtFTPj

Copyright © 2000-2007 Enterprise Distributed Technologies. All Rights Reserved.