test_server_options.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #include <src/serverapp/server_options.h>
00012 #include <opc/common/addons_core/config_file.h>
00013 
00014 #include <algorithm>
00015 #include <gtest/gtest.h>
00016 
00017 #ifndef TEST_CORE_CONFIG_PATH
00018 #define TEST_CORE_CONFIG_PATH "./tests/core/configs/"
00019 #endif
00020 
00021 const char* TestConfigFile = TEST_CORE_CONFIG_PATH "test.conf";
00022 const char* TestConfigPath = TEST_CORE_CONFIG_PATH;
00023 
00024 TEST(ServerOptions, ParsesCommandLine)
00025 {
00026   const char* argv[4] = { "test.exe", "--config=" TEST_CORE_CONFIG_PATH, "--log-file=/path/to/log/server.log", "--daemon" };
00027   OpcUa::Server::CommandLine cmdline(4, argv);
00028   EXPECT_EQ(cmdline.GetLogFile(), "/path/to/log/server.log");
00029   EXPECT_EQ(cmdline.GetConfigDir(), TestConfigPath);
00030   EXPECT_TRUE(cmdline.IsDaemonMode());
00031 }
00032 
00033 
00034 TEST(ServerOptions, ParsesConfigurationFiles)
00035 {
00036   Common::Configuration config = Common::ParseConfigurationFiles(TestConfigPath);
00037   std::vector<Common::AddonInformation> addons(config.Modules.size());
00038   std::transform(std::begin(config.Modules), std::end(config.Modules), std::begin(addons), [](const Common::ModuleConfiguration& module){
00039     return Common::GetAddonInfomation(module);
00040   });
00041 
00042   ASSERT_EQ(addons.size(), 1);
00043   const Common::AddonInformation& module = addons.front();
00044   ASSERT_EQ(module.Id, "child_module");
00045   //ASSERT_EQ(module.Path, "child_module.so");
00046   ASSERT_EQ(module.Dependencies.size(), 2);
00047   ASSERT_EQ(module.Dependencies[0], "parent_module1");
00048   ASSERT_EQ(module.Dependencies[1], "parent_module2");
00049 
00050   ASSERT_EQ(module.Parameters.Parameters.size(), 5);
00051   ASSERT_EQ(module.Parameters.Parameters[0].Name, "application_name");
00052   ASSERT_EQ(module.Parameters.Parameters[0].Value, "Test OPC UA Server");
00053 
00054   ASSERT_EQ(module.Parameters.Groups.size(), 2);
00055   ASSERT_EQ(module.Parameters.Groups[0].Name, "user_token_policy");
00056   ASSERT_EQ(module.Parameters.Groups[0].Parameters.size(), 3);
00057   ASSERT_EQ(module.Parameters.Groups[0].Parameters[0].Name, "id");
00058   ASSERT_EQ(module.Parameters.Groups[0].Parameters[0].Value, "anonymous");
00059   ASSERT_EQ(module.Parameters.Groups[0].Parameters[1].Name, "type");
00060   ASSERT_EQ(module.Parameters.Groups[0].Parameters[1].Value, "anonymous");
00061 }
00062 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:57