diff --git a/openCherry/Testing/org.opencherry.core.runtime/CMakeLists.txt b/openCherry/Testing/org.opencherry.core.runtime/CMakeLists.txt deleted file mode 100644 index 1731f3f9a2..0000000000 --- a/openCherry/Testing/org.opencherry.core.runtime/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -INCLUDE(${OPENCHERRY_SOURCE_DIR}/CMake/cherryTestingHelpers.cmake) -INCLUDE_DIRECTORIES(${OPENCHERRY_PLUGINS_SOURCE_DIR}/org.opencherry.osgi/src) -INCLUDE_DIRECTORIES(${OPENCHERRY_PLUGINS_SOURCE_DIR}/org.opencherry.core.runtime/src) -INCLUDE_DIRECTORIES(${OPENCHERRY_PLUGINS_SOURCE_DIR}/org.opencherry.core.runtime/src/internal) - -# tests with no extra command line parameter -SET(OPENCHERRY_TESTS - cherryPreferencesServiceTest.cpp - cherryPreferencesTest.cpp - cherryXMLPreferencesStorageTest.cpp -) - -OPENCHERRY_CREATE_TESTS() \ No newline at end of file diff --git a/openCherry/Testing/org.opencherry.core.runtime/cherryPreferencesServiceTest.cpp b/openCherry/Testing/org.opencherry.core.runtime/cherryPreferencesServiceTest.cpp deleted file mode 100644 index 69cc0c79df..0000000000 --- a/openCherry/Testing/org.opencherry.core.runtime/cherryPreferencesServiceTest.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*========================================================================= - - Program: openCherry Platform - Language: C++ - Date: $Date: 2009-02-20 18:47:40 +0100 (Fr, 20 Feb 2009) $ - Version: $Revision: 16370 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "cherryTestingMacros.h" -#include "cherryPreferencesService.h" - -#include "mbilog.h" - -#include "Poco/File.h" -#include "Poco/Path.h" -#include "Poco/AutoPtr.h" - -#include -#include -#include - -using namespace std; - -int cherryPreferencesServiceTest(int /*argc*/, char* /*argv*/[]) -{ - CHERRY_TEST_BEGIN("PreferencesService") - Poco::File sysPrefFile; - Poco::File user1PrefFile; - Poco::File user2PrefFile; - - std::string userName1 = "testUser1"; - std::string userName2 = "testUser2"; - - vector validUsersVector; - validUsersVector.push_back(""); - validUsersVector.push_back(userName1); - validUsersVector.push_back(userName2); - - try - { - - //std::string defaultPrefDir = cherry::PreferencesService::GetDefaultPreferencesDirPath(); - std::string defaultPrefDir = "testPrefDir"; - Poco::File prefDir("testPrefDir"); - - // tidy up from prior tests - if(prefDir.exists()) - prefDir.remove(); - { - cherry::PreferencesService::Pointer prefService(new cherry::PreferencesService(prefDir.path())); - - // hopefully tested - std::string defaultPrefFileName = cherry::PreferencesService::GetDefaultPreferencesFileName(); - - //# remove old user and sys files (if their was a previous test - ostringstream s; s << defaultPrefDir << Poco::Path::separator() << defaultPrefFileName; - sysPrefFile = s.str(); - s.str(""); s << defaultPrefDir << Poco::Path::separator() << userName1 << defaultPrefFileName; - user1PrefFile = s.str(); - s.str(""); s << defaultPrefDir << Poco::Path::separator() << userName2 << defaultPrefFileName; - user2PrefFile = s.str(); - - //# test GetSystemPreferences - cherry::IPreferences::Pointer sysPrefsRoot = prefService->GetSystemPreferences(); - CHERRY_TEST_CONDITION(sysPrefsRoot.IsNotNull(), "sysPrefsRoot.IsNotNull()") - cherry::IPreferences::Pointer sysPrefsGeneral = sysPrefsRoot->Node("/general"); - sysPrefsGeneral->Put("font-size", "10"); - - //# test GetUserPreferences - cherry::IPreferences::Pointer user1PrefsRoot = prefService->GetUserPreferences(userName1); - CHERRY_TEST_CONDITION(user1PrefsRoot.IsNotNull(), "user1PrefsRoot.IsNotNull()") - cherry::IPreferences::Pointer user1PrefsGeneral = user1PrefsRoot->Node("/general"); - user1PrefsGeneral->PutInt("font-size", 10); - - //# test GetUserPreferences - cherry::IPreferences::Pointer user2PrefsRoot = prefService->GetUserPreferences(userName2); - CHERRY_TEST_CONDITION(user2PrefsRoot.IsNotNull(), "user2PrefsRoot.IsNotNull()") - cherry::IPreferences::Pointer user2PrefsGeneral = user2PrefsRoot->Node("/general"); - user2PrefsGeneral->PutFloat("font-size", 10.32324f); - - //# test GetUsers - vector usersVector = prefService->GetUsers(); - CHERRY_TEST_CONDITION(usersVector == validUsersVector, "usersVector == validUsersVector") - } - // pref service was destructed files should exist now - CHERRY_TEST_CONDITION(sysPrefFile.exists(), "sysPrefFile.exists()") - CHERRY_TEST_CONDITION(user1PrefFile.exists(), "user1PrefFile.exists()") - CHERRY_TEST_CONDITION(user2PrefFile.exists(), "user2PrefFile.exists()") - - // now create a new pref service that reads the files in again - cherry::PreferencesService::Pointer prefService(new cherry::PreferencesService()); - - //# test GetUsers - vector usersVector = prefService->GetUsers(); - CHERRY_TEST_CONDITION(usersVector == validUsersVector, "usersVector == validUsersVector") - - //# test GetSystemPreferences - cherry::IPreferences::Pointer sysPrefsRoot = prefService->GetSystemPreferences(); - CHERRY_TEST_CONDITION(sysPrefsRoot.IsNotNull(), "sysPrefsRoot.IsNotNull()") - cherry::IPreferences::Pointer sysPrefsGeneral = sysPrefsRoot->Node("/general"); - CHERRY_TEST_CONDITION(sysPrefsGeneral->Get("font-size", "") == "10", "sysPrefsGeneral->Get(\"font-size\", \"\") == \"10\"") - - //# test GetUserPreferences - cherry::IPreferences::Pointer user1PrefsRoot = prefService->GetUserPreferences(userName1); - CHERRY_TEST_CONDITION(user1PrefsRoot.IsNotNull(), "user1PrefsRoot.IsNotNull()") - cherry::IPreferences::Pointer user1PrefsGeneral = user1PrefsRoot->Node("/general"); - CHERRY_TEST_CONDITION(user1PrefsGeneral->GetInt("font-size", 0) == 10, "user1PrefsGeneral->GetInt(\"font-size\", 0)") - - //# test GetUserPreferences - cherry::IPreferences::Pointer user2PrefsRoot = prefService->GetUserPreferences(userName2); - CHERRY_TEST_CONDITION(user2PrefsRoot.IsNotNull(), "user2PrefsRoot.IsNotNull()") - cherry::IPreferences::Pointer user2PrefsGeneral = user2PrefsRoot->Node("/general"); - float user2FontSize = user2PrefsGeneral->GetFloat("font-size", 0.0f); - CHERRY_TEST_CONDITION(user2FontSize == 10.32324f, "user2PrefsGeneral->GetFloat(\"font-size\", 0.0f) == 10.32324f") - - if(prefDir.exists()) - prefDir.remove(); - - } - catch (Poco::Exception& e) - { - LOG_WARN("PreferencesService") << e.message(); - } - - CHERRY_TEST_END() -} diff --git a/openCherry/Testing/org.opencherry.core.runtime/cherryPreferencesTest.cpp b/openCherry/Testing/org.opencherry.core.runtime/cherryPreferencesTest.cpp deleted file mode 100644 index 37c4cdb287..0000000000 --- a/openCherry/Testing/org.opencherry.core.runtime/cherryPreferencesTest.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/*========================================================================= - - Program: openCherry Platform - Language: C++ - Date: $Date: 2009-02-20 18:47:40 +0100 (Fr, 20 Feb 2009) $ - Version: $Revision: 16370 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "cherryTestingMacros.h" -#include "cherryPreferences.h" -#include "cherryAbstractPreferencesStorage.h" - -#include "mbilog.h" - -#include "Poco/File.h" -#include "Poco/Path.h" - -#include -#include -#include - -using namespace std; - -namespace cherry -{ - class TestPreferencesStorage: public cherry::AbstractPreferencesStorage - { - - public: - /// - /// For use with cherry::SmartPtr - /// - cherryObjectMacro(cherry::TestPreferencesStorage) - /// - /// Construct a new XML-based PreferencesStorage - /// - TestPreferencesStorage(const Poco::File& _File) - : AbstractPreferencesStorage(_File) - { - this->m_Root = new Preferences(Preferences::PropertyMap(), "", 0, this); - } - - /// - /// To be implemented in the subclasses. - /// - virtual void Flush(IPreferences* _Preferences) throw(Poco::Exception, BackingStoreException) - { - std::cout << "would flush to " << this->m_File.path() << std::endl; - } - }; -} - -int cherryPreferencesTest(int /*argc*/, char* /*argv*/[]) -{ - CHERRY_TEST_BEGIN("Preferences") - - cherry::IPreferences::Pointer root(0); - cherry::TestPreferencesStorage::Pointer _PreferencesStorage(0); - - // hopefully tested - Poco::File prefDir(Poco::Path::home()+Poco::Path::separator()+".BlueBerryTest"+Poco::Path::separator()+"prefs.xml"); - - // testing methods - // TestPreferencesStorage::TestPreferencesStorage() - // AbstractPreferencesStorage::AbstractPreferencesStorage(), - // AbstractPreferencesStorage::GetRoot - { - _PreferencesStorage = new cherry::TestPreferencesStorage(Poco::Path(prefDir.path())); - root = _PreferencesStorage->GetRoot(); - CHERRY_TEST_CONDITION(root.IsNotNull(), "root.IsNotNull()") - } - - // testing methods - // Preferences::Node() - // Preferences::NodeExists() - // Preferences::Parent() - // Preferences::ChildrenNames() - // Preferences::RemoveNode() - { - LOG_INFO << "testing Preferences::Node(), Preferences::NodeExists(), Preferences::Parent(), " - "Preferences::ChildrenNames(), Preferences::RemoveNode()"; - - cherry::IPreferences::Pointer editorsNode(0); - editorsNode = root->Node("/editors"); - CHERRY_TEST_CONDITION(editorsNode.IsNotNull(), "editorsNode.IsNotNull()") - - CHERRY_TEST_CONDITION(editorsNode->NodeExists("/editors"), "editorsNode->NodeExists(\"/editors\")") - - CHERRY_TEST_CONDITION(editorsNode->Parent() == root, "editorsNode->Parent() == root") - - cherry::IPreferences::Pointer editorsGeneralNode = root->Node("/editors/general"); - CHERRY_TEST_CONDITION(editorsNode->NodeExists("/editors/general"), "editorsNode->NodeExists(\"/editors/general\")") - - cherry::IPreferences::Pointer editorsSyntaxNode = root->Node("/editors/syntax"); - CHERRY_TEST_CONDITION(editorsGeneralNode->NodeExists("/editors/syntax"), "editorsGeneralNode->NodeExists(\"/editors/syntax\")") - - cherry::IPreferences::Pointer editorsFontNode = root->Node("/editors/font"); - CHERRY_TEST_CONDITION(editorsSyntaxNode->NodeExists("/editors/font"), "editorsSyntaxNode->NodeExists(\"/editors/font\")") - - vector childrenNames; - childrenNames.push_back("general"); - childrenNames.push_back("syntax"); - childrenNames.push_back("font"); - CHERRY_TEST_CONDITION(editorsNode->ChildrenNames() == childrenNames, "editorsNode->ChildrenNames() == childrenName") - - editorsFontNode->RemoveNode(); - CHERRY_TEST_FOR_EXCEPTION(Poco::IllegalStateException, editorsFontNode->Parent()); - } - - // testing methods - // Preferences::put*() - // Preferences::get*() - { - LOG_INFO << "testing Preferences::put*(), Preferences::get*()"; - - CHERRY_TEST_CONDITION(root->NodeExists("/editors/general"), "root->NodeExists(\"/editors/general\")") - cherry::IPreferences::Pointer editorsGeneralNode = root->Node("/editors/general"); - - std::string strKey = "Bad words";std::string strValue = "badword1 badword2"; - editorsGeneralNode->Put(strKey, strValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->Get(strKey, "") == strValue - , "editorsGeneralNode->Get(strKey, \"\")") - CHERRY_TEST_CONDITION(editorsGeneralNode->Get("wrong key", "default value") == "default value" - , "editorsGeneralNode->Get(\"wrong key\", \"default value\") == \"default value\"") - - strKey = "Show Line Numbers";bool bValue = true; - editorsGeneralNode->PutBool(strKey, bValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->GetBool(strKey, !bValue) == bValue - , "editorsGeneralNode->GetBool(strKey, !bValue)") - - strKey = "backgroundcolor"; strValue = "#00FF00"; - editorsGeneralNode->PutByteArray(strKey, strValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->GetByteArray(strKey, "") == strValue - , "editorsGeneralNode->GetByteArray(strKey, \"\")") - - strKey = "update time"; double dValue = 1.23; - editorsGeneralNode->PutDouble(strKey, dValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->GetDouble(strKey, 0.0) == dValue - , "editorsGeneralNode->GetDouble(strKey, 0.0)") - - strKey = "update time float"; float fValue = 1.23f; - editorsGeneralNode->PutFloat(strKey, fValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->GetFloat(strKey, 0.0f) == fValue - , "editorsGeneralNode->GetFloat(strKey, 0.0f)") - - strKey = "Break on column"; int iValue = 80; - editorsGeneralNode->PutInt(strKey, iValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->GetInt(strKey, 0) == iValue - , "editorsGeneralNode->GetInt(strKey, 0)") - - strKey = "Maximum number of words"; long lValue = 11000000; - editorsGeneralNode->PutLong(strKey, lValue); - CHERRY_TEST_CONDITION(editorsGeneralNode->GetLong(strKey, 0) == lValue - , "editorsGeneralNode->GetLong(strKey, 0)") - } - -/* - // Message test - { - cherry::Message<> msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef cherry::MessageDelegate Delegate; - - msg += Delegate(&receiver, &MessageReceiver::PureSignal); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Adding listener") - msg += Delegate(&receiver2, &MessageReceiver::PureSignal); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::PureSignal); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 2, "Adding duplicate listener") - - msg.Send(); - CHERRY_TEST_CONDITION(receiver.received && receiver2.received, "Receiving signal") - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::PureSignal); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Removing listener") - - msg.Send(); - CHERRY_TEST_CONDITION(receiver.received == false && receiver2.received, "Receiving signal") - } - - // Message with return type test - { - cherry::Message msg; - - MessageReceiver receiver; - typedef cherry::MessageDelegate Delegate; - msg += Delegate(&receiver, &MessageReceiver::PureSignalWithReturn); - msg(); - CHERRY_TEST_CONDITION(receiver.received, "Receiving signal with return type") - - receiver.received = false; - typedef cherry::Message::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(); - if (valueReturned) break; - } - CHERRY_TEST_CONDITION(valueReturned, "Handling return values") - } - - // Message1 test - { - cherry::Message1 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef cherry::MessageDelegate1 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message1); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Adding listener") - msg += Delegate(&receiver2, &MessageReceiver::Message1); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message1); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 2, "Adding duplicate listener") - - msg.Send(1); - CHERRY_TEST_CONDITION(receiver.received && receiver2.received, "Receiving message1") - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message1); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Removing listener") - - msg.Send(1); - CHERRY_TEST_CONDITION(receiver.received == false && receiver2.received, "Receiving message1") - } - - // Message1 with return type test - { - cherry::Message1 msg; - - MessageReceiver receiver; - typedef cherry::MessageDelegate1 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message1WithReturn); - msg(1); - CHERRY_TEST_CONDITION(receiver.received, "Receiving message1 with return type") - - receiver.received = false; - typedef cherry::Message1::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1); - if (valueReturned) break; - } - CHERRY_TEST_CONDITION(valueReturned, "Handling return values") - } - - // Message2 test - { - cherry::Message2 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef cherry::MessageDelegate2 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message2); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Adding listener") - msg += Delegate(&receiver2, &MessageReceiver::Message2); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message2); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 2, "Adding duplicate listener") - - msg.Send(1, 1.0); - CHERRY_TEST_CONDITION(receiver.received && receiver2.received, "Receiving message2") - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message2); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Removing listener") - - msg.Send(1, 1.0); - CHERRY_TEST_CONDITION(receiver.received == false && receiver2.received, "Receiving message2") - } - - // Message2 with return type test - { - cherry::Message2 msg; - - MessageReceiver receiver; - typedef cherry::MessageDelegate2 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message2WithReturn); - msg(1, 2); - CHERRY_TEST_CONDITION(receiver.received, "Receiving message2 with return type") - - receiver.received = false; - typedef cherry::Message2::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1, 0.4); - if (valueReturned) break; - } - CHERRY_TEST_CONDITION(valueReturned, "Handling return values") - } - - // Message3 test - { - cherry::Message3 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef cherry::MessageDelegate3 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message3); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Adding listener") - msg += Delegate(&receiver2, &MessageReceiver::Message3); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message3); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 2, "Adding duplicate listener") - - msg.Send(1, 1.0, 2.0); - CHERRY_TEST_CONDITION(receiver.received && receiver2.received, "Receiving message3") - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message3); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Removing listener") - - msg.Send(1, -1.0, 5.0); - CHERRY_TEST_CONDITION(receiver.received == false && receiver2.received, "Receiving message3") - } - - // Message3 with return type test - { - cherry::Message3 msg; - - MessageReceiver receiver; - typedef cherry::MessageDelegate3 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message3WithReturn); - msg(1, -2, 0.2); - CHERRY_TEST_CONDITION(receiver.received, "Receiving message3 with return type") - - receiver.received = false; - typedef cherry::Message3::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1, 23.5, -12.2); - if (valueReturned) break; - } - CHERRY_TEST_CONDITION(valueReturned, "Handling return values") - } - - // Message4 test - { - cherry::Message4 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef cherry::MessageDelegate4 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message4); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Adding listener") - msg += Delegate(&receiver2, &MessageReceiver::Message4); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message4); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 2, "Adding duplicate listener") - - msg.Send(1, 5.4, -1.0, true); - CHERRY_TEST_CONDITION(receiver.received && receiver2.received, "Receiving message4") - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message4); - CHERRY_TEST_CONDITION(msg.GetListeners().size() == 1, "Removing listener") - - msg.Send(1, 0.2, 12.0, true); - CHERRY_TEST_CONDITION(receiver.received == false && receiver2.received, "Receiving message4") - } - - // Message4 with return type test - { - cherry::Message4 msg; - - MessageReceiver receiver; - typedef cherry::MessageDelegate4 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message4WithReturn); - msg(1, 4.1, -1, true); - CHERRY_TEST_CONDITION(receiver.received, "Receiving message4 with return type") - - receiver.received = false; - typedef cherry::Message4::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1, -34.21, 2, true); - if (valueReturned) break; - } - CHERRY_TEST_CONDITION(valueReturned, "Handling return values") - }*/ - - - CHERRY_TEST_END() -} diff --git a/openCherry/Testing/org.opencherry.core.runtime/cherryXMLPreferencesStorageTest.cpp b/openCherry/Testing/org.opencherry.core.runtime/cherryXMLPreferencesStorageTest.cpp deleted file mode 100644 index 4f35ad4e9b..0000000000 --- a/openCherry/Testing/org.opencherry.core.runtime/cherryXMLPreferencesStorageTest.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*========================================================================= - - Program: openCherry Platform - Language: C++ - Date: $Date: 2009-02-20 18:47:40 +0100 (Fr, 20 Feb 2009) $ - Version: $Revision: 16370 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "cherryTestingMacros.h" -#include "cherryXMLPreferencesStorage.h" - -using namespace std; - -void testLoadFile(Poco::File& file) -{ - // file exists, test parsing etc. - cherry::XMLPreferencesStorage storage(file); - cherry::IPreferences::Pointer prefRoot = storage.GetRoot(); - CHERRY_TEST_CONDITION(prefRoot.IsNotNull(), "prefRoot.IsNotNull()") - - // try to find nodes that were create by testCreateFile - CHERRY_TEST_CONDITION(prefRoot->NodeExists("/Text Editor"), "prefRoot.NodeExists(\"/Text Editor\")") - CHERRY_TEST_CONDITION(prefRoot->NodeExists("/Text Editor"), "prefRoot.NodeExists(\"/Text Editor/C++\")") - CHERRY_TEST_CONDITION(prefRoot->NodeExists("/Text Editor"), "prefRoot.NodeExists(\"/Text Editor/Java\")") - CHERRY_TEST_CONDITION(prefRoot->NodeExists("/Text Editor"), "prefRoot.NodeExists(\"/Text Editor/Java/Javascript\")") - - // try to get some properties - cherry::IPreferences::Pointer cppEditor = prefRoot->Node("/Text Editor/C++"); - CHERRY_TEST_CONDITION(cppEditor->GetBool("Show Line Numbers", false) == true, "cppEditor->GetBool(\"Show Line Numbers\")") - CHERRY_TEST_CONDITION(cppEditor->Get("File Extension", "") == "cpp cxx", "cppEditor->Get(\"File Extension\") == \"cpp cxx\"") - - cherry::IPreferences::Pointer jsEditor = prefRoot->Node("/Text Editor/Java/Javascript"); - CHERRY_TEST_CONDITION(jsEditor->GetBool("Show Line Numbers", false) == true, "jsEditor->GetBool(\"Show Line Numbers\")") - CHERRY_TEST_CONDITION(jsEditor->Get("File Extension", "") == "js", "jsEditor->Get(\"File Extension\") == \"js\"") - CHERRY_TEST_CONDITION(jsEditor->GetInt("Show margin at column", 0) == 70, "jsEditor->GetInt(\"Show margin at column\", 0) == 70") -} - -void testCreateFile(Poco::File& file) -{ - // file does not exist, test with empty preferences - cherry::XMLPreferencesStorage storage(file); - cherry::IPreferences::Pointer prefRoot = storage.GetRoot(); - CHERRY_TEST_CONDITION(prefRoot.IsNotNull(), "prefRoot.IsNotNull()") - - // add some preferences ( tested in the preferences test -> no conditions here ) - cherry::IPreferences::Pointer textEditor = prefRoot->Node("/Text Editor"); - textEditor->PutBool("Show Line Numbers", true); - textEditor->Put("File Extension", "txt rtf xml"); - - cherry::IPreferences::Pointer cppEditor = prefRoot->Node("/Text Editor/C++"); - cppEditor->PutBool("Show Line Numbers", true); - cppEditor->Put("File Extension", "cpp cxx"); - cppEditor->PutInt("Show margin at column", 80); - - cherry::IPreferences::Pointer javaEditor = prefRoot->Node("/Text Editor/Java"); - javaEditor->PutBool("Show Line Numbers", false); - javaEditor->Put("File Extension", "java"); - javaEditor->PutInt("Show margin at column", 90); - - cherry::IPreferences::Pointer jsEditor = prefRoot->Node("/Text Editor/Java/Javascript"); - jsEditor->PutBool("Show Line Numbers", true); - jsEditor->Put("File Extension", "js"); - jsEditor->PutInt("Show margin at column", 70); - - // try to flush it with an arbitrary node (should take the root node) - storage.Flush(jsEditor.GetPointer()); - CHERRY_TEST_CONDITION(file.exists(), "file.exists()") -} - -int cherryXMLPreferencesStorageTest(int /*argc*/, char* /*argv*/[]) -{ - CHERRY_TEST_BEGIN("XMLPreferencesStorage") - - Poco::Path path("prefs.xml"); - Poco::File file(path); - - if(file.exists()) - file.remove(); - - testCreateFile(file); - testLoadFile(file); - - CHERRY_TEST_END() -}