Commit a7ba40e888eaffac1d3f47da20943f06ba9a9a5e

Authored by Wiebe Cazemier
1 parent 0765167b

Convert test_retained_removed to native test client

Showing 1 changed file with 19 additions and 11 deletions
FlashMQTests/tst_maintests.cpp
@@ -491,23 +491,31 @@ void MainTests::test_retained_changed() @@ -491,23 +491,31 @@ void MainTests::test_retained_changed()
491 491
492 void MainTests::test_retained_removed() 492 void MainTests::test_retained_removed()
493 { 493 {
494 - TwoClientTestContext testContext; 494 + FlashMQTestClient sender;
  495 + FlashMQTestClient receiver;
495 496
496 - QByteArray payload = "We are testing";  
497 - QString topic = "retaintopic"; 497 + sender.start();
  498 + receiver.start();
498 499
499 - testContext.connectSender();  
500 - testContext.publish(topic, payload, true); 500 + std::string payload = "We are testing";
  501 + std::string topic = "retaintopic";
501 502
502 - payload = ""; 503 + sender.connectClient(ProtocolVersion::Mqtt311);
503 504
504 - testContext.publish(topic, payload, true); 505 + Publish pub1(topic, payload, 0);
  506 + pub1.retain = true;
  507 + sender.publish(pub1);
505 508
506 - testContext.connectReceiver();  
507 - testContext.subscribeReceiver(topic);  
508 - testContext.waitReceiverReceived(0); 509 + pub1.payload = "";
  510 +
  511 + sender.publish(pub1);
  512 +
  513 + receiver.connectClient(ProtocolVersion::Mqtt311);
  514 + receiver.subscribe(topic, 0);
  515 + usleep(100000);
  516 + receiver.waitForMessageCount(0);
509 517
510 - QVERIFY2(testContext.receivedMessages.empty(), "We erased the retained message. We shouldn't have received any."); 518 + QVERIFY2(receiver.receivedPublishes.empty(), "We erased the retained message. We shouldn't have received any.");
511 } 519 }
512 520
513 /** 521 /**