Commit 58550eac98a1c21f26fe832b53013849fa0fb227
1 parent
f19d8d42
Run tests on different port
This prevents confusion when another instance of FlashMQ is running. This is not the final way. For instance, when SSL connections will also be tested, this won't work anymore.
Showing
3 changed files
with
9 additions
and
3 deletions
FlashMQTests/twoclienttestcontext.cpp
| ... | ... | @@ -26,9 +26,9 @@ TwoClientTestContext::TwoClientTestContext(int clientNr, QObject *parent) : QObj |
| 26 | 26 | { |
| 27 | 27 | QHostInfo targetHostInfo = QHostInfo::fromName("localhost"); |
| 28 | 28 | QHostAddress targetHost(targetHostInfo.addresses().first()); |
| 29 | - sender.reset(new QMQTT::Client(targetHost)); | |
| 29 | + sender.reset(new QMQTT::Client(targetHost, 21883)); | |
| 30 | 30 | sender->setClientId(QString("Sender%1").arg(clientNr)); |
| 31 | - receiver.reset(new QMQTT::Client(targetHost)); | |
| 31 | + receiver.reset(new QMQTT::Client(targetHost, 21883)); | |
| 32 | 32 | receiver->setClientId(QString("Receiver%1").arg(clientNr)); |
| 33 | 33 | |
| 34 | 34 | connect(sender.data(), &QMQTT::Client::error, this, &TwoClientTestContext::onClientError); | ... | ... |
flashmqtestclient.cpp
| ... | ... | @@ -95,7 +95,7 @@ void FlashMQTestClient::connectClient(ProtocolVersion protocolVersion, bool clea |
| 95 | 95 | |
| 96 | 96 | servaddr.sin_family = AF_INET; |
| 97 | 97 | servaddr.sin_addr.s_addr = inet_addr(hostname.c_str()); |
| 98 | - servaddr.sin_port = htons(1883); | |
| 98 | + servaddr.sin_port = htons(21883); | |
| 99 | 99 | |
| 100 | 100 | int flags = fcntl(sockfd, F_GETFL); |
| 101 | 101 | fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); | ... | ... |
mainapp.cpp
| ... | ... | @@ -728,6 +728,12 @@ void MainApp::loadConfig() |
| 728 | 728 | if (settings->listeners.empty()) |
| 729 | 729 | { |
| 730 | 730 | std::shared_ptr<Listener> defaultListener = std::make_shared<Listener>(); |
| 731 | + | |
| 732 | + // Kind of a quick hack to do this this way. | |
| 733 | +#ifdef TESTING | |
| 734 | + defaultListener->port = 21883; | |
| 735 | +#endif | |
| 736 | + | |
| 731 | 737 | defaultListener->isValid(); |
| 732 | 738 | settings->listeners.push_back(defaultListener); |
| 733 | 739 | } | ... | ... |