test_server_options.cpp
Go to the documentation of this file.
1 
13 
14 #include <algorithm>
15 #include <gtest/gtest.h>
16 
17 #ifndef TEST_CORE_CONFIG_PATH
18 #define TEST_CORE_CONFIG_PATH "./tests/core/configs/"
19 #endif
20 
21 const char * TestConfigFile = TEST_CORE_CONFIG_PATH "test.conf";
23 
24 TEST(ServerOptions, ParsesCommandLine)
25 {
26  const char * argv[4] = { "test.exe", "--config=" TEST_CORE_CONFIG_PATH, "--log-file=/path/to/log/server.log", "--daemon" };
27  OpcUa::Server::CommandLine cmdline(4, argv);
28  EXPECT_EQ(cmdline.GetLogFile(), "/path/to/log/server.log");
30  EXPECT_TRUE(cmdline.IsDaemonMode());
31 }
32 
33 
34 TEST(ServerOptions, ParsesConfigurationFiles)
35 {
37  std::vector<Common::AddonInformation> addons(config.Modules.size());
38  std::transform(std::begin(config.Modules), std::end(config.Modules), std::begin(addons), [](const Common::ModuleConfiguration & module)
39  {
40  return Common::GetAddonInfomation(module);
41  });
42 
43  ASSERT_EQ(addons.size(), 1);
44  const Common::AddonInformation & module = addons.front();
45  ASSERT_EQ(module.Id, "child_module");
46  //ASSERT_EQ(module.Path, "child_module.so");
47  ASSERT_EQ(module.Dependencies.size(), 2);
48  ASSERT_EQ(module.Dependencies[0], "parent_module1");
49  ASSERT_EQ(module.Dependencies[1], "parent_module2");
50 
51  ASSERT_EQ(module.Parameters.Parameters.size(), 5);
52  ASSERT_EQ(module.Parameters.Parameters[0].Name, "application_name");
53  ASSERT_EQ(module.Parameters.Parameters[0].Value, "Test OPC UA Server");
54 
55  ASSERT_EQ(module.Parameters.Groups.size(), 2);
56  ASSERT_EQ(module.Parameters.Groups[0].Name, "user_token_policy");
57  ASSERT_EQ(module.Parameters.Groups[0].Parameters.size(), 3);
58  ASSERT_EQ(module.Parameters.Groups[0].Parameters[0].Name, "id");
59  ASSERT_EQ(module.Parameters.Groups[0].Parameters[0].Value, "anonymous");
60  ASSERT_EQ(module.Parameters.Groups[0].Parameters[1].Name, "type");
61  ASSERT_EQ(module.Parameters.Groups[0].Parameters[1].Value, "anonymous");
62 }
63 
Configuration ParseConfigurationFiles(const std::string &directory)
#define EXPECT_TRUE(condition)
std::string GetLogFile() const
const char * TestConfigPath
#define TEST_CORE_CONFIG_PATH
Test of class UaServer::CommandLine. GNU LGPL.
const char * TestConfigFile
std::string GetConfigDir() const
#define ASSERT_EQ(val1, val2)
TEST(ServerOptions, ParsesCommandLine)
std::vector< ModuleConfiguration > Modules
Definition: config_file.h:32
#define EXPECT_EQ(expected, actual)


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:08