Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3394539
D3653.id11184.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D3653.id11184.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D3653: [services] Tunnelbroker - AMQP tests
Attached
Detach File
Event Timeline
Log In to Comment