void managerErr2()
{
- try
+ try
{
managerErr1();
}
- catch (PluginManagerException &e)
+ catch (PluginManagerException &e)
{
throw PluginManagerException(e, managerErrorMsg2);
}
TEST(CONTRIB_NNC, PluginManagerException)
{
- try
+ try
{
managerErr2();
}
- catch (PluginManagerException &e)
+ catch (PluginManagerException &e)
{
ASSERT_TRUE(managerErrorMsgs == e.getInfo());
return;
// should not happen
FAIL();
}
+
+// PluginManager class
+
+// Test 'getInstance()' method
+TEST(CONTRIB_NNC, PluginManagerGetInstance)
+{
+ PluginManager &pluginManager = PluginManager::getInstance();
+ ASSERT_NE(&pluginManager, nullptr);
+ PluginManager &pluginManager2 = PluginManager::getInstance();
+ ASSERT_EQ(&pluginManager, &pluginManager2);
+}
+
+// Test PluginManager loading with unexisting path
+TEST(CONTRIB_NNC, PluginManagerMissingDir)
+{
+ PluginManager &pluginManager = PluginManager::getInstance();
+
+ auto params = std::make_shared<config::DataList>(config::DataList("PluginManagerParams"));
+ params->createElement(PluginManager::paramPluginPath, "some very missing path");
+ pluginManager.setConfig(params);
+
+ std::vector<module::AbstractModule *> modules;
+ ASSERT_THROW(pluginManager.loadPlugins(modules), PluginManagerException);
+}
+
+// Test PluginManager work with correct configuration
+TEST(CONTRIB_NNC, PluginManager)
+{
+ PluginManager &pluginManager = PluginManager::getInstance();
+
+ auto params = std::make_shared<config::DataList>(config::DataList("PluginManagerParams"));
+ params->createElement(PluginManager::paramPluginPath, STRING(CMAKE_SAMPLE_PLUGIN_DIR_ABS_PATH));
+ params->createElement(PluginManager::paramVerboseLoading);
+ params->createElement(PluginManager::paramPluginHelp);
+ pluginManager.setConfig(params);
+
+ std::vector<module::AbstractModule *> modules;
+ modules.push_back(&module::FrontendModule::getInstance());
+ modules.push_back(&module::BackendModule::getInstance());
+ pluginManager.loadPlugins(modules);
+
+ // Test operator '<<'
+ std::ostringstream os;
+ os << pluginManager;
+ std::string pluginsOrder1(STRING(CMAKE_SAMPLE_PLUGIN_2_ABS_PATH) "\n"
+ STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH) "\n");
+ std::string pluginsOrder2(STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH) "\n"
+ STRING(CMAKE_SAMPLE_PLUGIN_2_ABS_PATH) "\n");
+ EXPECT_TRUE(os.str() == pluginsOrder1 || os.str() == pluginsOrder2);
+}