AUX_SOURCE_DIRECTORY(src AITT_SRC)
-ADD_LIBRARY(M_LOADER_OBJ OBJECT src/TransportModuleLoader.cc)
-LIST(REMOVE_ITEM AITT_SRC src/TransportModuleLoader.cc)
+ADD_LIBRARY(M_LOADER_OBJ OBJECT src/ModuleLoader.cc src/NullTransport.cc)
+LIST(REMOVE_ITEM AITT_SRC src/ModuleLoader.cc src/NullTransport.cc)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${AITT_SRC} $<TARGET_OBJECTS:M_LOADER_OBJ>)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} Threads::Threads ${CMAKE_DL_LIBS} ${AITT_COMMON})
*/
#pragma once
+#include <AITTEx.h>
#include <AittTypes.h>
#include <MSG.h>
-/*\r
- * Copyright (c) 2021-2022 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-#pragma once\r
-\r
-#include <exception>\r
-#include <string>\r
-#include <vector>\r
-\r
-namespace aitt {\r
-\r
-class AITTEx : public std::exception {\r
- public:\r
- typedef enum {\r
- INVALID_ARG,\r
- NO_MEMORY,\r
- OPERATION_FAILED,\r
- SYSTEM_ERR,\r
- MQTT_ERR,\r
- NO_DATA\r
- } ErrCode;\r
-\r
- AITTEx(ErrCode err_code);\r
- AITTEx(ErrCode err_code, const std::string& custom_err_msg);\r
-\r
- ErrCode getErrCode();\r
- virtual const char* what() const throw() override;\r
-\r
- private:\r
- ErrCode err_code;\r
- std::string err_msg;\r
-\r
- std::string getErrString() const;\r
-};\r
-\r
-} // namespace aitt\r
-\r
+/*
+ * Copyright (c) 2021-2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <exception>
+#include <string>
+#include <vector>
+
+namespace aitt {
+
+class AITTEx : public std::exception {
+ public:
+ typedef enum {
+ INVALID_ARG,
+ NO_MEMORY,
+ OPERATION_FAILED,
+ SYSTEM_ERR,
+ MQTT_ERR,
+ NO_DATA
+ } ErrCode;
+
+ AITTEx(ErrCode err_code);
+ AITTEx(ErrCode err_code, const std::string& custom_err_msg);
+
+ ErrCode getErrCode();
+ virtual const char* what() const throw() override;
+
+ private:
+ ErrCode err_code;
+ std::string err_msg;
+
+ std::string getErrString() const;
+};
+
+} // namespace aitt
namespace aitt {
AITT::Impl::Impl(AITT &parent, const std::string &id, const std::string &ipAddr, bool clearSession)
- : public_api(parent),
- id_(id),
- mq(id, clearSession),
- discovery(id),
- reply_id(0),
- modules(ipAddr)
+ : public_api(parent), id_(id), mq(id, clearSession), discovery(id), reply_id(0)
{
// TODO:
// Validate ipAddr
-
+ ModuleLoader loader(ipAddr);
+ for (ModuleLoader::Type i = ModuleLoader::TYPE_MQTT; i < ModuleLoader::TYPE_MAX;
+ i = ModuleLoader::Type(i + 1)) {
+ ModuleLoader::ModuleHandle handle = loader.OpenModule(i);
+ if (handle == nullptr)
+ ERR("OpenModule() Fail");
+
+ modules[i] =
+ new ModuleObj(std::move(handle), loader.LoadTransport(handle.get(), discovery));
+ }
aittThread = std::thread(&AITT::Impl::ThreadMain, this);
}
if (aittThread.joinable())
aittThread.join();
+
+ for (ModuleLoader::Type i = ModuleLoader::TYPE_MQTT; i < ModuleLoader::TYPE_MAX;
+ i = ModuleLoader::Type(i + 1)) {
+ delete modules[i];
+ }
}
void AITT::Impl::ThreadMain(void)
void AITT::Impl::Connect(const std::string &host, int port, const std::string &username,
const std::string &password)
{
- modules.Init(discovery);
-
discovery.Start(host, port, username, password);
mq.Connect(host, port, username, password);
case AITT_TYPE_MQTT:
mq.Unsubscribe(subscribe_info->second);
break;
-
case AITT_TYPE_TCP:
+ GetTransport(ModuleLoader::TYPE_TCP)->Unsubscribe(subscribe_info->second);
+ break;
case AITT_TYPE_WEBRTC:
- modules.GetInstance(subscribe_info->first)->Unsubscribe(subscribe_info->second);
+ GetTransport(ModuleLoader::TYPE_WEBRTC)->Unsubscribe(subscribe_info->second);
break;
default:
subscribed_list.clear();
}
+inline std::shared_ptr<AittTransport> AITT::Impl::GetTransport(ModuleLoader::Type type)
+{
+ return modules[type]->second;
+}
+
void AITT::Impl::ConfigureTransportModule(const std::string &key, const std::string &value,
AittProtocol protocols)
{
if ((protocols & AITT_TYPE_MQTT) == AITT_TYPE_MQTT)
mq.Publish(topic, data, datalen, qos, retain);
- // NOTE:
- // Invoke the publish method of the specified transport module
- if ((protocols & AITT_TYPE_TCP) == AITT_TYPE_TCP) {
- auto tcpModule = modules.GetInstance(AITT_TYPE_TCP);
- tcpModule->Publish(topic, data, datalen, qos, retain);
- }
- if ((protocols & AITT_TYPE_WEBRTC) == AITT_TYPE_WEBRTC) {
+ if ((protocols & AITT_TYPE_TCP) == AITT_TYPE_TCP)
+ GetTransport(ModuleLoader::TYPE_TCP)->Publish(topic, data, datalen, qos, retain);
+
+ if ((protocols & AITT_TYPE_WEBRTC) == AITT_TYPE_WEBRTC)
PublishWebRtc(topic, data, datalen, qos, retain);
- }
}
void AITT::Impl::PublishWebRtc(const std::string &topic, const void *data, const size_t datalen,
AittQoS qos, bool retain)
{
- auto webrtcModule = modules.GetInstance(AITT_TYPE_WEBRTC);
+ auto webrtcModule = GetTransport(ModuleLoader::TYPE_WEBRTC);
flexbuffers::Builder fbb;
fbb.Map([=, &fbb]() {
fbb.String("Id", id_ + WEBRTC_ID_POSTFIX);
void *AITT::Impl::Unsubscribe(AittSubscribeID subscribe_id)
{
- INFO("[%s] %p", __func__, subscribe_id);
+ INFO("subscribe_id : %p", subscribe_id);
SubscribeInfo *info = reinterpret_cast<SubscribeInfo *>(subscribe_id);
std::unique_lock<std::mutex> lock(subscribed_list_mutex_);
user_data = mq.Unsubscribe(found_info->second);
break;
case AITT_TYPE_TCP: {
- auto tcpModule = modules.GetInstance(AITT_TYPE_TCP);
+ auto tcpModule = GetTransport(ModuleLoader::TYPE_TCP);
user_data = tcpModule->Unsubscribe(found_info->second);
break;
}
case AITT_TYPE_WEBRTC: {
- auto webrtcModule = modules.GetInstance(AITT_TYPE_WEBRTC);
+ auto webrtcModule = GetTransport(ModuleLoader::TYPE_WEBRTC);
user_data = webrtcModule->Unsubscribe(found_info->second);
break;
}
void *AITT::Impl::SubscribeTCP(SubscribeInfo *handle, const std::string &topic,
const SubscribeCallback &cb, void *user_data, AittQoS qos)
{
- auto tcpModule = modules.GetInstance(AITT_TYPE_TCP);
+ auto tcpModule = GetTransport(ModuleLoader::TYPE_TCP);
return tcpModule->Subscribe(
topic,
[handle, cb](const std::string &topic, const void *data, const size_t datalen,
void *AITT::Impl::SubscribeWebRtc(SubscribeInfo *handle, const std::string &topic,
const SubscribeCallback &cb, void *user_data, AittQoS qos)
{
- auto webrtc_module = modules.GetInstance(AITT_TYPE_WEBRTC);
+ auto webrtc_module = GetTransport(ModuleLoader::TYPE_WEBRTC);
flexbuffers::Builder fbb;
fbb.Map([=, &fbb]() {
fbb.String("Id", id_ + WEBRTC_ID_POSTFIX);
#include "AittDiscovery.h"
#include "MQ.h"
#include "MainLoopHandler.h"
-#include "TransportModuleLoader.h"
+#include "ModuleLoader.h"
namespace aitt {
private:
using Blob = std::pair<const void *, int>;
using SubscribeInfo = std::pair<AittProtocol, void *>;
+ using ModuleObj = std::pair<ModuleLoader::ModuleHandle, std::shared_ptr<AittTransport>>;
void ConnectionCB(ConnectionCallback cb, void *user_data, int status);
AittSubscribeID SubscribeMQ(SubscribeInfo *info, MainLoopHandler *loop_handle,
void PublishWebRtc(const std::string &topic, const void *data, const size_t datalen,
AittQoS qos, bool retain);
void UnsubscribeAll();
+ std::shared_ptr<AittTransport> GetTransport(ModuleLoader::Type type);
AITT &public_api;
std::string id_;
MQ mq;
AittDiscovery discovery;
unsigned short reply_id;
- TransportModuleLoader modules;
+ ModuleObj *modules[ModuleLoader::TYPE_MAX];
MainLoopHandler main_loop;
void ThreadMain(void);
std::thread aittThread;
--- /dev/null
+/*
+ * Copyright (c) 2021-2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ModuleLoader.h"
+
+#include <dlfcn.h>
+
+#include "AITTEx.h"
+#include "NullTransport.h"
+#include "aitt_internal.h"
+
+namespace aitt {
+
+ModuleLoader::ModuleLoader(const std::string &ip) : ip(ip)
+{
+}
+
+std::string ModuleLoader::GetModuleFilename(Type type)
+{
+ if (type == TYPE_TCP)
+ return "libaitt-transport-tcp.so";
+ if (type == TYPE_WEBRTC)
+ return "libaitt-transport-webrtc.so";
+
+ return std::string("Unknown");
+}
+
+ModuleLoader::ModuleHandle ModuleLoader::OpenModule(Type type)
+{
+ std::string filename = GetModuleFilename(type);
+
+ ModuleHandle handle(dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL),
+ [](const void *handle) -> void {
+ if (dlclose(const_cast<void *>(handle)))
+ ERR("dlclose: %s", dlerror());
+ });
+ if (handle == nullptr)
+ ERR("dlopen: %s", dlerror());
+
+ return handle;
+}
+
+std::shared_ptr<AittTransport> ModuleLoader::LoadTransport(void *handle, AittDiscovery &discovery)
+{
+ AittTransport::ModuleEntry get_instance_fn = reinterpret_cast<AittTransport::ModuleEntry>(
+ dlsym(handle, AittTransport::MODULE_ENTRY_NAME));
+ if (get_instance_fn == nullptr) {
+ ERR("dlsym: %s", dlerror());
+ return std::shared_ptr<AittTransport>(new NullTransport(ip.c_str(), discovery));
+ }
+
+ std::shared_ptr<AittTransport> instance(
+ static_cast<AittTransport *>(get_instance_fn(ip.c_str(), discovery)),
+ [](const AittTransport *instance) -> void { delete instance; });
+ if (instance == nullptr) {
+ ERR("Failed to create a new instance");
+ return std::shared_ptr<AittTransport>(new NullTransport(ip.c_str(), discovery));
+ }
+
+ return instance;
+}
+
+} // namespace aitt
#include <mutex>
#include <string>
-#include "TransportModuleLoader.h"
+#include "ModuleLoader.h"
namespace aitt {
-class TransportModuleLoader {
+class ModuleLoader {
public:
- explicit TransportModuleLoader(const std::string &ip);
- virtual ~TransportModuleLoader() = default;
+ enum Type {
+ TYPE_MQTT = 0,
+ TYPE_TCP,
+ TYPE_WEBRTC,
+ TYPE_RTSP,
+ TYPE_MAX,
+ };
- void Init(AittDiscovery &discovery);
- std::shared_ptr<AittTransport> GetInstance(AittProtocol protocol);
+ using ModuleHandle = std::unique_ptr<void, void (*)(const void *)>;
- private:
- using Handler = std::unique_ptr<void, void (*)(const void *)>;
- using ModuleMap = std::map<AittProtocol, std::pair<Handler, std::shared_ptr<AittTransport>>>;
+ explicit ModuleLoader(const std::string &ip);
+ virtual ~ModuleLoader() = default;
+
+ ModuleHandle OpenModule(Type type);
+ std::shared_ptr<AittTransport> LoadTransport(void *handle, AittDiscovery &discovery);
- std::string GetModuleFilename(AittProtocol protocol);
- int LoadModule(AittProtocol protocol, AittDiscovery &discovery);
+ private:
+ std::string GetModuleFilename(Type type);
- ModuleMap module_table;
- std::mutex module_lock;
std::string ip;
};
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "NullTransport.h"
+
+#include "aitt_internal.h"
+
+NullTransport::NullTransport(const std::string& ip, AittDiscovery& discovery)
+ : AittTransport(discovery)
+{
+}
+
+void NullTransport::Publish(const std::string& topic, const void* data, const size_t datalen,
+ const std::string& correlation, AittQoS qos, bool retain)
+{
+}
+
+void NullTransport::Publish(const std::string& topic, const void* data, const size_t datalen,
+ AittQoS qos, bool retain)
+{
+}
+
+void* NullTransport::Subscribe(const std::string& topic, const SubscribeCallback& cb, void* cbdata,
+ AittQoS qos)
+{
+ return nullptr;
+}
+
+void* NullTransport::Subscribe(const std::string& topic, const SubscribeCallback& cb,
+ const void* data, const size_t datalen, void* cbdata, AittQoS qos)
+{
+ return nullptr;
+}
+
+void* NullTransport::Unsubscribe(void* handle)
+{
+ return nullptr;
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <AittTransport.h>
+using AittTransport = aitt::AittTransport;
+using AittDiscovery = aitt::AittDiscovery;
+
+class NullTransport : public AittTransport {
+ public:
+ explicit NullTransport(const std::string &ip, AittDiscovery &discovery);
+ virtual ~NullTransport(void) = default;
+
+ void Publish(const std::string &topic, const void *data, const size_t datalen,
+ const std::string &correlation, AittQoS qos = AITT_QOS_AT_MOST_ONCE,
+ bool retain = false) override;
+
+ void Publish(const std::string &topic, const void *data, const size_t datalen,
+ AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) override;
+
+ void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *cbdata = nullptr,
+ AittQoS qos = AITT_QOS_AT_MOST_ONCE) override;
+
+ void *Subscribe(const std::string &topic, const SubscribeCallback &cb, const void *data,
+ const size_t datalen, void *cbdata = nullptr,
+ AittQoS qos = AITT_QOS_AT_MOST_ONCE) override;
+
+ void *Unsubscribe(void *handle) override;
+};
+++ /dev/null
-/*
- * Copyright (c) 2021-2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "TransportModuleLoader.h"
-
-#include <dlfcn.h>
-
-#include "AITTEx.h"
-#include "aitt_internal.h"
-
-namespace aitt {
-
-TransportModuleLoader::TransportModuleLoader(const std::string &ip) : ip(ip)
-{
-}
-
-std::string TransportModuleLoader::GetModuleFilename(AittProtocol protocol)
-{
- // TODO:
- // We are able to generate the module name by a particular syntax,
- // It could be introduced later when we have several modules.
- if (protocol == AITT_TYPE_TCP)
- return "libaitt-transport-tcp.so";
- if (protocol == AITT_TYPE_WEBRTC)
- return "libaitt-transport-webrtc.so";
-
- return std::string();
-}
-
-int TransportModuleLoader::LoadModule(AittProtocol protocol, AittDiscovery &discovery)
-{
- std::string filename = GetModuleFilename(protocol);
-
- Handler handle(dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL),
- [](const void *handle) -> void {
- if (dlclose(const_cast<void *>(handle)))
- ERR("dlclose: %s", dlerror());
- });
- if (handle == nullptr) {
- ERR("dlopen: %s", dlerror());
- return -1;
- }
-
- AittTransport::ModuleEntry get_instance_fn = reinterpret_cast<AittTransport::ModuleEntry>(
- dlsym(handle.get(), AittTransport::MODULE_ENTRY_NAME));
- if (get_instance_fn == nullptr) {
- ERR("dlsym: %s", dlerror());
- return -1;
- }
-
- std::shared_ptr<AittTransport> instance(
- static_cast<AittTransport *>(get_instance_fn(ip.c_str(), discovery)),
- [](const AittTransport *instance) -> void { delete instance; });
- if (instance == nullptr) {
- ERR("Failed to create a new instance");
- return -1;
- }
-
- module_table.emplace(protocol, std::make_pair(std::move(handle), instance));
-
- return 0;
-}
-
-void TransportModuleLoader::Init(AittDiscovery &discovery)
-{
- std::lock_guard<std::mutex> lock_from_here(module_lock);
- if (LoadModule(AITT_TYPE_TCP, discovery) < 0) {
- ERR("LoadModule(AITT_TYPE_TCP) Fail");
- }
-
-#ifdef WITH_WEBRTC
- if (LoadModule(AITT_TYPE_WEBRTC, discovery) < 0) {
- ERR("LoadModule(AITT_TYPE_WEBRTC) Fail");
- }
-#endif // WITH_WEBRTC
-}
-
-std::shared_ptr<AittTransport> TransportModuleLoader::GetInstance(AittProtocol protocol)
-{
- std::lock_guard<std::mutex> lock_from_here(module_lock);
-
- auto item = module_table.find(protocol);
- if (item == module_table.end()) {
- ERR("Not Initialized");
- // throw AITTEx(AITTEx::NO_DATA, "Not Initialized");
- return nullptr;
- }
-
- return item->second.second;
-}
-
-} // namespace aitt
aitt.Connect();
aitt.Publish(testTopic, TEST_MSG, sizeof(TEST_MSG),
(AittProtocol)(AITT_TYPE_MQTT | AITT_TYPE_TCP));
+ aitt.Publish(testTopic, TEST_MSG, sizeof(TEST_MSG),
+ (AittProtocol)(AITT_TYPE_MQTT | AITT_TYPE_TCP | AITT_TYPE_WEBRTC));
} catch (std::exception &e) {
FAIL() << "Unexpected exception: " << e.what();
}
}
-TEST_F(AITTTest, Positive_Subscribe_Anytime)
+TEST_F(AITTTest, Positive_Subscribe_WebRTC_Anytime)
{
try {
AITT aitt(clientId, LOCAL_IP, true);
aitt.Subscribe(
testTopic,
[](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void {},
- nullptr, AITT_TYPE_TCP);
+ nullptr, AITT_TYPE_WEBRTC);
} catch (std::exception &e) {
FAIL() << "Unexpected exception: " << e.what();
}
)
###########################################################################
-ADD_EXECUTABLE(${AITT_UT}_module TransportModuleLoader_test.cc $<TARGET_OBJECTS:M_LOADER_OBJ>)
+ADD_EXECUTABLE(${AITT_UT}_module ModuleLoader_test.cc $<TARGET_OBJECTS:M_LOADER_OBJ>)
TARGET_LINK_LIBRARIES(${AITT_UT}_module ${UT_NEEDS_LIBRARIES} ${AITT_NEEDS_LIBRARIES} ${CMAKE_DL_LIBS} ${AITT_COMMON})
TARGET_INCLUDE_DIRECTORIES(${AITT_UT}_module PRIVATE ../src)
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "TransportModuleLoader.h"
+#include "ModuleLoader.h"
#include <AITT.h>
#include <gtest/gtest.h>
#include "AittTransport.h"
#include "aitt_internal.h"
-class TransportModuleLoaderTest : public testing::Test {
+using ModuleLoader = aitt::ModuleLoader;
+
+class ModuleLoaderTest : public testing::Test {
public:
- TransportModuleLoaderTest(void) : discovery("test"), loader("127.0.0.1")
- {
- loader.Init(discovery);
- }
+ ModuleLoaderTest(void) : discovery("test"), loader("127.0.0.1") {}
protected:
void SetUp() override {}
void TearDown() override {}
aitt::AittDiscovery discovery;
- aitt::TransportModuleLoader loader;
+ aitt::ModuleLoader loader;
};
-TEST_F(TransportModuleLoaderTest, Positive_GetInstance_Anytime)
+TEST_F(ModuleLoaderTest, Positive_LoadTransport_Anytime)
{
- std::shared_ptr<aitt::AittTransport> module = loader.GetInstance(AITT_TYPE_TCP);
+ ModuleLoader::ModuleHandle handle = loader.OpenModule(ModuleLoader::TYPE_TCP);
+ ASSERT_NE(handle, nullptr);
+
+ std::shared_ptr<aitt::AittTransport> module = loader.LoadTransport(handle.get(), discovery);
ASSERT_NE(module, nullptr);
}
-TEST_F(TransportModuleLoaderTest, Negative_GetInstance_Anytime)
+TEST_F(ModuleLoaderTest, Negative_LoadTransport_Anytime)
{
- std::shared_ptr<aitt::AittTransport> module = loader.GetInstance(AITT_TYPE_MQTT);
- ASSERT_EQ(module, nullptr);
+ ModuleLoader::ModuleHandle handle = loader.OpenModule(ModuleLoader::TYPE_MQTT);
+ ASSERT_EQ(handle.get(), nullptr);
+
+ auto module = loader.LoadTransport(handle.get(), discovery);
+ ASSERT_NE(module, nullptr);
}