1 #define BOOST_TEST_MODULE testDoocsBackend
2 #include <ChimeraTK/Device.h>
4 #include <boost/filesystem.hpp>
5 #include <boost/test/included/unit_test.hpp>
11 static std::string cacheFile =
"cache-" + boost::filesystem::unique_path().string() +
".xml";
13 static void deleteFile(
const std::string& filename) {
14 std::string command =
"rm " + filename;
15 if(std::system(command.c_str()) != 0) {
16 throw std::runtime_error(command +
"failed");
23 std::cout <<
"generateCacheFile: " << cacheFile << std::endl;
25 std::string xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
26 "<catalogue version=\"1.0\">"
28 " <name>/DUMMY</name>\n"
29 " <length>1</length>\n"
30 " <access_mode></access_mode>\n"
31 " <doocs_type_id>1</doocs_type_id>\n"
32 " <!--doocs id: INT-->\n"
35 std::ofstream o(cacheFile);
47 std::string address =
"(doocs:doocs://localhost:212/F/D/L?cacheFile=" + cacheFile +
")";
48 auto d = ChimeraTK::Device(address);
49 auto catalogue = d.getRegisterCatalogue();
51 BOOST_CHECK(catalogue.hasRegister(
"/DUMMY"));
54 deleteFile(cacheFile);
64 std::string address =
"(doocs:doocs://localhost:212/F/D/L?cacheFile=" + cacheFile +
")";
65 auto d = ChimeraTK::Device(address);
66 auto catalogue = d.getRegisterCatalogue();
68 BOOST_CHECK(catalogue.hasRegister(
"/DUMMY"));
71 auto acc = d.getOneDRegisterAccessor<std::string>(
"DUMMY");
72 BOOST_CHECK(acc.getNElements() == 1);
73 BOOST_CHECK_THROW(acc.read(), ChimeraTK::logic_error);
77 deleteFile(cacheFile);