From 9731edb16484921577323cad00aa3e51466217ec Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Fri, 17 Mar 2017 21:34:32 +0100 Subject: [PATCH] Cleanup and extending the data parsers for XML/JSON add example ClientTests/MiniTel_json --- examples/ClientTests/CMakeLists.txt | 12 +++++++++++- .../src_boost/{JsonTest.cpp => JsonDumper.cpp} | 11 +++++------ 2 files changed, 16 insertions(+), 7 deletions(-) rename examples/ClientTests/src_boost/{JsonTest.cpp => JsonDumper.cpp} (76%) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index 1a7733b4f..fa7a816f8 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -30,8 +30,18 @@ dd4hep_install_dir( compact scripts DESTINATION ${DD4hep_DIR}/examples/ClientTes dd4hep_configure_scripts( ClientTests DEFAULT_SETUP WITH_TESTS) #--- Testing ------------------------------------------------------------ # +# Test JSON based parser +dd4hep_add_test_reg( ClientTests_MiniTel_JSON_Dump + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" + EXEC_ARGS geoPluginRun -destroy -plugin DD4hep_JsonDumper + ${CMAKE_CURRENT_SOURCE_DIR}/compact/MiniTel.json + REGEX_PASS "Successfully dumped json input" + REGEX_FAIL "Exception" + REGEX_FAIL "FAILED" + ) +# # Test JSON based detector construction -dd4hep_add_test_reg( ClientTests_MiniTel_JSON +dd4hep_add_test_reg( ClientTests_MiniTel_JSON_Detector COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hepCompactLoader file:${CMAKE_CURRENT_SOURCE_DIR}/compact/MiniTel_json.xml diff --git a/examples/ClientTests/src_boost/JsonTest.cpp b/examples/ClientTests/src_boost/JsonDumper.cpp similarity index 76% rename from examples/ClientTests/src_boost/JsonTest.cpp rename to examples/ClientTests/src_boost/JsonDumper.cpp index 13cb089d9..471672bd3 100644 --- a/examples/ClientTests/src_boost/JsonTest.cpp +++ b/examples/ClientTests/src_boost/JsonDumper.cpp @@ -15,23 +15,22 @@ // Framework include files #include "JSON/Elements.h" #include "JSON/DocumentHandler.h" +#include "DD4hep/Printout.h" #include "DD4hep/Factories.h" -using namespace std; using namespace DD4hep; -using namespace DD4hep::JSON; -using namespace DD4hep::Geometry; -static long json_dump(LCDD& /* lcdd */, int argc, char** argv) { +static long json_dump(Geometry::LCDD& /* lcdd */, int argc, char** argv) { if ( argc < 1 ) { ::printf("DD4hep_JsonDumper <file> \n"); exit(EINVAL); } - DocumentHolder doc(JSON::DocumentHandler().load(argv[0])); + std::string fname = argv[0]; + JSON::DocumentHolder doc(JSON::DocumentHandler().load(fname)); dumpTree(doc.root()); + printout(INFO,"JsonDumper","+++ Successfully dumped json input: %s.",fname.c_str()); return 1; } - DECLARE_APPLY(DD4hep_JsonDumper,json_dump) #endif -- GitLab