Client Testing
[Native API]

Collaboration diagram for Client Testing:


Classes

class  TestFileSource
 This code uses the ClientTest and RawFileSyncSource to test real synchronization against a server. More...
class  RegisterTest
 the only purpose of this class is to own the first TestFileSource and to register its tests at program startup More...
class  ClientTestFactory
 generates tests on demand based on what the client supports More...

Functions

void simplifyFilename (string &filename)
const string & getCurrentTest ()
static void printTests (CppUnit::Test *test, int indention)
int main (int argc, char *argv[])
static int countAnyItems (SyncSource *source, SyncItem *(SyncSource::*first)(), SyncItem *(SyncSource::*next)())
 utility function to iterate over different kinds of items in a sync source
static int countNewItems (SyncSource *source)
static int countUpdatedItems (SyncSource *source)
static int countDeletedItems (SyncSource *source)
static int countItems (SyncSource *source)
int countItemsOfType (SyncSource *source, itemType type)
 utility function which counts items of a certain kind known to the sync source
static void importItem (SyncSource *source, std::string &data)
virtual void LocalTests::addTests ()
 adds the supported tests to the instance itself; this is the function that a derived class can override to add additional tests
virtual void LocalTests::insert (CreateSource createSource, const char *data)
 opens source and inserts the given item; can be called regardless whether the data source already contains items or not
virtual void LocalTests::update (CreateSource createSource, const char *data, bool check=true)
 assumes that exactly one element is currently inserted and updates it with the given item
virtual void LocalTests::deleteAll (CreateSource createSource)
 deletes all items locally via sync source
virtual void LocalTests::compareDatabases (const char *refFile, SyncSource &copy, bool raiseAssert=true)
 takes two databases, exports them, then compares them using synccompare
virtual int LocalTests::insertManyItems (CreateSource createSource, int startIndex=1, int numItems=0, int size=-1)
 insert artificial items, number of them determined by TEST_EVOLUTION_NUM_ITEMS unless passed explicitly
virtual void LocalTests::testOpen ()
virtual void LocalTests::testIterateTwice ()
virtual void LocalTests::testSimpleInsert ()
virtual void LocalTests::testLocalDeleteAll ()
virtual void LocalTests::testComplexInsert ()
virtual void LocalTests::testLocalUpdate ()
virtual void LocalTests::testChanges ()
virtual void LocalTests::testImport ()
virtual void LocalTests::testImportDelete ()
virtual void LocalTests::testManyChanges ()
 SyncTests::SyncTests (const std::string &name, ClientTest &cl, std::vector< int > sourceIndices, bool isClientA=true)
virtual void SyncTests::addTests ()
 adds the supported tests to the instance itself
virtual void SyncTests::compareDatabases ()
 compare databases of first and second client
virtual void SyncTests::deleteAll (DeleteAllMode mode=DELETE_ALL_SYNC)
 deletes all items locally and on server
virtual void SyncTests::doCopy ()
 get both clients in sync with empty server, then copy one item from client A to B
virtual void SyncTests::refreshClient ()
 replicate server database locally: same as SYNC_REFRESH_FROM_SERVER, but done with explicit local delete and then a SYNC_SLOW because some servers do no support SYNC_REFRESH_FROM_SERVER
virtual void SyncTests::testDeleteAllRefresh ()
virtual void SyncTests::testRefreshSemantic ()
virtual void SyncTests::testRefreshStatus ()
virtual void SyncTests::testUpdate ()
virtual void SyncTests::testComplexUpdate ()
virtual void SyncTests::testDelete ()
virtual void SyncTests::testMerge ()
virtual void SyncTests::testTwinning ()
virtual void SyncTests::testOneWayFromServer ()
virtual void SyncTests::testOneWayFromClient ()
virtual void SyncTests::testItems ()
virtual void SyncTests::testAddUpdate ()
virtual void SyncTests::testManyItems ()
virtual void SyncTests::doVarSizes (bool withMaxMsgSize, bool withLargeObject, const char *encoding)
 implements testMaxMsg(), testLargeObject(), testLargeObjectEncoded() using a sequence of items with varying sizes
virtual void SyncTests::sync (SyncMode syncMode, const std::string &logprefix="", CheckSyncReport checkReport=CheckSyncReport(), long maxMsgSize=0, long maxObjSize=0, bool loSupport=false, const char *encoding="")
 executes a sync with the given options, checks the result and (optionally) the sync report
