File indexing completed on 2024-10-13 06:30:11

0001 /*
0002     File                 : MQTTUnitTest.cpp
0003     Project              : LabPlot
0004     Description          : Tests for MQTT related features
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2018 Kovacs Ferencz <kferike98@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include "MQTTUnitTest.h"
0012 
0013 #ifdef HAVE_MQTT
0014 #include "backend/core/Project.h"
0015 #include "backend/datasources/MQTTClient.h"
0016 #include "backend/datasources/MQTTSubscription.h"
0017 #include "backend/datasources/MQTTTopic.h"
0018 #include "backend/datasources/filters/AsciiFilter.h"
0019 #include "kdefrontend/dockwidgets/LiveDataDock.h"
0020 
0021 #include <QDebug>
0022 #include <QEventLoop>
0023 #include <QFile>
0024 #include <QTextStream>
0025 #include <QTimer>
0026 #include <QTreeWidgetItem>
0027 #include <QVector>
0028 
0029 void MQTTUnitTest::initTestCase() {
0030     const QString currentDir = QLatin1String(__FILE__);
0031     m_dataDir = currentDir.left(currentDir.lastIndexOf(QDir::separator())) + QDir::separator() + QLatin1String("data") + QDir::separator();
0032 
0033     // needed in order to have the signals triggered by SignallingUndoCommand, see LabPlot.cpp
0034     // TODO: redesign/remove this
0035     qRegisterMetaType<const AbstractAspect*>("const AbstractAspect*");
0036     qRegisterMetaType<const AbstractColumn*>("const AbstractColumn*");
0037 }
0038 
0039 // ##############################################################################
0040 // ###################  check superior and inferior relations  ##################
0041 // ##############################################################################
0042 void MQTTUnitTest::testContainFalse() {
0043     MQTTClient* client = new MQTTClient(QStringLiteral("test"));
0044     const QString fileName = m_dataDir + QStringLiteral("contain_false.txt");
0045     QFile file(fileName);
0046 
0047     if (file.open(QIODevice::ReadOnly)) {
0048         QTextStream in(&file);
0049 
0050         while (!in.atEnd()) {
0051             QString line = in.readLine();
0052 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
0053             QStringList topics = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
0054 #else
0055             QStringList topics = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
0056 #endif
0057             QCOMPARE(client->checkTopicContains(topics[0], topics[1]), false);
0058         }
0059 
0060         delete client;
0061         file.close();
0062     }
0063 }
0064 
0065 void MQTTUnitTest::testContainTrue() {
0066     MQTTClient* client = new MQTTClient(QStringLiteral("test"));
0067     const QString fileName = m_dataDir + QStringLiteral("contain_true.txt");
0068     QFile file(fileName);
0069 
0070     if (file.open(QIODevice::ReadOnly)) {
0071         QTextStream in(&file);
0072 
0073         while (!in.atEnd()) {
0074             QString line = in.readLine();
0075 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
0076             QStringList topics = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
0077 #else
0078             QStringList topics = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
0079 #endif
0080             QCOMPARE(client->checkTopicContains(topics[0], topics[1]), true);
0081         }
0082 
0083         delete client;
0084         file.close();
0085     }
0086 }
0087 
0088 // ##############################################################################
0089 // ############################  check common topics  ###########################
0090 // ##############################################################################
0091 void MQTTUnitTest::testCommonTrue() {
0092     MQTTClient* client = new MQTTClient(QStringLiteral("test"));
0093     const QString fileName = m_dataDir + QStringLiteral("common_true.txt");
0094     QFile file(fileName);
0095 
0096     if (file.open(QIODevice::ReadOnly)) {
0097         QTextStream in(&file);
0098 
0099         while (!in.atEnd()) {
0100             QString line = in.readLine();
0101 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
0102             QStringList topics = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
0103 #else
0104             QStringList topics = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
0105 #endif
0106             QCOMPARE(client->checkCommonLevel(topics[0], topics[1]), topics[2]);
0107         }
0108 
0109         delete client;
0110         file.close();
0111     }
0112 }
0113 
0114 void MQTTUnitTest::testCommonFalse() {
0115     MQTTClient* client = new MQTTClient(QStringLiteral("test"));
0116     const QString fileName = m_dataDir + QStringLiteral("common_false.txt");
0117     QFile file(fileName);
0118 
0119     if (file.open(QIODevice::ReadOnly)) {
0120         QTextStream in(&file);
0121 
0122         while (!in.atEnd()) {
0123             QString line = in.readLine();
0124 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
0125             QStringList topics = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
0126 #else
0127             QStringList topics = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
0128 #endif
0129             QCOMPARE(client->checkCommonLevel(topics[0], topics[1]), QString());
0130         }
0131 
0132         delete client;
0133         file.close();
0134     }
0135 }
0136 
0137 // ##############################################################################
0138 // #################  test handling of data received by messages  ###############
0139 // ##############################################################################
0140 void MQTTUnitTest::testIntegerMessage() {
0141     AsciiFilter* filter = new AsciiFilter();
0142     filter->setAutoModeEnabled(true);
0143 
0144     Project* project = new Project();
0145 
0146     MQTTClient* mqttClient = new MQTTClient(QStringLiteral("test"));
0147     project->addChild(mqttClient);
0148     mqttClient->setFilter(filter);
0149     mqttClient->setReadingType(MQTTClient::ReadingType::TillEnd);
0150     mqttClient->setKeepNValues(0);
0151     mqttClient->setUpdateType(MQTTClient::UpdateType::NewData);
0152     mqttClient->setMQTTClientHostPort(QStringLiteral("broker.hivemq.com"), 1883);
0153     mqttClient->setMQTTUseAuthentication(false);
0154     mqttClient->setMQTTUseID(false);
0155     QMqttTopicFilter topicFilter{QStringLiteral("labplot/mqttUnitTest")};
0156     mqttClient->addInitialMQTTSubscriptions(topicFilter, 0);
0157     mqttClient->read();
0158     mqttClient->ready();
0159 
0160     QMqttClient* client = new QMqttClient();
0161     client->setHostname(QStringLiteral("broker.hivemq.com"));
0162     client->setPort(1883);
0163     client->connectToHost();
0164 
0165     bool wait = QTest::qWaitFor(
0166         [&]() {
0167             return (client->state() == QMqttClient::Connected);
0168         },
0169         5000);
0170     QCOMPARE(wait, true);
0171 
0172     QMqttSubscription* subscription = client->subscribe(topicFilter, 0);
0173     if (subscription) {
0174         const QString fileName = m_dataDir + QStringLiteral("integer_message_1.txt");
0175         QFile file(fileName);
0176 
0177         if (file.open(QIODevice::ReadOnly)) {
0178             QTextStream in(&file);
0179             QString message = in.readAll();
0180             client->publish(topicFilter.filter(), message.toUtf8(), 0);
0181         }
0182         file.close();
0183 
0184         QTimer timer;
0185         timer.setSingleShot(true);
0186         QEventLoop* loop = new QEventLoop();
0187         connect(mqttClient, &MQTTClient::MQTTTopicsChanged, loop, &QEventLoop::quit);
0188         connect((&timer), &QTimer::timeout, loop, &QEventLoop::quit);
0189         timer.start(5000);
0190         loop->exec();
0191 
0192         const MQTTTopic* testTopic = nullptr;
0193 
0194         if (timer.isActive()) {
0195             QVector<const MQTTTopic*> topic = mqttClient->children<const MQTTTopic>(AbstractAspect::ChildIndexFlag::Recursive);
0196             for (const auto& top : topic) {
0197                 if (top->topicName() == QLatin1String("labplot/mqttUnitTest")) {
0198                     testTopic = top;
0199                     break;
0200                 }
0201             }
0202 
0203             if (testTopic) {
0204                 Column* value = testTopic->column(testTopic->columnCount() - 1);
0205                 QCOMPARE(value->columnMode(), Column::ColumnMode::Integer);
0206                 QCOMPARE(value->rowCount(), 3);
0207                 QCOMPARE(value->valueAt(0), 1);
0208                 QCOMPARE(value->valueAt(1), 2);
0209                 QCOMPARE(value->valueAt(2), 3);
0210 
0211                 const QString fileName2 = m_dataDir + QStringLiteral("integer_message_2.txt");
0212                 QFile file2(fileName2);
0213 
0214                 if (file2.open(QIODevice::ReadOnly)) {
0215                     QTextStream in2(&file2);
0216                     QString message = in2.readAll();
0217                     client->publish(topicFilter.filter(), message.toUtf8(), 0);
0218                 }
0219                 file2.close();
0220 
0221                 QTest::qWait(1000);
0222 
0223                 QCOMPARE(value->rowCount(), 8);
0224                 QCOMPARE(value->valueAt(3), 6);
0225                 QCOMPARE(value->valueAt(4), 0);
0226                 QCOMPARE(value->valueAt(5), 0);
0227                 QCOMPARE(value->valueAt(6), 0);
0228                 QCOMPARE(value->valueAt(7), 3);
0229             }
0230         }
0231     }
0232 }
0233 
0234 void MQTTUnitTest::testNumericMessage() {
0235     AsciiFilter* filter = new AsciiFilter();
0236     filter->setAutoModeEnabled(true);
0237 
0238     Project* project = new Project();
0239 
0240     MQTTClient* mqttClient = new MQTTClient(QStringLiteral("test"));
0241     project->addChild(mqttClient);
0242     mqttClient->setFilter(filter);
0243     mqttClient->setReadingType(MQTTClient::ReadingType::TillEnd);
0244     mqttClient->setKeepNValues(0);
0245     mqttClient->setUpdateType(MQTTClient::UpdateType::NewData);
0246     mqttClient->setMQTTClientHostPort(QStringLiteral("broker.hivemq.com"), 1883);
0247     mqttClient->setMQTTUseAuthentication(false);
0248     mqttClient->setMQTTUseID(false);
0249     QMqttTopicFilter topicFilter{QStringLiteral("labplot/mqttUnitTest")};
0250     mqttClient->addInitialMQTTSubscriptions(topicFilter, 0);
0251     mqttClient->read();
0252     mqttClient->ready();
0253 
0254     QMqttClient* client = new QMqttClient();
0255     client->setHostname(QStringLiteral("broker.hivemq.com"));
0256     client->setPort(1883);
0257     client->connectToHost();
0258 
0259     bool wait = QTest::qWaitFor(
0260         [&]() {
0261             return (client->state() == QMqttClient::Connected);
0262         },
0263         5000);
0264     QCOMPARE(wait, true);
0265 
0266     QMqttSubscription* subscription = client->subscribe(topicFilter, 0);
0267     if (subscription) {
0268         const QString fileName = m_dataDir + QStringLiteral("numeric_message_1.txt");
0269         QFile file(fileName);
0270 
0271         if (file.open(QIODevice::ReadOnly)) {
0272             QTextStream in(&file);
0273             QString message = in.readAll();
0274             client->publish(topicFilter.filter(), message.toUtf8(), 0);
0275         }
0276         file.close();
0277 
0278         QTimer timer;
0279         timer.setSingleShot(true);
0280         QEventLoop* loop = new QEventLoop();
0281         connect(mqttClient, &MQTTClient::MQTTTopicsChanged, loop, &QEventLoop::quit);
0282         connect((&timer), &QTimer::timeout, loop, &QEventLoop::quit);
0283         timer.start(5000);
0284         loop->exec();
0285 
0286         const MQTTTopic* testTopic = nullptr;
0287 
0288         if (timer.isActive()) {
0289             QVector<const MQTTTopic*> topic = mqttClient->children<const MQTTTopic>(AbstractAspect::ChildIndexFlag::Recursive);
0290             for (const auto& top : topic) {
0291                 if (top->topicName() == QLatin1String("labplot/mqttUnitTest")) {
0292                     testTopic = top;
0293                     break;
0294                 }
0295             }
0296 
0297             if (testTopic) {
0298                 Column* value = testTopic->column(testTopic->columnCount() - 1);
0299                 QCOMPARE(value->columnMode(), Column::ColumnMode::Double);
0300                 QCOMPARE(value->rowCount(), 3);
0301                 QCOMPARE(value->valueAt(0), 1.5);
0302                 QCOMPARE(value->valueAt(1), 2.7);
0303                 QCOMPARE(value->valueAt(2), 3.9);
0304 
0305                 const QString fileName2 = m_dataDir + QStringLiteral("numeric_message_2.txt");
0306                 QFile file2(fileName2);
0307 
0308                 if (file2.open(QIODevice::ReadOnly)) {
0309                     QTextStream in2(&file2);
0310                     QString message = in2.readAll();
0311                     client->publish(topicFilter.filter(), message.toUtf8(), 0);
0312                 }
0313                 file2.close();
0314 
0315                 QTest::qWait(1000);
0316 
0317                 QCOMPARE(value->rowCount(), 8);
0318                 QCOMPARE(value->valueAt(3), 6);
0319                 QCOMPARE((bool)std::isnan(value->valueAt(4)), true);
0320                 QCOMPARE((bool)std::isnan(value->valueAt(5)), true);
0321                 QCOMPARE((bool)std::isnan(value->valueAt(6)), true);
0322                 QCOMPARE(value->valueAt(7), 0.0098);
0323             }
0324         }
0325     }
0326 }
0327 
0328 void MQTTUnitTest::testTextMessage() {
0329     AsciiFilter* filter = new AsciiFilter();
0330     filter->setAutoModeEnabled(true);
0331 
0332     Project* project = new Project();
0333 
0334     MQTTClient* mqttClient = new MQTTClient(QStringLiteral("test"));
0335     project->addChild(mqttClient);
0336     mqttClient->setFilter(filter);
0337     mqttClient->setReadingType(MQTTClient::ReadingType::TillEnd);
0338     mqttClient->setKeepNValues(0);
0339     mqttClient->setUpdateType(MQTTClient::UpdateType::NewData);
0340     mqttClient->setMQTTClientHostPort(QStringLiteral("broker.hivemq.com"), 1883);
0341     mqttClient->setMQTTUseAuthentication(false);
0342     mqttClient->setMQTTUseID(false);
0343     QMqttTopicFilter topicFilter{QStringLiteral("labplot/mqttUnitTest")};
0344     mqttClient->addInitialMQTTSubscriptions(topicFilter, 0);
0345     mqttClient->read();
0346     mqttClient->ready();
0347 
0348     QMqttClient* client = new QMqttClient();
0349     client->setHostname(QStringLiteral("broker.hivemq.com"));
0350     client->setPort(1883);
0351     client->connectToHost();
0352 
0353     bool wait = QTest::qWaitFor(
0354         [&]() {
0355             return (client->state() == QMqttClient::Connected);
0356         },
0357         5000);
0358     QCOMPARE(wait, true);
0359 
0360     QMqttSubscription* subscription = client->subscribe(topicFilter, 0);
0361     if (subscription) {
0362         const QString fileName = m_dataDir + QStringLiteral("text_message.txt");
0363         QFile file(fileName);
0364 
0365         if (file.open(QIODevice::ReadOnly)) {
0366             QTextStream in(&file);
0367             QString message = in.readAll();
0368             client->publish(topicFilter.filter(), message.toUtf8(), 0);
0369         }
0370         file.close();
0371 
0372         QTimer timer;
0373         timer.setSingleShot(true);
0374         QEventLoop* loop = new QEventLoop();
0375         connect(mqttClient, &MQTTClient::MQTTTopicsChanged, loop, &QEventLoop::quit);
0376         connect((&timer), &QTimer::timeout, loop, &QEventLoop::quit);
0377         timer.start(5000);
0378         loop->exec();
0379 
0380         const MQTTTopic* testTopic = nullptr;
0381 
0382         if (timer.isActive()) {
0383             QVector<const MQTTTopic*> topic = mqttClient->children<const MQTTTopic>(AbstractAspect::ChildIndexFlag::Recursive);
0384             for (const auto& top : topic) {
0385                 if (top->topicName() == QLatin1String("labplot/mqttUnitTest")) {
0386                     testTopic = top;
0387                     break;
0388                 }
0389             }
0390 
0391             if (testTopic) {
0392                 Column* value = testTopic->column(testTopic->columnCount() - 1);
0393                 QCOMPARE(value->columnMode(), Column::ColumnMode::Text);
0394                 QCOMPARE(value->rowCount(), 5);
0395                 QCOMPARE(value->textAt(0), QStringLiteral("ball"));
0396                 QCOMPARE(value->textAt(1), QStringLiteral("cat"));
0397                 QCOMPARE(value->textAt(2), QStringLiteral("dog"));
0398                 QCOMPARE(value->textAt(3), QStringLiteral("house"));
0399                 QCOMPARE(value->textAt(4), QStringLiteral("Barcelona"));
0400             }
0401         }
0402     }
0403 }
0404 
0405 // ##############################################################################
0406 // #####################  test subscribing and unsubscribing  ###################
0407 // ##############################################################################
0408 /*void MQTTUnitTest::testSubscriptions() {
0409     AsciiFilter* filter = new AsciiFilter();
0410     filter->setAutoModeEnabled(true);
0411 
0412     Project* project = new Project();
0413 
0414     MQTTClient* mqttClient = new MQTTClient(QStringLiteral("test"));
0415     project->addChild(mqttClient);
0416     mqttClient->setFilter(filter);
0417     mqttClient->setReadingType(MQTTClient::ReadingType::TillEnd);
0418     mqttClient->setKeepNValues(0);
0419     mqttClient->setUpdateType(MQTTClient::UpdateType::NewData);
0420     mqttClient->setMQTTClientHostPort(QStringLiteral("broker.hivemq.com"), 1883);
0421     mqttClient->setMQTTUseAuthentication(false);
0422     mqttClient->setMQTTUseID(false);
0423     mqttClient->setMQTTWillUse(false);
0424     QMqttTopicFilter topicFilter {QStringLiteral("labplot/mqttUnitTest")};
0425     mqttClient->addInitialMQTTSubscriptions(topicFilter, 0);
0426 
0427     LiveDataDock* liveDock = new LiveDataDock();
0428     liveDock->setMQTTClient(mqttClient);
0429 
0430     mqttClient->read();
0431     mqttClient->ready();
0432 
0433     QTimer timer;
0434     timer.setSingleShot(true);
0435     QEventLoop* loop = new QEventLoop();
0436     connect(mqttClient, &MQTTClient::MQTTSubscribed, loop, &QEventLoop::quit);
0437     connect( (&timer), &QTimer::timeout, loop, &QEventLoop::quit);
0438     timer.start(5000);
0439     loop->exec();
0440 
0441     if(timer.isActive()) {
0442         delete loop;
0443         QMqttClient* client = new QMqttClient();
0444         client->setHostname(QStringLiteral("broker.hivemq.com"));
0445         client->setPort(1883);
0446         client->connectToHost();
0447 
0448         bool wait = QTest::qWaitFor([&]() {
0449             return (client->state() == QMqttClient::Connected);
0450         }, 3000);
0451         QCOMPARE(wait, true);
0452 
0453         QString fileName = m_dataDir + QStringLiteral("subscribe_1.txt");
0454         QFile* file = new QFile(fileName);
0455 
0456         QTest::qWait(1000);
0457 
0458         if(file->open(QIODevice::ReadOnly)) {
0459             QTextStream in(file);
0460 
0461             while(!in.atEnd()) {
0462                 QString line = in.readLine();
0463                 QMqttTopicFilter filter{line};
0464                 client->publish(filter.filter(), QString("test").toUtf8());
0465 
0466                 QTimer timer2;
0467                 timer2.setSingleShot(true);
0468                 loop = new QEventLoop();
0469                 connect( (&timer2), &QTimer::timeout, loop, &QEventLoop::quit);
0470                 connect(liveDock, &LiveDataDock::newTopic, this, [line, loop](const QString& topic) {
0471                     if(topic == line) {
0472                         loop->quit();
0473                     }
0474                 });
0475                 timer2.start(5000);
0476                 loop->exec();
0477 
0478                 disconnect(liveDock, &LiveDataDock::newTopic, this, nullptr);
0479             }
0480         }
0481 
0482         liveDock->testUnsubscribe("labplot/mqttUnitTest");
0483 
0484         file->close();
0485         delete file;
0486 
0487         fileName = m_dataDir + "subscribe_2.txt";
0488         file = new QFile(fileName);
0489         if(file->open(QIODevice::ReadOnly)) {
0490             QTextStream in(file);
0491             while(!in.atEnd()) {
0492                 QString topic = in.readLine();
0493                 bool found = liveDock->testSubscribe(topic);
0494                 QCOMPARE(found, true);
0495             }
0496         }
0497         file->close();
0498         delete file;
0499 
0500         fileName = m_dataDir + "subscribe_2_result.txt";
0501         file = new QFile(fileName);
0502         if(file->open(QIODevice::ReadOnly)) {
0503             QTextStream in(file);
0504             int count = in.readLine().simplified().toInt();
0505             QCOMPARE(mqttClient->MQTTSubscriptions().size(), count);
0506 
0507             while(!in.atEnd()) {
0508                 QString topic = in.readLine();
0509                 QVector<QString> subscriptions = mqttClient->MQTTSubscriptions();
0510                 QCOMPARE(subscriptions.contains(topic), true);
0511             }
0512         }
0513         file->close();
0514         delete file;
0515 
0516         fileName = m_dataDir + "unsubscribe_1.txt";
0517         file = new QFile(fileName);
0518         if(file->open(QIODevice::ReadOnly)) {
0519             QTextStream in(file);
0520             while(!in.atEnd()) {
0521                 QString topic = in.readLine();
0522                 bool found = liveDock->testUnsubscribe(topic);
0523                 QCOMPARE(found, true);
0524             }
0525         }
0526         file->close();
0527         delete file;
0528 
0529         fileName = m_dataDir + "unsubscribe_1_result.txt";
0530         file = new QFile(fileName);
0531         if(file->open(QIODevice::ReadOnly)) {
0532             QTextStream in(file);
0533             int count = in.readLine().simplified().toInt();
0534             QCOMPARE(mqttClient->MQTTSubscriptions().size(), count);
0535 
0536             while(!in.atEnd()) {
0537                 QString topic = in.readLine();
0538                 QVector<QString> subscriptions = mqttClient->MQTTSubscriptions();
0539                 QCOMPARE(subscriptions.contains(topic), true);
0540             }
0541         }
0542         file->close();
0543         delete file;
0544 
0545         fileName = m_dataDir + "subscribe_3.txt";
0546         file = new QFile(fileName);
0547         if(file->open(QIODevice::ReadOnly)) {
0548             QTextStream in(file);
0549             while(!in.atEnd()) {
0550                 QString topic = in.readLine();
0551                 bool found = liveDock->testSubscribe(topic);
0552                 QCOMPARE(found, true);
0553             }
0554         }
0555         file->close();
0556         delete file;
0557 
0558         fileName = m_dataDir + "subscribe_3_result.txt";
0559         file = new QFile(fileName);
0560         if(file->open(QIODevice::ReadOnly)) {
0561             QTextStream in(file);
0562             int count = in.readLine().simplified().toInt();
0563             QCOMPARE(mqttClient->MQTTSubscriptions().size(), count);
0564 
0565             while(!in.atEnd()) {
0566                 QString topic = in.readLine();
0567                 QVector<QString> subscriptions = mqttClient->MQTTSubscriptions();
0568                 QCOMPARE(subscriptions.contains(topic), true);
0569             }
0570         }
0571         file->close();
0572         delete file;
0573 
0574         fileName = m_dataDir + "unsubscribe_2.txt";
0575         file = new QFile(fileName);
0576         if(file->open(QIODevice::ReadOnly)) {
0577             QTextStream in(file);
0578             while(!in.atEnd()) {
0579                 QString topic = in.readLine();
0580                 bool found = liveDock->testUnsubscribe(topic);
0581                 QCOMPARE(found, true);
0582             }
0583         }
0584         file->close();
0585         delete file;
0586 
0587         fileName = m_dataDir + "unsubscribe_2_result.txt";
0588         file = new QFile(fileName);
0589         if(file->open(QIODevice::ReadOnly)) {
0590             QTextStream in(file);
0591             int count = in.readLine().simplified().toInt();
0592             QCOMPARE(mqttClient->MQTTSubscriptions().size(), count);
0593 
0594             QVector<QString> subscriptions = mqttClient->MQTTSubscriptions();
0595             while(!in.atEnd()) {
0596                 QString topic = in.readLine();
0597                 QCOMPARE(subscriptions.contains(topic), true);
0598             }
0599         }
0600         file->close();
0601         delete file;
0602     }
0603 }*/
0604 
0605 QTEST_MAIN(MQTTUnitTest)
0606 
0607 #endif // HAVE_MQTT