Page MenuHomePhabricator

D3653.id11184.diff
No OneTemporary

D3653.id11184.diff

diff --git a/services/tunnelbroker/test/AmqpManagerTest.cpp b/services/tunnelbroker/test/AmqpManagerTest.cpp
new file mode 100644
--- /dev/null
+++ b/services/tunnelbroker/test/AmqpManagerTest.cpp
@@ -0,0 +1,39 @@
+#include "AmqpManager.h"
+#include "ConfigManager.h"
+#include "Constants.h"
+#include "DeliveryBroker.h"
+#include "Tools.h"
+
+#include <gtest/gtest.h>
+
+#include <string>
+#include <thread>
+
+using namespace comm::network;
+
+class DatabaseManagerTest : public testing::Test {
+protected:
+ virtual void SetUp() {
+ config::ConfigManager::getInstance().load();
+ std::thread amqpThread([]() { AmqpManager::getInstance().connect(); });
+ }
+};
+
+TEST_F(DatabaseManagerTest, TestOperationsOnSendAndReceive) {
+ const std::string messageID = tools::generateUUID();
+ const std::string toDeviceID =
+ "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH);
+ const std::string fromDeviceID =
+ "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH);
+ const std::string payload = tools::generateRandomString(512);
+ EXPECT_EQ(
+ AmqpManager::getInstance().send(
+ messageID, toDeviceID, fromDeviceID, payload),
+ true);
+ DeliveryBrokerMessage receivedMessage =
+ DeliveryBroker::getInstance().pop(toDeviceID);
+ EXPECT_EQ(messageID == receivedMessage.messageID, true);
+ EXPECT_EQ(fromDeviceID == receivedMessage.fromDeviceID, true);
+ EXPECT_EQ(payload == receivedMessage.payload, true);
+ AmqpManager::getInstance().ack(receivedMessage.deliveryTag);
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 8:25 PM (17 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2606012
Default Alt Text
D3653.id11184.diff (1 KB)

Event Timeline