Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* UnitTests for ExerciseManagement (EXM)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-08-20
|
||||
*/
|
||||
|
||||
#include "data_topic_tests_main.h"
|
||||
#include "data_topic_tests.h"
|
||||
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("UnitTests", "log4cxx_exm_unit_tests.props");
|
||||
|
||||
DataTopicTestsMain *tc = new DataTopicTestsMain;
|
||||
|
||||
int retCode = QTest::qExec(tc, argc, argv);
|
||||
|
||||
delete tc;
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
DataTopicTestsMain::DataTopicTestsMain()
|
||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.DataTopicTestsMain"))
|
||||
{
|
||||
}
|
||||
|
||||
void DataTopicTestsMain::initTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: initTestCase";
|
||||
|
||||
m_dtTest = new DataTopicTests();
|
||||
|
||||
QVERIFY2(m_dtTest, "Initialisation of DataTopicTest failed");
|
||||
QVERIFY2(m_dtTest->initPublisher(), "Initialisation Publisher failed");
|
||||
QVERIFY2(m_dtTest->initSubscriber(), "Initialisation Subscriber failed");
|
||||
|
||||
m_serviceInformationDataArrivedSpy = new QSignalSpy(m_dtTest, &DataTopicTests::serviceInformationDataArrived);
|
||||
m_groupInformationDataArrivedSpy = new QSignalSpy(m_dtTest, &DataTopicTests::groupInformationDataArrived);
|
||||
}
|
||||
|
||||
void DataTopicTestsMain::publishServiceInformationTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: publish ServiceInformation data";
|
||||
|
||||
// Topic ServiceInformation
|
||||
m_sentServiceInformationData.id(13);
|
||||
m_sentServiceInformationData.name("UnitTest dummy Service");
|
||||
m_sentServiceInformationData.state(Core::RunningState::inner_enum::NotYetStarted);
|
||||
m_sentServiceInformationData.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
m_sentServiceInformationData.errorString(QStringLiteral("UnitTest dummy Error").toStdString());
|
||||
|
||||
QVERIFY2(m_dtTest->write(m_sentServiceInformationData), "Publishing Topic ServiceInformation failed");
|
||||
}
|
||||
|
||||
void DataTopicTestsMain::subscribeServiceInformationTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "IN subscribeServiceInformationTestCase";
|
||||
|
||||
QTRY_COMPARE(m_serviceInformationDataArrivedSpy->count(), 1);
|
||||
|
||||
ServiceManagement::ServiceInformation recvServiceInformation = m_dtTest->getReceivedServiceInformationData();
|
||||
|
||||
QCOMPARE(recvServiceInformation.id(), m_sentServiceInformationData.id());
|
||||
QCOMPARE(recvServiceInformation.name(), m_sentServiceInformationData.name());
|
||||
QCOMPARE(recvServiceInformation.state(), m_sentServiceInformationData.state());
|
||||
QCOMPARE(recvServiceInformation.timestamp(), m_sentServiceInformationData.timestamp());
|
||||
QCOMPARE(recvServiceInformation.errorString(), m_sentServiceInformationData.errorString());
|
||||
}
|
||||
|
||||
void DataTopicTestsMain::publishGroupInformationTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataTopicTestsMain: publish GroupInformation data";
|
||||
|
||||
std::vector<int> services = {1, 3, 5, 7, 11, 13, 17, 19, 23, 42};
|
||||
|
||||
// Topic GroupInformation
|
||||
m_sentGroupInformationData.type(Core::ServiceGroupType::inner_enum::Master);
|
||||
m_sentGroupInformationData.exercisePartitionId(113);
|
||||
m_sentGroupInformationData.domainId(42);
|
||||
m_sentGroupInformationData.services(services);
|
||||
m_sentGroupInformationData.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
|
||||
QVERIFY2(m_dtTest->write(m_sentGroupInformationData), "Publishing Topic GroupInformation failed");
|
||||
}
|
||||
|
||||
void DataTopicTestsMain::subscribeGroupInformationTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "IN subscribeGroupInformationTestCase";
|
||||
|
||||
QTRY_COMPARE(m_groupInformationDataArrivedSpy->count(), 1);
|
||||
|
||||
ServiceManagement::GroupInformation recvGroupInformation = m_dtTest->getReceivedGroupInformationData();
|
||||
|
||||
QCOMPARE(recvGroupInformation.type(), m_sentGroupInformationData.type());
|
||||
QCOMPARE(recvGroupInformation.exercisePartitionId(), m_sentGroupInformationData.exercisePartitionId());
|
||||
QCOMPARE(recvGroupInformation.domainId(), m_sentGroupInformationData.domainId());
|
||||
QCOMPARE(recvGroupInformation.services(), m_sentGroupInformationData.services());
|
||||
QCOMPARE(recvGroupInformation.timestamp(), m_sentGroupInformationData.timestamp());
|
||||
}
|
||||
|
||||
void DataTopicTestsMain::cleanupTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: cleanupTestCase";
|
||||
delete m_dtTest; m_dtTest = nullptr;
|
||||
delete m_serviceInformationDataArrivedSpy; m_serviceInformationDataArrivedSpy = nullptr;
|
||||
delete m_groupInformationDataArrivedSpy; m_groupInformationDataArrivedSpy = nullptr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user