-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathtestFactory.cxx
More file actions
63 lines (52 loc) · 2.06 KB
/
testFactory.cxx
File metadata and controls
63 lines (52 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
///
/// \file testNonEmpty.cxx
/// \author Barthelemy von Haller
///
#include "QualityControl/ObjectsManager.h"
#include "QualityControl/TaskFactory.h"
#include <Common/Exceptions.h>
#include <TSystem.h>
#include <boost/exception/diagnostic_information.hpp>
#define BOOST_TEST_MODULE Publisher test
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
using namespace std;
namespace utf = boost::unit_test;
using namespace o2::quality_control::core;
namespace o2::quality_control_modules::example
{
BOOST_AUTO_TEST_CASE(Task_Factory)
{
TaskFactory factory;
TaskRunnerConfig config;
config.name = "task";
config.moduleName = "QcCommon";
config.className = "o2::quality_control_modules::example::ExampleTask";
config.detectorName = "DAQ";
config.ccdbUrl = "something";
auto manager = make_shared<ObjectsManager>(config.name, config.className, config.detectorName, 0);
try {
gSystem->AddDynamicPath("lib:../../lib:../../../lib:.:"); // add local paths for the test
factory.create(config, manager);
} catch (...) {
BOOST_TEST_FAIL(boost::current_exception_diagnostic_information());
}
}
bool is_critical(AliceO2::Common::FatalException const&) { return true; }
BOOST_AUTO_TEST_CASE(Task_Factory_failures, *utf::depends_on("Task_Factory") /* make sure we don't run both tests at the same time */)
{
TaskFactory factory;
TaskRunnerConfig config;
auto manager = make_shared<ObjectsManager>(config.name, config.className, config.detectorName, 0);
config.name = "task";
config.moduleName = "WRONGNAME";
config.className = "o2::quality_control_modules::example::ExampleTask";
BOOST_CHECK_EXCEPTION(factory.create(config, manager), AliceO2::Common::FatalException, is_critical);
gSystem->AddDynamicPath("lib:../../lib:../../../lib:"); // add local paths for the test
config.name = "task";
config.moduleName = "QcCommon";
config.className = "WRONGCLASS";
BOOST_CHECK_EXCEPTION(factory.create(config, manager), AliceO2::Common::FatalException, is_critical);
}
} // namespace o2::quality_control_modules::example