virtual void ClientTest::registerTests ()
 This function registers tests using this instance of ClientTest for later use during a test run.
 ClientTest::ClientTest (int serverSleepSec=0, const std::string &serverLog="")
virtual LocalTestsClientTest::createLocalTests (const std::string &name, int sourceParam, ClientTest::Config &co)
 Creates an instance of LocalTests (default implementation) or a class derived from it.
virtual SyncTestsClientTest::createSyncTests (const std::string &name, std::vector< int > sourceIndices, bool isClientA=true)
 Creates an instance of SyncTests (default) or a class derived from it.
static int ClientTest::dump (ClientTest &client, SyncSource &source, const char *file)
 utility function for dumping items which are C strings with blank lines as separator
static int ClientTest::import (ClientTest &client, SyncSource &source, const char *file)
 utility function for importing items with blank lines as separator
static bool ClientTest::compare (ClientTest &client, const char *fileA, const char *fileB)
 utility function for comparing vCard and iCal files with the external synccompare.pl Perl script
virtual void ClientTest::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 void ClientTest::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.
virtual void CheckSyncReport::check (int res, SyncReport &report) const
 checks that the sync completed as expected and throws CPPUnit exceptions if something is wrong

Variables

ClientListener syncListener
static class RegisterTest registerTest
 the only purpose of this class is to own the first TestFileSource and to register its tests at program startup

Function Documentation

void CheckSyncReport::check ( int  res,
SyncReport report 
) const [virtual, inherited]

checks that the sync completed as expected and throws CPPUnit exceptions if something is wrong

Parameters:
res return code from SyncClient::sync()
report the sync report stored in the SyncClient

void LocalTests::compareDatabases ( const char *  refFile,
SyncSource copy,
bool  raiseAssert = true 
) [virtual, inherited]

takes two databases, exports them, then compares them using synccompare

Parameters:
refFile existing file with source reference items, NULL uses a dump of sync source A instead
copy a sync source which contains the copied items, begin/endSync will be called
raiseAssert raise assertion if comparison yields differences (defaults to true)

int countItemsOfType ( SyncSource source,
itemType  type 
)

utility function which counts items of a certain kind known to the sync source

Parameters:
source valid source ready to iterate; NULL triggers an assert
itemType determines which iterator functions are used
Returns:
number of valid items iterated over

LocalTests * ClientTest::createLocalTests ( const std::string &  name,
int  sourceParam,
ClientTest::Config co 
) [virtual, inherited]

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.

SyncTests * ClientTest::createSyncTests ( const std::string &  name,
std::vector< int >  sourceIndices,
bool  isClientA = true 
) [virtual, inherited]

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.

void ClientTest::getTestData ( const char *  type,
Config config 
) [static, inherited]

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:

void LocalTests::insert ( CreateSource  createSource,
const char *  data 
) [virtual, inherited]

opens source and inserts the given item; can be called regardless whether the data source already contains items or not

The type of the item is unset; it is assumed that the source can handle that.

int LocalTests::insertManyItems ( CreateSource  createSource,
int  startIndex = 1,
int  numItems = 0,
int  size = -1 
) [virtual, inherited]

insert artificial items, number of them determined by TEST_EVOLUTION_NUM_ITEMS unless passed explicitly

Parameters:
createSource a factory for the sync source that is to be used
startIndex IDs are generated starting with this value
numItems number of items to be inserted if non-null, otherwise TEST_EVOLUTION_NUM_ITEMS is used
size minimum size for new items
Returns:
number of items inserted

void ClientTest::postSync ( int  res,
const std::string &  logname 
) [virtual, inherited]

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.

Parameters:
res result of sync()
logname base name of the current sync log (without ".client.[AB].log" suffix)

void ClientTest::registerTests (  )  [virtual, inherited]

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.

void LocalTests::update ( CreateSource  createSource,
const char *  data,
bool  check = true 
) [virtual, inherited]

assumes that exactly one element is currently inserted and updates it with the given item

The type of the item is cleared, as in insert() above.

Parameters:
check if true, then reopen the source and verify that the reported items are as expected


Generated on Mon Feb 4 09:50:53 2008 for Funambol Outlook Plug-in Library by  doxygen 1.5.2