com.enterprisedt.net.ftp.test
Class FTPTestCase

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended bycom.enterprisedt.net.ftp.test.FTPTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
TestDirOperations, TestFileOperations, TestGeneral, TestListings, TestLogin, TestMode, TestTimeout, TestTransfer

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.5 $
Author:
Bruce Blackshaw

Field Summary
protected  FTPConnectMode connectMode
          Connect mode for test
protected  FTPClient ftp
          Reference to the FTP client
protected  java.lang.String host
          Remote test host
protected  java.lang.String localBinaryFile
          Local binary file
protected  java.lang.String localEmptyFile
          Local empty file
protected  java.lang.String localTextFile
          Local text file
protected  java.io.PrintWriter log
          Log stream
protected  java.lang.String password
          User password
protected  java.util.Properties props
          Loaded properties
protected  java.lang.String remoteBinaryFile
          Remote binary file
protected  java.lang.String remoteEmptyDir
          Remote empty dir
protected  java.lang.String remoteEmptyFile
          Remote empty file
protected  java.lang.String remoteTextFile
          Remote text file
protected  java.lang.String testdir
          Remote directory that remote test files/dirs are in
protected  int timeout
          Socket timeout
protected  java.lang.String user
          Test user
 
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(java.io.File file1, java.io.File file2)
          Test to see if two files are identical, byte for byte
protected  void assertIdentical(java.lang.String file1, java.lang.String file2)
          Test to see if two files are identical, byte for byte
protected  void connect()
          Connect to the server and setup log stream
protected  void connect(int timeout)
          Connect to the server and setup log stream
protected  java.lang.String generateRandomFilename()
          Generate a random file name for testing
protected abstract  java.lang.String getLogName()
          Get name of log file
protected  void login()
          Login to the server
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

log

protected java.io.PrintWriter log
Log stream


ftp

protected FTPClient ftp
Reference to the FTP client


host

protected java.lang.String host
Remote test host


user

protected java.lang.String user
Test user


password

protected java.lang.String password
User password


connectMode

protected FTPConnectMode connectMode
Connect mode for test


timeout

protected int timeout
Socket timeout


testdir

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


remoteTextFile

protected java.lang.String remoteTextFile
Remote text file


localTextFile

protected java.lang.String localTextFile
Local text file


remoteBinaryFile

protected java.lang.String remoteBinaryFile
Remote binary file


localBinaryFile

protected java.lang.String localBinaryFile
Local binary file


localEmptyFile

protected java.lang.String localEmptyFile
Local empty file


remoteEmptyFile

protected java.lang.String remoteEmptyFile
Remote empty file


remoteEmptyDir

protected java.lang.String remoteEmptyDir
Remote empty dir


props

protected java.util.Properties props
Loaded properties

Constructor Detail

FTPTestCase

public FTPTestCase()
Initialize test properties

Method Detail

setUp

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

Throws:
java.lang.Exception

tearDown

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

Throws:
java.lang.Exception

connect

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

Throws:
java.lang.Exception

connect

protected void connect(int timeout)
                throws java.lang.Exception
Connect to the server and setup log stream

Throws:
java.lang.Exception

login

protected void login()
              throws java.lang.Exception
Login to the server

Throws:
java.lang.Exception

generateRandomFilename

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

Returns:
random filename

assertIdentical

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

Parameters:
buf1 - first buffer
buf2 - second buffer
Throws:
java.lang.Exception

assertIdentical

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

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

assertIdentical

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

Parameters:
file1 - first file object
file2 - second file object
Throws:
java.lang.Exception

getLogName

protected abstract java.lang.String getLogName()
Get name of log file

Returns:
name of file to log to


Copyright (c) 2001-2004 Enterprise Distributed Technologies Ltd. All Rights Reserved.