--- /dev/null
+#include "module/plugin/PluginSession.h"
+#include "module/AbstractModule.h"
+#include "ConfigException.h"
+
+#include "gtest/gtest.h"
+
+#define STRING(s) _STRING(s)
+#define _STRING(s) #s
+
+using namespace nncc::contrib;
+using namespace nncc::contrib::config;
+using namespace nncc::contrib::plugin;
+using namespace nncc::contrib::module;
+using namespace nncc::contrib::module::plugin;
+
+class ConcreteModule : public AbstractModule
+{
+public:
+ ConcreteModule():AbstractModule() {}
+ ConcreteModule(PluginType moduleType):AbstractModule(moduleType) {}
+};
+
+std::shared_ptr<PluginProxy> createPluginProxy()
+{
+ std::shared_ptr<PluginProxy> pp = PluginProxy::create(STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH));
+ std::shared_ptr<AbstractSession> session = std::make_shared<PluginSession>();
+ pp->getPluginInstance().setSession(session);
+ pp->getPluginInstance().fillSession();
+ return pp;
+}
+
+// Test AbstractModule with wrong config
+TEST(CONTRIB_NNC, AbstractModuleWrongConfig)
+{
+ // Default constructor
+ ConcreteModule pluginModuleDefault;
+ ASSERT_THROW(pluginModuleDefault.execute(nullptr), ConfigException);
+
+ // Constructor(PluginType)
+ ConcreteModule pluginModule(PluginType::typeFrontEnd);
+ ASSERT_EQ(pluginModule.getModuleType(), PluginType::typeFrontEnd);
+
+ // 'configure' method for Module without plugins
+ ASSERT_THROW(pluginModule.configure(std::make_shared<DataList>("DataListName")), ConfigException);
+
+ // Register PluginProxy
+ auto pp = createPluginProxy();
+ pluginModule.registerPlugin(pp);
+
+ // 'configure' method with missing required plugin paramether
+ std::shared_ptr<DataList> config = std::make_shared<DataList>("DataListName");
+ ASSERT_THROW(pluginModule.configure(config), ConfigException);
+}
+
+// Test AbstractModule with correct config
+TEST(CONTRIB_NNC, AbstractModule)
+{
+ ConcreteModule pluginModule(PluginType::typeFrontEnd);
+
+ // Register PluginProxy
+ auto pp1 = createPluginProxy();
+ auto pp2 = createPluginProxy();
+ pluginModule.registerPlugin(pp1);
+ pluginModule.registerPlugin(pp2);
+
+ // 'configure' method
+ std::shared_ptr<DataList> config = std::make_shared<DataList>("DataListName");
+ config->createElement("filename", "samplePluginName");
+ config->createElement("someoption");
+ pluginModule.configure(config);
+ int x;
+ ASSERT_EQ(pluginModule.execute((void*)&x), (void*)&x);
+
+ // Operator '<<'
+ std::ostringstream os;
+ os << pluginModule;
+ ASSERT_EQ(os.str(), "=== MODULE FrontEnd ===\nplugins {\n "
+ STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH) "\n "
+ STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH) "\n}\n");
+}