#include <ClientTest.h>
Inheritance diagram for ClientTest:
Public Member Functions | |
ClientTest (int serverSleepSec=0, const std::string &serverLog="") | |
virtual void | registerTests () |
This is the only function provided by ClientTest itself: it registers tests using this instance of ClientTest for later use during a test run. | |
virtual int | getNumSources ()=0 |
Data sources are enumbered from 0 to n-1 for the purpose of testing. | |
virtual void | getSourceConfig (int source, Config &config)=0 |
Called to fill the given test source config with information about a sync source identified by its index. | |
virtual ClientTest * | getClientB ()=0 |
The instance to use as second client. | |
virtual bool | isB64Enabled ()=0 |
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. | |
virtual int | sync (const int *activeSources, SyncMode syncMode, const CheckSyncReport &checkReport, long maxMsgSize=0, long maxObjSize=0, bool loSupport=false, const char *encoding="")=0 |
Execute a synchronization with the selected sync sources and the selected synchronization options. | |
virtual void | postSync (int res, const std::string &logname) |
This is called after successful sync() calls (res == 0) as well as after unsuccessful ones (res != 1). | |
Static Public Member Functions | |
static int | dump (ClientTest &client, SyncSource &source, const char *file) |
utility function for dumping items which are C strings with blank lines as separator | |
static int | import (ClientTest &client, SyncSource &source, const char *file) |
utility function for importing items with blank lines as separator | |
static bool | compare (ClientTest &client, const char *fileA, const char *fileB) |
utility function for comparing vCard and iCal files with the external synccompare.pl Perl script | |
static void | getTestData (const char *type, Config &config) |
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. | |
Protected Attributes | |
int | serverSleepSeconds |
time to sleep in postSync() | |
std::string | serverLogFileName |
server log file which is copied by postSync() and then truncated (Unix only, Windows does not allow such access to an open file) | |
Classes | |
struct | Config |
Information about a data source. More... |
It defines several methods that a derived class must implement if it wants to use that framework. Note that this class itself is not derived from SyncClient. This gives a user of this framework the freedom to implement it in two different ways:
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.
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 TestFileSource.
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.
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 TestFileSource.
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 TestFileSource.