ChimeraTK-ControlSystemAdapter-OPCUAAdapter 04.00.05
Loading...
Searching...
No Matches
test_csa_opcua_adapter.cpp
Go to the documentation of this file.
1#include <boost/test/included/unit_test.hpp>
2
3#include <csa_opcua_adapter.h>
4#include <test_sample_data.h>
5
6#include <iostream>
7
8extern "C" {
9#include "unistd.h"
10}
11
12using namespace boost::unit_test_framework;
13using namespace std;
14
16 public:
17 static void testWithoutPVSet();
18
19 static void testWithPVSet();
20};
21
23 cout << "Enter CSAOPCUATest without any pv" << std::endl;
24 TestFixtureEmptySet tfEmptySet;
25 // Create the managers
26 csa_opcua_adapter csaOPCUA(tfEmptySet.csManager, "uamapping_test_1.xml");
27
28 // is Server running?
30 while(!csaOPCUA.getUAAdapter()->running) {
31 }
32 BOOST_CHECK(csaOPCUA.isRunning());
33 BOOST_CHECK(csaOPCUA.getUAAdapter()->running);
34 // is csManager init
35 BOOST_CHECK(csaOPCUA.getControlSystemManager()->getAllProcessVariables().size() == 0);
36
37 csaOPCUA.stop();
38 BOOST_CHECK(!csaOPCUA.isRunning());
39}
40
42 std::cout << "Enter CSAOPCUATest with ExampleSet" << std::endl;
43 TestFixturePVSet tfExampleSet;
44 csa_opcua_adapter csaOPCUA(tfExampleSet.csManager, "../tests/uamapping_test_2.xml");
46 BOOST_CHECK(csaOPCUA.isRunning());
47 while(!csaOPCUA.getUAAdapter()->running) {
48 }
49 BOOST_CHECK(csaOPCUA.getUAAdapter()->running);
50 // is csManager init
51 BOOST_CHECK(csaOPCUA.getControlSystemManager()->getAllProcessVariables().size() == 21);
52
53 BOOST_CHECK(csaOPCUA.getUAAdapter() != NULL);
54
55 csaOPCUA.stop();
56 BOOST_CHECK(!csaOPCUA.isRunning());
57}
58
62class CSAOPCUATestSuite : public test_suite {
63 public:
64 CSAOPCUATestSuite() : test_suite("csa_opcua_adapter Test Suite") {
65 add(BOOST_TEST_CASE(&CSAOPCUATest::testWithoutPVSet));
66 add(BOOST_TEST_CASE(&CSAOPCUATest::testWithPVSet));
67 }
68};
69
70test_suite* init_unit_test_suite(int /*argc*/, char** /*argv[]*/) {
71 framework::master_test_suite().add(new CSAOPCUATestSuite);
72 return 0;
73}
static void testWithPVSet()
static void testWithoutPVSet()
The boost test suite which executes the ProcessVariableTest.
This class provide the two parts of the OPCUA Adapter.
bool isRunning()
Checks if the opcua server is still running and return the suitable bool value.
void start()
Start all objects in single threads for this case only the opc ua server.
std::shared_ptr< ua_uaadapter > getUAAdapter()
Return the uaadapter, hence the OPC UA server.
void stop()
Stop all objects in single threads for this case only the opc ua server.
boost::shared_ptr< ControlSystemPVManager > const & getControlSystemManager() const
Return the ControlsystemPVManager of the class.
csa_opcua_adapter * csaOPCUA
boost::shared_ptr< ControlSystemPVManager > csManager
boost::shared_ptr< ControlSystemPVManager > csManager
test_suite * init_unit_test_suite(int, char **)