4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE BackendFactoryTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
10 #include "DeviceAccessVersion.h"
14 #include <boost/make_shared.hpp>
26 using DummyBackend::DummyBackend;
29 std::string instance, std::map<std::string, std::string> parameters) {
30 return returnInstance<NewBackend>(instance, convertPathRelativeToDmapToAbs(parameters[
"map"]));
36 BOOST_AUTO_TEST_SUITE(BackendFactoryTestSuite)
39 BackendFactory::getInstance().setDMapFilePath(
"");
46 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"test"),
49 BackendFactory::getInstance().setDMapFilePath(oldtestFilePath);
50 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"test"),
53 boost::shared_ptr<DeviceBackend> testPtr;
54 BOOST_CHECK_NO_THROW(testPtr = BackendFactory::getInstance().createBackend(
"DUMMYD0"));
57 BackendFactory::getInstance().setDMapFilePath(testFilePath);
58 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"test"),
61 BOOST_CHECK_NO_THROW(testPtr = BackendFactory::getInstance().createBackend(
"DUMMYD9"));
63 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"FAKE1"),
68 boost::shared_ptr<DeviceBackend> testPtr2;
69 BOOST_CHECK_NO_THROW(testPtr2 = BackendFactory::getInstance().createBackend(
"DUMMYD9"));
71 BOOST_CHECK(testPtr2 == testPtr);
83 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"(newBackendWrongVersion?map=goodMapFile.map)"),
89 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend(
"(newBackend?map=goodMapFile.map)"));
96 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend(
"(working?map=goodMapFile.map)"));
97 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend(
"(working?map=goodMapFile.map)"));
101 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"(notRegisteringPlugin?map=goodMapFile.map)"),
106 BackendFactory::getInstance().createBackend(
"(wrongVersionBackend?map=goodMapFile.map)"),
ChimeraTK::logic_error);
109 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"(ibWrongVersionBackendCompat?map=goodMapFile.map)"),
112 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend(
"(unregisteredBackend)"),
ChimeraTK::logic_error);
117 BackendFactory::getInstance().setDMapFilePath(
"");
119 boost::shared_ptr<DeviceBackend> testPtr;
120 testPtr = BackendFactory::getInstance().createBackend(
"(dummy?map=mtcadummy.map)");
123 BOOST_CHECK(testPtr);
126 BOOST_AUTO_TEST_SUITE_END()