#include <ClientTest.h>
Classes | |
struct | Config |
Public Member Functions | |
ClientTest (int serverSleepSec=0, const std::string &serverLog="") | |
virtual | ~ClientTest () |
virtual void | registerTests () |
virtual LocalTests * | createLocalTests (const std::string &name, int sourceParam, ClientTest::Config &co) |
virtual SyncTests * | createSyncTests (const std::string &name, std::vector< int > sourceIndices, bool isClientA=true) |
virtual int | getNumSources ()=0 |
virtual void | getSourceConfig (int source, Config &config)=0 |
virtual ClientTest * | getClientB ()=0 |
virtual bool | isB64Enabled ()=0 |
virtual int | sync (const int *activeSources, SyncMode syncMode, const CheckSyncReport &checkReport, long maxMsgSize=0, long maxObjSize=0, bool loSupport=false, const char *encoding="")=0 |
virtual void | postSync (int res, const std::string &logname) |
ClientTest (int serverSleepSec=0, const std::string &serverLog="") | |
virtual | ~ClientTest () |
virtual void | registerTests () |
virtual LocalTests * | createLocalTests (const std::string &name, int sourceParam, ClientTest::Config &co) |
virtual SyncTests * | createSyncTests (const std::string &name, std::vector< int > sourceIndices, bool isClientA=true) |
virtual int | getNumSources ()=0 |
virtual void | getSourceConfig (int source, Config &config)=0 |
virtual ClientTest * | getClientB ()=0 |
virtual bool | isB64Enabled ()=0 |
virtual int | sync (const int *activeSources, SyncMode syncMode, const CheckSyncReport &checkReport, long maxMsgSize=0, long maxObjSize=0, bool loSupport=false, const char *encoding="")=0 |
virtual void | postSync (int res, const std::string &logname) |
Static Public Member Functions | |
static int | dump (ClientTest &client, SyncSource &source, const char *file) |
static int | import (ClientTest &client, SyncSource &source, const char *file) |
static bool | compare (ClientTest &client, const char *fileA, const char *fileB) |
static void | getTestData (const char *type, Config &config) |
static int | dump (ClientTest &client, SyncSource &source, const char *file) |
static int | import (ClientTest &client, SyncSource &source, const char *file) |
static bool | compare (ClientTest &client, const char *fileA, const char *fileB) |
static void | getTestData (const char *type, Config &config) |
Protected Attributes | |
int | serverSleepSeconds |
std::string | serverLogFileName |
The client is expected to support change tracking for multiple servers. Although the framework always always tests against the same server, for most tests it is necessary to access the database without affecting the next synchronization with the server. This is done by asking the client for two different sync sources via Config::createSourceA and Config::createSourceB which have to create them in a suitable way - pretty much as if the client was synchronized against different server. A third, different change tracking is needed for real synchronizations of the data.
Furthermore the client is expected to support multiple data sources of the same kind, f.i. two different address books. This is used to test full client A <-> server <-> client B synchronizations in some tests or to check server modifications done by client A with a synchronization against client B. In those tests client A is mapped to the first data source and client B to the second one.
Finally the SyncSource API is used in slightly different ways which go beyond what is normally expected from a SyncSource implementation:
Handling configuration and creating classes is entirely done by the subclass of ClientTest, the frameworks makes no assumptions about how this is done. Instead it queries the ClientTest for properties (like available sync sources) and then creates several tests.
Definition at line 139 of file ClientTest.h.
ClientTest::ClientTest | ( | int | serverSleepSec = 0 , |
|
const std::string & | serverLog = "" | |||
) |
virtual ClientTest::~ClientTest | ( | ) | [virtual] |
static bool ClientTest::compare | ( | ClientTest & | client, | |
const char * | fileA, | |||
const char * | fileB | |||
) | [static] |
utility function for comparing vCard and iCal files with the external synccompare.pl Perl script
Reimplemented in TestEvolution.
virtual LocalTests* ClientTest::createLocalTests | ( | const std::string & | name, | |
int | sourceParam, | |||
ClientTest::Config & | co | |||
) | [virtual] |
Creates an instance of LocalTests (default implementation) or a class derived from it. LocalTests provides tests which cover the SyncSource interface and can be executed without a SyncML server. It also contains utility functions for working with SyncSources.
A ClientTest implementation can, but doesn't have to extend these tests by instantiating a derived class here.
Reimplemented in TestEvolution.
virtual SyncTests* ClientTest::createSyncTests | ( | const std::string & | name, | |
std::vector< int > | sourceIndices, | |||
bool | isClientA = true | |||
) | [virtual] |
Creates an instance of SyncTests (default) or a class derived from it. SyncTests provides tests which cover the actual interaction with a SyncML server.
A ClientTest implementation can, but doesn't have to extend these tests by instantiating a derived class here.
static int ClientTest::dump | ( | ClientTest & | client, | |
SyncSource & | source, | |||
const char * | file | |||
) | [static] |
utility function for dumping items which are C strings with blank lines as separator
virtual ClientTest* ClientTest::getClientB | ( | ) | [pure virtual] |
The instance to use as second client. Returning NULL disables all checks which require a second client. The returned pointer must remain valid throughout the life time of the tests.
The second client must be configured to access the same server and have data sources which match the ones from the primary client.
Implemented in TestEvolution.
virtual ClientTest* ClientTest::getClientB | ( | ) | [pure virtual] |
The instance to use as second client. Returning NULL disables all checks which require a second client. The returned pointer must remain valid throughout the life time of the tests.
The second client must be configured to access the same server and have data sources which match the ones from the primary client.
Implemented in TestEvolution.
Referenced by SyncTests::SyncTests().
virtual int ClientTest::getNumSources | ( | ) | [pure virtual] |
Data sources are enumbered from 0 to n-1 for the purpose of testing. This call returns n.
Implemented in TestEvolution.
virtual int ClientTest::getNumSources | ( | ) | [pure virtual] |
Data sources are enumbered from 0 to n-1 for the purpose of testing. This call returns n.
Implemented in TestEvolution.
Referenced by ClientTestFactory::makeTest().
virtual void ClientTest::getSourceConfig | ( | int | source, | |
Config & | config | |||
) | [pure virtual] |
Called to fill the given test source config with information about a sync source identified by its index. It's okay to only fill in the available pieces of information and set everything else to zero.
Implemented in TestEvolution.
virtual void ClientTest::getSourceConfig | ( | int | source, | |
Config & | config | |||
) | [pure virtual] |
Called to fill the given test source config with information about a sync source identified by its index. It's okay to only fill in the available pieces of information and set everything else to zero.
Implemented in TestEvolution.
Referenced by ClientTestFactory::makeTest(), and SyncTests::SyncTests().
static void ClientTest::getTestData | ( | const char * | type, | |
Config & | config | |||
) | [static] |
A derived class can use this call to get default test cases, but still has to add callbacks which create sources and execute a sync session.
Some of the test cases are compiled into the library, other depend on the auxiliary files from the "test" directory. Currently supported types:
static int ClientTest::import | ( | ClientTest & | client, | |
SyncSource & | source, | |||
const char * | file | |||
) | [static] |
utility function for importing items with blank lines as separator
virtual bool ClientTest::isB64Enabled | ( | ) | [pure virtual] |
Returning true enables tests which only work if the server is a Funambol server which supports the "b64" encoding of items on the transport level.
Implemented in TestEvolution.
virtual bool ClientTest::isB64Enabled | ( | ) | [pure virtual] |
Returning true enables tests which only work if the server is a Funambol server which supports the "b64" encoding of items on the transport level.
Implemented in TestEvolution.
Referenced by SyncTests::addTests().
virtual void ClientTest::postSync | ( | int | res, | |
const std::string & | logname | |||
) | [virtual] |
This is called after successful sync() calls (res == 0) as well as after unsuccessful ones (res != 1). The default implementation sleeps for the number of seconds specified when constructing this instance and copies the server log if one was named.
res | result of sync() | |
logname | base name of the current sync log (without ".client.[AB].log" suffix) |
virtual void ClientTest::registerTests | ( | ) | [virtual] |
This function registers tests using this instance of ClientTest for later use during a test run.
The instance must remain valid until after the tests were run. To run them use a separate test runner, like the one from client-test-main.cpp.
virtual int ClientTest::sync | ( | const int * | activeSources, | |
SyncMode | syncMode, | |||
const CheckSyncReport & | checkReport, | |||
long | maxMsgSize = 0 , |
|||
long | maxObjSize = 0 , |
|||
bool | loSupport = false , |
|||
const char * | encoding = "" | |||
) | [pure virtual] |
Execute a synchronization with the selected sync sources and the selected synchronization options. The log file in LOG has been set up already for the synchronization run and should not be changed by the client.
activeSources | a -1 terminated array of sync source indices | |
syncMode | the synchronization mode to be used | |
checkReport | has to be called after a successful or unsuccessful sync, will dump the report and (optionally) check the result; beware, the later may throw exceptions inside CPPUNIT macros | |
maxMsgSize | >0: enable the maximum message size, else disable it | |
maxObjSize | same as maxMsgSize for maximum object size | |
loSupport | if true, then the sync is expected to enable Large Object support | |
encoding | if non-empty, then let client library transform all items into this format (guaranteed to be not NULL) |
Implemented in TestEvolution.
virtual int ClientTest::sync | ( | const int * | activeSources, | |
SyncMode | syncMode, | |||
const CheckSyncReport & | checkReport, | |||
long | maxMsgSize = 0 , |
|||
long | maxObjSize = 0 , |
|||
bool | loSupport = false , |
|||
const char * | encoding = "" | |||
) | [pure virtual] |
Execute a synchronization with the selected sync sources and the selected synchronization options. The log file in LOG has been set up already for the synchronization run and should not be changed by the client.
activeSources | a -1 terminated array of sync source indices | |
syncMode | the synchronization mode to be used | |
checkReport | has to be called after a successful or unsuccessful sync, will dump the report and (optionally) check the result; beware, the later may throw exceptions inside CPPUNIT macros | |
maxMsgSize | >0: enable the maximum message size, else disable it | |
maxObjSize | same as maxMsgSize for maximum object size | |
loSupport | if true, then the sync is expected to enable Large Object support | |
encoding | if non-empty, then let client library transform all items into this format (guaranteed to be not NULL) |
Implemented in TestEvolution.
Referenced by SyncTests::sync().
std::string ClientTest::serverLogFileName [protected] |
server log file which is copied by postSync() and then truncated (Unix only, Windows does not allow such access to an open file)
Definition at line 511 of file ClientTest.h.
Referenced by postSync().
int ClientTest::serverSleepSeconds [protected] |