#include <FileTestContext.h>

This class and its subclasses abstract the locations of files that would normally be hardcoded so that tests can use locations in the build tree and provide different input sets for each test.
A typical test that reads and writes files can declare a FileTestContext so that the input files are copied from the source tree to the build tree, possibly modified along the way by a TemplateConverter supplied by the test or some subclass of FileTestContext. Typically the paths to the source and build tree will be provided from the build environment.
Public Member Functions | |
| FileTestContext (const char *testInputDir, const char *testWorkingDir) | |
| Define a context for a test or set of tests. | |
| virtual void | inputFile (const char *filename) |
| Get a file from the testInputDir, copy into testWorkingDir. | |
| typedef void | TemplateConverter (OsFile *templateFile, OsFile *workingFile) |
| Helper function provided by a test for converting a template to a working file. | |
| virtual void | workingFileFromTemplate (const char *templateName, TemplateConverter *converter, const char *filename=NULL) |
| The template in the testInputDir and the filename in testWorkingDir are opened, and then both files are passed to the converter. | |
| virtual void | removeWorkingFile (const char *filename) |
| Delete any existing copy of the file in the testWorkingDir. | |
| void | inputFilePath (const char *filename, UtlString &path) |
| Convert a file name to a full path name in the input directory. | |
| void | workingFilePath (const char *filename, UtlString &path) |
| Convert a file name to a full path name in the working directory. | |
| void | setSipxDir (DirectoryType dirType, const char *subDir=NULL) |
| Set the environment so that the SipXecsService paths are resolved to the context. | |
| virtual | ~FileTestContext () |
| Destructor. | |
Protected Member Functions | |
| virtual void | makeCleanWorkingDir () |
Protected Attributes | |
| UtlString | mTestInputDir |
| UtlString | mTestWorkingDir |
Private Member Functions | |
| FileTestContext (const FileTestContext &) | |
| There is no copy constructor. | |
| FileTestContext & | operator= (const FileTestContext &) |
| There is no assignment operator. | |
| FileTestContext | ( | const char * | testInputDir, | |
| const char * | testWorkingDir | |||
| ) |
Define a context for a test or set of tests.
Deletes all files and directories in the testWorkingDir.
The directories are:
| testInputDir | directory for test input & template files |
| testWorkingDir | directory for test working files. |
| virtual ~FileTestContext | ( | ) | [virtual] |
Destructor.
| FileTestContext | ( | const FileTestContext & | ) | [private] |
There is no copy constructor.
| virtual void inputFile | ( | const char * | filename | ) | [virtual] |
Get a file from the testInputDir, copy into testWorkingDir.
Reimplemented in RegistrationDbTestContext.
| typedef void TemplateConverter | ( | OsFile * | templateFile, | |
| OsFile * | workingFile | |||
| ) |
Helper function provided by a test for converting a template to a working file.
This is provided by a test and called by workingFileFromTemplate. When called, the templateFile is already opened for reading, and the workingFile is already opened for writing.
| templateFile | input |
| workingFile | output |
| virtual void workingFileFromTemplate | ( | const char * | templateName, | |
| TemplateConverter * | converter, | |||
| const char * | filename = NULL | |||
| ) | [virtual] |
The template in the testInputDir and the filename in testWorkingDir are opened, and then both files are passed to the converter.
The converter is responsible for reading the template and writing the filename.
If no filename is supplied, its name is the same as the templateName.
| templateName | testInputDir file |
| converter | conversion function |
| filename | testWorkingDir file |
| virtual void removeWorkingFile | ( | const char * | filename | ) | [virtual] |
Delete any existing copy of the file in the testWorkingDir.
| void inputFilePath | ( | const char * | filename, | |
| UtlString & | path | |||
| ) |
Convert a file name to a full path name in the input directory.
| void workingFilePath | ( | const char * | filename, | |
| UtlString & | path | |||
| ) |
Convert a file name to a full path name in the working directory.
| void setSipxDir | ( | DirectoryType | dirType, | |
| const char * | subDir = NULL | |||
| ) |
Set the environment so that the SipXecsService paths are resolved to the context.
| subDir | a subdirectory of the working directory. |
| virtual void makeCleanWorkingDir | ( | ) | [protected, virtual] |
| FileTestContext& operator= | ( | const FileTestContext & | ) | [private] |
There is no assignment operator.
UtlString mTestInputDir [protected] |
UtlString mTestWorkingDir [protected] |