diff options
-rw-r--r-- | HACKING | 5 | ||||
-rw-r--r-- | src/client-test-app.cpp | 1 | ||||
-rw-r--r-- | src/core/EvolutionSyncClient.cpp | 5 | ||||
-rw-r--r-- | src/core/SyncEvolutionCmdline.cpp | 18 | ||||
-rw-r--r-- | src/core/SyncEvolutionConfig.cpp | 30 | ||||
-rw-r--r-- | src/core/SyncEvolutionConfig.h | 30 | ||||
-rw-r--r-- | test/ClientTest.cpp | 56 | ||||
-rw-r--r-- | test/ClientTest.h | 38 |
8 files changed, 80 insertions, 103 deletions
@@ -61,12 +61,17 @@ libraries "client-test", among them: before aborting it - CLIENT_TEST_SOURCES = comma separated list of enabled sources, identified by their name (ical20, vcard21, vcard30, itodo20, text (= memos)) +- CLIENT_TEST_XML=1 use XML format as default instead of the normal WBXML In addition it supports: - CLIENT_TEST_EVOLUTION_PREFIX=[name|file://<path>] overrides the evolutionsource setting in the configuration; if file:// is used then these database will be created automatically +Most Client::Sync tests use the default encoding, usually WBXML unless +changed via CLIENT_TEST_XML=1. Client::Sync::*::testItemsXML always +uses XML and Client::Sync::*::testItems always WBXML. + Here are step-by-step instructions to get started with testing, using ScheduleWorld as example: - CLIENT_TEST_SERVER=scheduleworld \ diff --git a/src/client-test-app.cpp b/src/client-test-app.cpp index 32111e97..0457f293 100644 --- a/src/client-test-app.cpp +++ b/src/client-test-app.cpp @@ -333,6 +333,7 @@ public: setLoSupport(m_options.m_loSupport, true); setMaxObjSize(m_options.m_maxObjSize, true); setMaxMsgSize(m_options.m_maxMsgSize, true); + setWBXML(m_options.m_isWBXML, true); EvolutionSyncClient::prepare(); } virtual void prepare(const std::vector<EvolutionSyncSource *> &sources) { diff --git a/src/core/EvolutionSyncClient.cpp b/src/core/EvolutionSyncClient.cpp index 80c6ebb9..af547e6f 100644 --- a/src/core/EvolutionSyncClient.cpp +++ b/src/core/EvolutionSyncClient.cpp @@ -1277,9 +1277,8 @@ SyncMLStatus EvolutionSyncClient::doSync() m_engine.SetStrValue(profile, "serverURI", getSyncURL()); m_engine.SetStrValue(profile, "serverUser", getUsername()); m_engine.SetStrValue(profile, "serverPassword", getPassword()); - - // TODO(?): make XML vs WBXML configurable - m_engine.SetInt32Value(profile, "encoding", 2); + m_engine.SetInt32Value(profile, "encoding", + getWBXML() ? 1 /* WBXML */ : 2 /* XML */); // Iterate over all data stores in the XML config // and match them with sync sources. diff --git a/src/core/SyncEvolutionCmdline.cpp b/src/core/SyncEvolutionCmdline.cpp index 54f8066d..79697313 100644 --- a/src/core/SyncEvolutionCmdline.cpp +++ b/src/core/SyncEvolutionCmdline.cpp @@ -858,10 +858,7 @@ class SyncEvolutionCmdlineTest : public CppUnit::TestFixture { public: SyncEvolutionCmdlineTest() : m_testDir("SyncEvolutionCmdlineTest"), - m_scheduleWorldConfig(".internal.ini:# serverNonce = \n" - ".internal.ini:# clientNonce = \n" - ".internal.ini:# devInfoHash = \n" - "config.ini:syncURL = http://sync.scheduleworld.com/funambol/ds\n" + m_scheduleWorldConfig("config.ini:syncURL = http://sync.scheduleworld.com/funambol/ds\n" "config.ini:username = your SyncML server account name\n" "config.ini:password = your SyncML server password\n" "config.ini:# logdir = \n" @@ -873,6 +870,7 @@ public: "config.ini:# proxyPassword = \n" "config.ini:# clientAuthType = syncml:auth-md5\n" "config.ini:deviceId = fixed-devid\n" /* this is not the default! */ + "config.ini:# enableWBXML = 1\n" "config.ini:# maxMsgSize = 8192\n" "config.ini:# maxObjSize = 500000\n" "config.ini:# loSupport = 1\n" @@ -887,7 +885,6 @@ public: "sources/addressbook/config.ini:uri = card3\n" "sources/addressbook/config.ini:# evolutionuser = \n" "sources/addressbook/config.ini:# evolutionpassword = \n" - "sources/addressbook/config.ini:# encoding = \n" "sources/calendar/.internal.ini:# last = 0\n" "sources/calendar/config.ini:sync = two-way\n" "sources/calendar/config.ini:type = calendar\n" @@ -895,7 +892,6 @@ public: "sources/calendar/config.ini:uri = cal2\n" "sources/calendar/config.ini:# evolutionuser = \n" "sources/calendar/config.ini:# evolutionpassword = \n" - "sources/calendar/config.ini:# encoding = \n" "sources/memo/.internal.ini:# last = 0\n" "sources/memo/config.ini:sync = two-way\n" "sources/memo/config.ini:type = memo\n" @@ -903,15 +899,13 @@ public: "sources/memo/config.ini:uri = note\n" "sources/memo/config.ini:# evolutionuser = \n" "sources/memo/config.ini:# evolutionpassword = \n" - "sources/memo/config.ini:# encoding = \n" "sources/todo/.internal.ini:# last = 0\n" "sources/todo/config.ini:sync = two-way\n" "sources/todo/config.ini:type = todo\n" "sources/todo/config.ini:# evolutionsource = \n" "sources/todo/config.ini:uri = task2\n" "sources/todo/config.ini:# evolutionuser = \n" - "sources/todo/config.ini:# evolutionpassword = \n" - "sources/todo/config.ini:# encoding = \n") + "sources/todo/config.ini:# evolutionpassword = \n") {} protected: @@ -1276,6 +1270,8 @@ protected: "\n" "deviceId:\n" "\n" + "enableWBXML:\n" + "\n" "maxMsgSize:\n" "maxObjSize:\n" "loSupport:\n" @@ -1296,9 +1292,7 @@ protected: "uri:\n" "\n" "evolutionuser:\n" - "evolutionpassword:\n" - "\n" - "encoding:\n"); + "evolutionpassword:\n"); { TestCmdline cmdline("--sync-property", "?", diff --git a/src/core/SyncEvolutionConfig.cpp b/src/core/SyncEvolutionConfig.cpp index f442c212..095810ae 100644 --- a/src/core/SyncEvolutionConfig.cpp +++ b/src/core/SyncEvolutionConfig.cpp @@ -292,10 +292,9 @@ static BoolConfigProperty syncPropLoSupport("loSupport", "", "T"); static UIntConfigProperty syncPropMaxObjSize("maxObjSize", "", "500000"); static BoolConfigProperty syncPropCompression("enableCompression", "enable compression of network traffic (not currently supported)"); -static ConfigProperty syncPropServerNonce("serverNonce", - "used by the SyncML library internally; do not modify"); -static ConfigProperty syncPropClientNonce("clientNonce", ""); -static ConfigProperty syncPropDevInfHash("devInfoHash", ""); +static BoolConfigProperty syncPropWBXML("enableWBXML", + "use the more compact binary XML (WBXML) for messages between client and server", + "TRUE"); static ConfigProperty syncPropLogDir("logdir", "full path to directory where automatic backups and logs\n" "are stored for all synchronizations; if empty, the temporary\n" @@ -355,6 +354,7 @@ ConfigPropertyRegistry &EvolutionSyncConfig::getRegistry() registry.push_back(&syncPropClientAuthType); registry.push_back(&syncPropDevID); syncPropDevID.setObligatory(true); + registry.push_back(&syncPropWBXML); registry.push_back(&syncPropMaxMsgSize); registry.push_back(&syncPropMaxObjSize); registry.push_back(&syncPropLoSupport); @@ -362,13 +362,6 @@ ConfigPropertyRegistry &EvolutionSyncConfig::getRegistry() registry.push_back(&syncPropSSLServerCertificates); registry.push_back(&syncPropSSLVerifyServer); registry.push_back(&syncPropSSLVerifyHost); - - registry.push_back(&syncPropServerNonce); - syncPropServerNonce.setHidden(true); - registry.push_back(&syncPropClientNonce); - syncPropClientNonce.setHidden(true); - registry.push_back(&syncPropDevInfHash); - syncPropDevInfHash.setHidden(true); initialized = true; } @@ -453,12 +446,8 @@ bool EvolutionSyncConfig::getCompression() const { return syncPropCompression.ge void EvolutionSyncConfig::setCompression(bool value, bool temporarily) { syncPropCompression.setProperty(*m_configNode, value, temporarily); } const char *EvolutionSyncConfig::getDevID() const { return m_stringCache.getProperty(*m_configNode, syncPropDevID); } void EvolutionSyncConfig::setDevID(const string &value, bool temporarily) { syncPropDevID.setProperty(*m_configNode, value, temporarily); } -const char *EvolutionSyncConfig::getServerNonce() const { return m_stringCache.getProperty(*m_hiddenNode, syncPropServerNonce); } -void EvolutionSyncConfig::setServerNonce(const char *value) { syncPropServerNonce.setProperty(*m_hiddenNode, value); } -const char *EvolutionSyncConfig::getClientNonce() const { return m_stringCache.getProperty(*m_hiddenNode, syncPropClientNonce); } -void EvolutionSyncConfig::setClientNonce(const char *value) { syncPropClientNonce.setProperty(*m_hiddenNode, value); } -const char *EvolutionSyncConfig::getDevInfHash() const { return m_stringCache.getProperty(*m_hiddenNode, syncPropDevInfHash); } -void EvolutionSyncConfig::setDevInfHash(const char *value) { syncPropDevInfHash.setProperty(*m_hiddenNode, value); } +bool EvolutionSyncConfig::getWBXML() const { return syncPropWBXML.getProperty(*m_configNode); } +void EvolutionSyncConfig::setWBXML(bool value, bool temporarily) { syncPropWBXML.setProperty(*m_configNode, value, temporarily); } const char *EvolutionSyncConfig::getLogDir() const { return m_stringCache.getProperty(*m_configNode, syncPropLogDir); } void EvolutionSyncConfig::setLogDir(const string &value, bool temporarily) { syncPropLogDir.setProperty(*m_configNode, value, temporarily); } int EvolutionSyncConfig::getMaxLogDirs() const { return syncPropMaxLogDirs.getProperty(*m_configNode); } @@ -695,10 +684,6 @@ static ConfigProperty sourcePropUser("evolutionuser", "can cause the Evolution backend to hang."); static PasswordConfigProperty sourcePropPassword("evolutionpassword", ""); -static StringConfigProperty sourcePropEncoding("encoding", - "\"b64\" enables base64 encoding of outgoing items (not recommended)", - "", - Values() + (Aliases("b64") + "bin") + Aliases("")); static ULongConfigProperty sourcePropLast("last", "used by the SyncML library internally; do not modify"); @@ -716,7 +701,6 @@ ConfigPropertyRegistry &EvolutionSyncSourceConfig::getRegistry() registry.push_back(&sourcePropURI); registry.push_back(&sourcePropUser); registry.push_back(&sourcePropPassword); - registry.push_back(&sourcePropEncoding); registry.push_back(&sourcePropLast); sourcePropLast.setHidden(true); initialized = true; @@ -741,8 +725,6 @@ const char *EvolutionSyncSourceConfig::getURI() const { return m_stringCache.get void EvolutionSyncSourceConfig::setURI(const string &value, bool temporarily) { sourcePropURI.setProperty(*m_nodes.m_configNode, value, temporarily); } const char *EvolutionSyncSourceConfig::getSync() const { return m_stringCache.getProperty(*m_nodes.m_configNode, m_sourcePropSync); } void EvolutionSyncSourceConfig::setSync(const string &value, bool temporarily) { m_sourcePropSync.setProperty(*m_nodes.m_configNode, value, temporarily); } -const char *EvolutionSyncSourceConfig::getEncoding() const { return m_stringCache.getProperty(*m_nodes.m_configNode, sourcePropEncoding); } -void EvolutionSyncSourceConfig::setEncoding(const string &value, bool temporarily) { sourcePropEncoding.setProperty(*m_nodes.m_configNode, value, temporarily); } unsigned long EvolutionSyncSourceConfig::getLast() const { return sourcePropLast.getProperty(*m_nodes.m_hiddenNode); } void EvolutionSyncSourceConfig::setLast(unsigned long timestamp) { sourcePropLast.setProperty(*m_nodes.m_hiddenNode, timestamp); } string EvolutionSyncSourceConfig::getSourceTypeString(const SyncSourceNodes &nodes) { return sourcePropSourceType.getProperty(*nodes.m_configNode); } diff --git a/src/core/SyncEvolutionConfig.h b/src/core/SyncEvolutionConfig.h index 83b22951..abc486c6 100644 --- a/src/core/SyncEvolutionConfig.h +++ b/src/core/SyncEvolutionConfig.h @@ -671,13 +671,14 @@ class EvolutionSyncConfig { virtual const char* getDevID() const; virtual void setDevID(const string &value, bool temporarily = false); - virtual bool getServerAuthRequired() const { return false; } - virtual const char* getServerAuthType() const { return ""; } - virtual const char* getServerPWD() const { return ""; } - virtual const char* getServerID() const { return ""; } + /** + * Specifies whether WBXML is to be used (default). + * Otherwise XML is used. + */ + virtual bool getWBXML() const; + virtual void setWBXML(bool isWBXML, bool temporarily = false); virtual const char* getUserAgent() const { return "SyncEvolution"; } - virtual const char* getVerDTD() const { return "1.1"; } virtual const char* getMan() const { return "Patrick Ohly"; } virtual const char* getMod() const { return "SyncEvolution"; } virtual const char* getOem() const { return "Open Source"; } @@ -687,16 +688,6 @@ class EvolutionSyncConfig { virtual const char* getSwv() const; virtual const char* getDevType() const; - virtual bool getUtc() const { return true; } - virtual bool getNocSupport() const { return false; } - - virtual const char* getServerNonce() const; - virtual void setServerNonce(const char *value); - virtual const char* getClientNonce() const; - virtual void setClientNonce(const char *value); - virtual const char* getDevInfHash() const; - virtual void setDevInfHash(const char *value); - /**@}*/ private: @@ -893,15 +884,6 @@ class EvolutionSyncSourceConfig { virtual void setSync(const string &value, bool temporarily = false); /** - * Specifies how the content of an outgoing item should be - * encoded by the client library if the sync source does not - * set an encoding on the item that it created. Valid values - * are listed in SyncItem::encodings. - */ - virtual const char* getEncoding() const; - virtual void setEncoding(const string &value, bool temporarily = false); - - /** * Sets the last sync timestamp. Called by the sync engine at * the end of a sync. The client must save that modified * value; it is needed to decide during the next sync whether diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index 0f03f211..507099c8 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -64,6 +64,17 @@ #include <boost/bind.hpp> +bool SyncOptions::defaultWBXML() +{ + const char *t = getenv("CLIENT_TEST_XML"); + if (t && (!strcmp(t, "1") || !strcasecmp(t, "t"))) { + // use XML + return false; + } else { + return true; + } +} + /** utility function to iterate over different kinds of items in a sync source */ static std::list<std::string> listAnyItems( SyncSource *source, @@ -1664,14 +1675,11 @@ void SyncTests::addTests() { if (config.import) { ADD_TEST(SyncTests, testTwinning); ADD_TEST(SyncTests, testItems); + ADD_TEST(SyncTests, testItemsXML); } if (config.templateItem) { ADD_TEST(SyncTests, testMaxMsg); ADD_TEST(SyncTests, testLargeObject); - ADD_TEST(SyncTests, testLargeObjectBin); - if (client.isB64Enabled()) { - ADD_TEST(SyncTests, testLargeObjectEncoded); - } ADD_TEST(SyncTests, testOneWayFromServer); ADD_TEST(SyncTests, testOneWayFromClient); } @@ -1795,14 +1803,16 @@ void SyncTests::doCopy() { * but done with explicit local delete and then a SYNC_SLOW because some * servers do no support SYNC_REFRESH_FROM_SERVER */ -void SyncTests::refreshClient() { +void SyncTests::refreshClient(SyncOptions options) { source_it it; for (it = sources.begin(); it != sources.end(); ++it) { it->second->deleteAll(it->second->createSourceA); } + doSync("refresh", - SyncOptions(SYNC_SLOW, - CheckSyncReport(-1,0,0, 0,0,0, true, SYNC_SLOW))); + options + .setSyncMode(SYNC_SLOW) + .setCheckReport(CheckSyncReport(-1,0,0, 0,0,0, true, SYNC_SLOW))); } @@ -2454,8 +2464,27 @@ void SyncTests::testItems() { } // transfer from client A to server to client B - doSync("send", SyncOptions(SYNC_TWO_WAY)); - accessClientB->refreshClient(); + doSync("send", SyncOptions(SYNC_TWO_WAY).setWBXML(true)); + accessClientB->refreshClient(SyncOptions().setWBXML(true)); + + compareDatabases(); +} + +// creates several items, transmits them back and forth and +// then compares which of them have been preserved +void SyncTests::testItemsXML() { + // clean server and first test database + deleteAll(); + + // import data + source_it it; + for (it = sources.begin(); it != sources.end(); ++it) { + it->second->testImport(); + } + + // transfer from client A to server to client B using the non-default XML format + doSync("send", SyncOptions(SYNC_TWO_WAY).setWBXML(false)); + accessClientB->refreshClient(SyncOptions().setWBXML(false)); compareDatabases(); } @@ -2549,8 +2578,7 @@ void SyncTests::testManyItems() { * using a sequence of items with varying sizes */ void SyncTests::doVarSizes(bool withMaxMsgSize, - bool withLargeObject, - const std::string &encoding) { + bool withLargeObject) { static const int maxMsgSize = 8 * 1024; // clean server and client A @@ -2576,8 +2604,7 @@ void SyncTests::doVarSizes(bool withMaxMsgSize, CheckSyncReport(0,0,0, -1,0,0, true, SYNC_TWO_WAY), // number of items sent to server depends on source withMaxMsgSize ? maxMsgSize : 0, withMaxMsgSize ? maxMsgSize * 100 : 0, - withLargeObject, - encoding)); + withLargeObject)); // copy to second client accessClientB->doSync("recv", @@ -2585,8 +2612,7 @@ void SyncTests::doVarSizes(bool withMaxMsgSize, CheckSyncReport(-1,0,-1, 0,0,0, true, SYNC_REFRESH_FROM_SERVER), // number of items received from server depends on source withLargeObject ? maxMsgSize : withMaxMsgSize ? maxMsgSize * 100 /* large enough so that server can sent the largest item */ : 0, withMaxMsgSize ? maxMsgSize * 100 : 0, - withLargeObject, - encoding)); + withLargeObject)); // compare compareDatabases(); diff --git a/test/ClientTest.h b/test/ClientTest.h index b2f6640c..7cd8a478 100644 --- a/test/ClientTest.h +++ b/test/ClientTest.h @@ -113,8 +113,8 @@ struct SyncOptions { long m_maxObjSize; /** enabled large object support */ bool m_loSupport; - /** preferred item encoding */ - std::string m_encoding; + /** enabled WBXML (default) */ + bool m_isWBXML; typedef boost::function<bool (EvolutionSyncClient &, SyncOptions &)> Callback_t; @@ -130,14 +130,14 @@ struct SyncOptions { long maxMsgSize = 0, long maxObjSize = 0, bool loSupport = false, - const std::string &encoding = std::string(), + bool isWBXML = defaultWBXML(), Callback_t startCallback = EmptyCallback) : m_syncMode(syncMode), m_checkReport(checkReport), m_maxMsgSize(maxMsgSize), m_maxObjSize(maxObjSize), m_loSupport(loSupport), - m_encoding(encoding), + m_isWBXML(isWBXML), m_startCallback(startCallback) {} @@ -146,11 +146,14 @@ struct SyncOptions { SyncOptions &setMaxMsgSize(long maxMsgSize) { m_maxMsgSize = maxMsgSize; return *this; } SyncOptions &setMaxObjSize(long maxObjSize) { m_maxObjSize = maxObjSize; return *this; } SyncOptions &setLOSupport(bool loSupport) { m_loSupport = loSupport; return *this; } - SyncOptions &setEncoding(const std::string &encoding) { m_encoding = encoding; return *this; } + SyncOptions &setWBXML(bool isWBXML) { m_isWBXML = isWBXML; return *this; } SyncOptions &setStartCallback(const Callback_t &callback) { m_startCallback = callback; return *this; } static bool EmptyCallback(EvolutionSyncClient &, SyncOptions &) { return false; } + + /** if CLIENT_TEST_XML=1, then XML, otherwise WBXML */ + static bool defaultWBXML(); }; class LocalTests; @@ -522,13 +525,6 @@ class ClientTest { virtual ClientTest *getClientB() = 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 bool isB64Enabled() = 0; - - /** * 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 @@ -829,7 +825,7 @@ protected: * but done with explicit local delete and then a SYNC_SLOW because some * servers do no support SYNC_REFRESH_FROM_SERVER */ - virtual void refreshClient(); + virtual void refreshClient(SyncOptions options = SyncOptions()); /* for more information on the different tests see their implementation */ @@ -883,23 +879,16 @@ protected: SyncOptions &options); virtual void testConversion(); virtual void testItems(); + virtual void testItemsXML(); virtual void testAddUpdate(); // test copying with maxMsg and no large object support void testMaxMsg() { - doVarSizes(true, false, ""); + doVarSizes(true, false); } // test copying with maxMsg and large object support void testLargeObject() { - doVarSizes(true, true, ""); - } - // test copying with maxMsg and large object support using explicit "bin" encoding - void testLargeObjectBin() { - doVarSizes(true, true, "bin"); - } - // test copying with maxMsg and large object support using B64 encoding - void testLargeObjectEncoded() { - doVarSizes(true, true, "b64"); + doVarSizes(true, true); } virtual void testManyItems(); @@ -926,8 +915,7 @@ protected: * using a sequence of items with varying sizes */ virtual void doVarSizes(bool withMaxMsgSize, - bool withLargeObject, - const std::string &encoding); + bool withLargeObject); /** * executes a sync with the given options, |