ChimeraTK-ControlSystemAdapter-OPCUAAdapter  04.00.01
test_csa_opcua_adapter.cpp
Go to the documentation of this file.
1 #include <csa_opcua_adapter.h>
2 #include <test_sample_data.h>
3 
4 #include <boost/test/included/unit_test.hpp>
5 
6 #include <iostream>
7 
8 extern "C" {
9 #include "unistd.h"
10 }
11 
12 using namespace boost::unit_test_framework;
13 using namespace std;
14 
15 class CSAOPCUATest {
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?
29  csaOPCUA.start();
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");
45  csaOPCUA.start();
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 
62 class 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 
70 test_suite* init_unit_test_suite(int /*argc*/, char** /*argv[]*/) {
71  framework::master_test_suite().add(new CSAOPCUATestSuite);
72  return 0;
73 }
ChimeraTK::csa_opcua_adapter
This class provide the two parts of the OPCUA Adapter. First of all the OPCUA server starts with a po...
Definition: csa_opcua_adapter.h:44
csa_opcua_adapter.h
ChimeraTK::csa_opcua_adapter::stop
void stop()
Stop all objects in single threads for this case only the opc ua server.
Definition: csa_opcua_adapter.cpp:216
CSAOPCUATestSuite
The boost test suite which executes the ProcessVariableTest.
Definition: test_csa_opcua_adapter.cpp:62
ChimeraTK::csa_opcua_adapter::isRunning
bool isRunning()
Checks if the opcua server is still running and return the suitable bool value.
Definition: csa_opcua_adapter.cpp:226
CSAOPCUATestSuite::CSAOPCUATestSuite
CSAOPCUATestSuite()
Definition: test_csa_opcua_adapter.cpp:64
TestFixturePVSet
Definition: test_sample_data.h:33
TestFixtureEmptySet::csManager
boost::shared_ptr< ControlSystemPVManager > csManager
Definition: test_sample_data.h:24
CSAOPCUATest::testWithoutPVSet
static void testWithoutPVSet()
Definition: test_csa_opcua_adapter.cpp:22
TestFixturePVSet::csManager
boost::shared_ptr< ControlSystemPVManager > csManager
Definition: test_sample_data.h:35
ChimeraTK::csa_opcua_adapter::getUAAdapter
std::shared_ptr< ua_uaadapter > getUAAdapter()
Return the uaadapter, hence the OPC UA server.
Definition: csa_opcua_adapter.cpp:176
CSAOPCUATest
Definition: test_csa_opcua_adapter.cpp:15
csaOPCUA
csa_opcua_adapter * csaOPCUA
Definition: csa_opcua_adapter_example.cpp:43
ChimeraTK::csa_opcua_adapter::start
void start()
Start all objects in single threads for this case only the opc ua server.
Definition: csa_opcua_adapter.cpp:180
test_sample_data.h
TestFixtureEmptySet
Definition: test_sample_data.h:22
CSAOPCUATest::testWithPVSet
static void testWithPVSet()
Definition: test_csa_opcua_adapter.cpp:41
ChimeraTK::csa_opcua_adapter::getControlSystemManager
boost::shared_ptr< ControlSystemPVManager > const & getControlSystemManager() const
Return the ControlsystemPVManager of the class.
Definition: csa_opcua_adapter.cpp:172
init_unit_test_suite
test_suite * init_unit_test_suite(int, char **)
Definition: test_csa_opcua_adapter.cpp:70