summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-14 13:58:22 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-14 13:58:22 (GMT)
commit9c81b10bfafddd0c3c329731da89887c2538aabf (patch)
tree0f902d2af211c3a2a0c9d662b8b693228ce32b8e
parentd46e862656689255e7a2c8e598ac20177f91a60b (diff)
parentb547658b06be929298bf90fe1ebb500ad3b186a8 (diff)
downloadlibkolabxml-9c81b10bfafddd0c3c329731da89887c2538aabf.tar.gz
Merge branch 'master' of ssh://git.kolabsys.com/git/libkolabxml
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/kolabconversions.h20
-rw-r--r--src/xcalconversions.h7
-rw-r--r--src/xcardconversions.h10
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/bindingstest.cpp37
-rw-r--r--tests/bindingstest.h3
-rw-r--r--tests/conversiontest.cpp2
-rw-r--r--tests/parsingtest.cpp6
9 files changed, 66 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04418f5..a523538 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -180,6 +180,7 @@ include_directories(
add_subdirectory(src)
if (BUILD_TESTS)
+ enable_testing()
add_subdirectory(tests)
endif()
diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index 2c4e0dc..1a9eb86 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -183,8 +183,11 @@ std::string serializeObject <Kolab::Configuration> (const Kolab::Configuration &
KolabXSD::configuration(ostringstream, n, map);
return ostringstream.str();
} catch (const xml_schema::exception& e) {
- CRITICAL("Unknown Exception: failed to write Configuration");
+ std::cerr << e << std::endl;
+ } catch (...) {
+ CRITICAL("Unhandled exception");
}
+ CRITICAL("Failed to write configuration!");
return std::string();
}
@@ -258,8 +261,11 @@ std::string serializeObject <Kolab::Note> (const Kolab::Note &note, const std::s
KolabXSD::note(ostringstream, n, map);
return ostringstream.str();
} catch (const xml_schema::exception& e) {
- CRITICAL("Unknown Exception: failed to write Note");
+ std::cerr << e << std::endl;
+ } catch (...) {
+ CRITICAL("Unhandled exception");
}
+ CRITICAL("Failed to write note!");
return std::string();
}
@@ -350,9 +356,10 @@ boost::shared_ptr<Kolab::Note> deserializeObject <Kolab::Note> (const std::strin
return n;
} catch (const xml_schema::exception& e) {
std::cerr << e << std::endl;
- CRITICAL("Failed to read note!");
+ } catch (...) {
+ CRITICAL("Unhandled exception");
}
-
+ CRITICAL("Failed to read note!");
return boost::shared_ptr<Kolab::Note>();
}
@@ -415,9 +422,10 @@ boost::shared_ptr<Kolab::Configuration> deserializeObject <Kolab::Configuration>
return n;
} catch (const xml_schema::exception& e) {
std::cerr << e << std::endl;
- CRITICAL("Failed to read configuration!");
+ } catch (...) {
+ CRITICAL("Unhandled exception");
}
-
+ CRITICAL("Failed to read configuration!");
return boost::shared_ptr<Kolab::Configuration>();
}
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index c36cc42..0a419b9 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -1905,11 +1905,11 @@ typename T::IncidencePtr deserializeIncidence(const std::string& s, bool isUrl)
}
return *incidences.begin();
} catch (const xml_schema::exception& e) {
- std::cout << e << std::endl;
- CRITICAL("Failed to read incidence!");
+ std::cerr << e << std::endl;
} catch (...) {
CRITICAL("Unhandled exception");
}
+ CRITICAL("Failed to read incidence!");
return IncidencePtr();
}
@@ -1953,10 +1953,11 @@ std::string serializeFreebusy(const Kolab::Freebusy &incidence, const std::strin
icalendar_2_0::icalendar(ostringstream, icalendar, map);
return ostringstream.str();
} catch (const xml_schema::exception& e) {
- CRITICAL("failed to write Incidence");
+ std::cerr << e << std::endl;
} catch (...) {
CRITICAL("Unhandled exception");
}
+ CRITICAL("failed to write Incidence");
return std::string();
}
diff --git a/src/xcardconversions.h b/src/xcardconversions.h
index dd23c3b..8e913d3 100644
--- a/src/xcardconversions.h
+++ b/src/xcardconversions.h
@@ -791,8 +791,11 @@ std::string serializeCard(const T &card, const std::string prod = std::string())
vcard_4_0::vcards(ostringstream, vcards, map);
return ostringstream.str();
} catch (const xml_schema::exception& e) {
- CRITICAL("Unknown Exception: failed to write Contact");
+ std::cerr << e << std::endl;
+ } catch (...) {
+ CRITICAL("Unhandled exception");
}
+ CRITICAL("Failed to write vcard!");
return std::string();
}
@@ -1141,9 +1144,10 @@ boost::shared_ptr<T> deserializeCard(const std::string& s, bool isUrl)
return card;
} catch (const xml_schema::exception& e) {
std::cerr << e << std::endl;
- CRITICAL("Failed to read card!");
+ } catch (...) {
+ CRITICAL("Unhandled exception");
}
-
+ CRITICAL("Failed to read vcard!");
return boost::shared_ptr<T>();
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6b2cc7a..63c06cb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,5 @@
find_package(Qt4)
+add_definitions(-DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -13,14 +14,17 @@ if (QT4_FOUND)
QT4_AUTOMOC(bindingstest.cpp)
add_executable(bindingstest bindingstest.cpp ${CMAKE_CURRENT_BINARY_DIR}/${BINDINGSTEST_MOC})
target_link_libraries(bindingstest ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} kolabxml ${XERCES_C})
+ add_test(bindingstest ${CMAKE_CURRENT_BINARY_DIR}/bindingstest)
QT4_AUTOMOC(conversiontest.cpp)
add_executable(conversiontest conversiontest.cpp ${CMAKE_CURRENT_BINARY_DIR}/${CONVERSIONTEST_MOC})
target_link_libraries(conversiontest ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} kolabxml ${XERCES_C})
+ add_test(conversiontest ${CMAKE_CURRENT_BINARY_DIR}/conversiontest)
QT4_AUTOMOC(parsingtest.cpp)
add_executable(parsingtest parsingtest.cpp ${CMAKE_CURRENT_BINARY_DIR}/${CONVERSIONTEST_MOC})
target_link_libraries(parsingtest ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} kolabxml ${XERCES_C})
+ add_test(parsingtest ${CMAKE_CURRENT_BINARY_DIR}/parsingtest)
else()
message(WARNING "Could not build tests because qt is missing")
endif()
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index 02bdef8..912e5c6 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -20,7 +20,6 @@
#include "src/containers/kolabjournal.h"
#include "libkolabxml-version.h"
-
void BindingsTest::categorycolorConfigurationCompletness()
{
Kolab::CategoryColor color("name");
@@ -181,13 +180,13 @@ void setIncidence(T &ev)
attachments.push_back(attach);
Kolab::Attachment attach2;
- attach2.setUri("../../tests/testfiles/icalEvent.xml", "mimetype");
+ attach2.setUri(TEST_DATA_PATH "/testfiles/icalEvent.xml", "mimetype");
attach2.setLabel("labe2l");
attachments.push_back(attach2);
Kolab::Attachment attach3;
using namespace std;
- ifstream file ("../../tests/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
+ ifstream file (TEST_DATA_PATH "/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
if (file.is_open()) {
int size = file.tellg();
char *memblock = new char [size];
@@ -376,13 +375,13 @@ void BindingsTest::journalCompletness()
attachments.push_back(attach);
Kolab::Attachment attach2;
- attach2.setUri("../../tests/testfiles/icalEvent.xml", "mimetype");
+ attach2.setUri(TEST_DATA_PATH "/testfiles/icalEvent.xml", "mimetype");
attach2.setLabel("labe2l");
attachments.push_back(attach2);
Kolab::Attachment attach3;
using namespace std;
- ifstream file ("../../tests/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
+ ifstream file (TEST_DATA_PATH "/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
if (file.is_open()) {
int size = file.tellg();
char *memblock = new char [size];
@@ -703,7 +702,7 @@ void BindingsTest::errorRecoveryTest()
void BindingsTest::BenchmarkRoundtripKolab()
{
- const Kolab::Event &event = Kolab::readEvent("../../tests/testfiles/icalEvent.xml", true);
+ const Kolab::Event &event = Kolab::readEvent(TEST_DATA_PATH "/testfiles/icalEvent.xml", true);
std::string result = Kolab::writeEvent(event);
QBENCHMARK {
Kolab::readEvent(result, false);
@@ -712,7 +711,7 @@ void BindingsTest::BenchmarkRoundtripKolab()
void BindingsTest::BenchmarkRoundtrip()
{
- const Kolab::Event &event = Kolab::readEvent("../../tests/testfiles/icalEvent.xml", true);
+ const Kolab::Event &event = Kolab::readEvent(TEST_DATA_PATH "/testfiles/icalEvent.xml", true);
std::string result;
QBENCHMARK {
result = Kolab::writeEvent(event);
@@ -720,6 +719,30 @@ void BindingsTest::BenchmarkRoundtrip()
}
}
+void BindingsTest::preserveLatin1()
+{
+ Kolab::Event event;
+ event.setSummary("äöü%@$£é¤¼²°");
+ std::string result = Kolab::writeEvent(event);
+// std::cout << result << std::endl;
+ Kolab::Event readEvent = Kolab::readEvent(result, false);
+// std::cout << readEvent.summary() << std::endl;
+ QCOMPARE(readEvent.summary(), event.summary());
+}
+
+void BindingsTest::preserveUnicode()
+{
+ Kolab::Event event;
+ event.setSummary("€Š�ـأبـ");
+ std::string result = Kolab::writeEvent(event);
+// std::cout << result << std::endl;
+ Kolab::Event readEvent = Kolab::readEvent(result, false);
+// std::cout << readEvent.summary() << std::endl;
+ QCOMPARE(readEvent.summary(), event.summary());
+}
+
+
+
QTEST_MAIN( BindingsTest )
#include "bindingstest.moc"
diff --git a/tests/bindingstest.h b/tests/bindingstest.h
index b5f7ce0..86fd7d7 100644
--- a/tests/bindingstest.h
+++ b/tests/bindingstest.h
@@ -44,6 +44,9 @@ class BindingsTest : public QObject
void BenchmarkRoundtripKolab();
void BenchmarkRoundtrip();
+ void preserveLatin1();
+ void preserveUnicode();
+
};
#endif \ No newline at end of file
diff --git a/tests/conversiontest.cpp b/tests/conversiontest.cpp
index 8ead31d..5b5c6d2 100644
--- a/tests/conversiontest.cpp
+++ b/tests/conversiontest.cpp
@@ -255,7 +255,7 @@ void threadF()
std::string uid = s.str();
// std::cout << uid << std::endl;
Kolab::Utils::setCreatedUid(uid);
- boost::this_thread::sleep(boost::posix_time::seconds(1));
+ boost::this_thread::sleep(boost::posix_time::millisec(50));
QCOMPARE(Kolab::Utils::createdUid(), uid);
}
}
diff --git a/tests/parsingtest.cpp b/tests/parsingtest.cpp
index c6619f0..d7957e5 100644
--- a/tests/parsingtest.cpp
+++ b/tests/parsingtest.cpp
@@ -23,11 +23,9 @@
#include "src/kolabformat.h"
-#define TESTFILEDIR "../../tests/testfiles/"
-
void ParsingTest::vcardParsingTest()
{
- const Kolab::Contact &contact = Kolab::readContact(TESTFILEDIR "vcard/contact.xml", true);
+ const Kolab::Contact &contact = Kolab::readContact(TEST_DATA_PATH "/testfiles/vcard/contact.xml", true);
QCOMPARE(Kolab::error(), Kolab::NoError);
std::cout << Kolab::writeContact(contact);
}
@@ -35,4 +33,4 @@ void ParsingTest::vcardParsingTest()
QTEST_MAIN( ParsingTest )
-#include "parsingtest.moc" \ No newline at end of file
+#include "parsingtest.moc"