Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
#
# $Id$
# $HeadURL$
# $Author$
#
SET(SRCS_MRK_TEST
mrk_tests.cpp
mrk_tests.h
)
IF(BUILD_TESTING AND TARGET svcMrkClient)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(mrkTests ${SRCS_MRK_TEST})
TARGET_LINK_LIBRARIES(mrkTests
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcMrkClient
LtsCommandLineParser
ddsconnector
nglcoreapplication
)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS mrkTests DESTINATION bin/test)
NGL_INSTALL(AAR SV FILES log4cxx_mrk.props DESTINATION bin/test)
ENDIF()
ENDIF()
@@ -0,0 +1,86 @@
log4j.reset=true
log4j.rootLogger=WARN, file
# Service: MarkerManagement
###########################################################
#log4j.logger.MRK=INFO
#log4j.logger.MRK.main=INFO
#log4j.logger.MRK.MainHandler=INFO
#log4j.logger.MRK.DdsHandler=INFO
#log4j.logger.MRK.DbHandler=INFO
#log4j.logger.MRK.HandlerMarker=DEBUG
#log4j.logger.MRK.ObjectMarker=DEBUG
#log4j.logger.MRK.HandlerMarkerDescription=DEBUG
#log4j.logger.MRK.ObjectMarkerDescription=DEBUG
#log4j.logger.MRK.ObjectMarker=INFO
# File
###########################################################
log4j.appender.file=Lts::RollingFileAppender
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=9
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
# Appnd_Console
###########################################################
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
# Appnd_Syslog
###########################################################
log4j.appender.syslog=org.apache.log4j.SyslogAppender
log4j.appender.syslog.Threshold=ERROR
log4j.appender.syslog.SysLogHost=localhost
log4j.appender.syslog.Facility=LOCAL7
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
###########################################################
###########################################################
###########################################################
# 1) Available Levels in LOG4CXX Version 0.10.0:
# TRACE,
# DEBUG,
# INFO,
# WARN,
# ERROR
# FATAL
#
# d = date/time
# p = priority (Level)
# c = category/channel
# m = message
# F = file
# L = line
# n = platform dependent line separator character or characters.
# ....
#
# Examples for console:
# a)
# %d %p %c #%m# (%.50F:%L)%n
# date/time
# priority
# category/channel
# #message#
# (Maximal 50Character des Filename von rechts:Line)
# line separator
#
# b)
# %d (%.15F:%L) %-5p %c |#| %m%n
# date/time
# (Maximal 15Character des Filename von rechts:Line)
# priority, Right pad with spaces if the priority name is less than 5 characters long.
# category/channel
# message
# line separator
#
# Examples for files:
+725
View File
@@ -0,0 +1,725 @@
/**
* MRK Function Topic test executable
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-04-18
*/
#include "mrk_tests.h"
#include <nglapplication/nglcoreapplication.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QTimer>
#include <QDateTime>
#include <QString>
#include <QVector>
#include <MarkerManagement/mrk_ftc.h>
#include <MarkerManagement/mrk_dtc.h>
using namespace MarkerManagement;
//-----------------------------------------------------------------------------
MrkTests::MrkTests(QObject *parent)
: QObject(parent)
, m_exerciseId(0)
, m_testId(0)
, m_markerId(0)
, m_eTestStep(eUnknown)
, m_bTestsSuccessful(true)
, m_logger(getLogger("MrkTests"))
{
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
} // end of ctor()
//-----------------------------------------------------------------------------
MrkTests::~MrkTests()
{
} // end of dtor()
//-----------------------------------------------------------------------------
bool MrkTests::init(int domainId, int exerciseId, int testId, int markerId, int snapshotId)
{
INFO_LOG(m_logger) << "MrkTests::init() "
<< " domainId:" << domainId
<< " exerciseId:" << exerciseId
<< " testId: " << testId
<< " markerId: " << markerId
;
m_testId = testId;
m_exerciseId = exerciseId;
m_markerId = markerId;
m_snapshotId = snapshotId;
// initialize DDS
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId));
if (!m_ddsConnector->init())
return false;
m_ddsConnector->initPublisherSubscriber();
// Access to FTC
DEBUG_LOG(m_logger) << "create ftc";
m_ftc = MarkerManagement::Interface::Ftc::create(m_ddsConnector);
DEBUG_LOG(m_logger) << "init ftc";
bool bRet = m_ftc->enableAll();
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
// Access to DTC
DEBUG_LOG(m_logger) << "create dtc";
m_dtc = MarkerManagement::Interface::Dtc::create(m_ddsConnector);
DEBUG_LOG(m_logger) << "init dtc";
bRet = m_dtc->enableAll();
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
return bRet;
} // end of init()
//-----------------------------------------------------------------------------
void MrkTests::startTest()
{
INFO_LOG(m_logger) << "startTest() exerciseId:" << m_exerciseId
<< " testId:" << m_testId
<< " markerId:" << m_markerId
;
connect(m_dtc.get(), &Interface::Dtc::markerChanged,
this, &MrkTests::onReceiveMarkerChanged);
if (m_testId <= 1)
QTimer::singleShot(0, this, &MrkTests::tryCreate);
else if (m_testId == 2)
QTimer::singleShot(0, this, &MrkTests::tryModify);
else if (m_testId == 3)
QTimer::singleShot(0, this, &MrkTests::tryRemove);
else if (m_testId == 4)
QTimer::singleShot(0, this, &MrkTests::tryCreateSnapshot);
else if (m_testId == 5)
QTimer::singleShot(0, this, &MrkTests::tryModifySnapshot);
else if (m_testId == 6)
QTimer::singleShot(0, this, &MrkTests::tryRemoveSnapshot);
else if (m_testId == 10)
QTimer::singleShot(0, this, &MrkTests::tryGetAllMarkers);
else if (m_testId == 11)
QTimer::singleShot(0, this, &MrkTests::tryGetMarker);
} // end of startTest()
//-----------------------------------------------------------------------------
void MrkTests::tryCreate()
{
m_eTestStep = eCreate;
MarkerModifyRequest data;
getMarkerCreateRequestData(data);
INFO_LOG(m_logger) << "trying to send MarkerCreateRequest";
if (!m_ftc->markerModifyRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
} // end of tryCreate()
//-----------------------------------------------------------------------------
void MrkTests::tryModify()
{
m_eTestStep = eModify;
MarkerModifyRequest data;
getMarkerModifyRequestData(data);
INFO_LOG(m_logger) << "trying to send MarkerModifyRequest for markerId:" << data.id();
if (!m_ftc->markerModifyRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting modify data for markerId:" << data.id();
failExit();
}
} // end of tryModify()
//-----------------------------------------------------------------------------
void MrkTests::tryRemove()
{
m_eTestStep = eRemove;
MarkerRemoveRequest data;
data.id(m_markerId);
INFO_LOG(m_logger) << "trying to send remove request for markerId:" << data.id();
if (!m_ftc->markerRemoveRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting remove data for markerId:" << data.id();
failExit();
}
} // end of tryRemove()
//-----------------------------------------------------------------------------
void MrkTests::tryGetAllMarkers()
{
m_eTestStep = eGetAllMarkers;
DEBUG_LOG(m_logger) << "trying to get all markers";
m_dtc->waitForHistoricalDataMarker();
const QMap<qint32, MarkerManagement::Marker> map = m_dtc->markers();
if (map.isEmpty())
{
ERROR_LOG(m_logger) << "Error requesting all marker data";
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
return;
}
INFO_LOG(m_logger) << "Amout of existing markers:" << map.size();
m_markerId = map.firstKey();
for (auto it = map.begin(); it != map.end(); ++it)
{
INFO_LOG(m_logger) << "Mrk(" << it.key() << ") :"
<< " note:" << it.value().note()
<< " operatorId:" << it.value().operatorId()
<< " timeStamp:" << it.value().timeStamp()
<< " timeStampOffset:" << it.value().timeStampOffset()
<< " description count:" << it.value().descriptions().size();
}
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of tryGetAllMarkers()
//-----------------------------------------------------------------------------
void MrkTests::tryGetMarker()
{
DEBUG_LOG(m_logger) << "trying to get marker with id:" << m_markerId;
if (m_testId > 1)
m_eTestStep = eGetMarker;
if (m_markerId <= 0)
{
ERROR_LOG(m_logger) << "invalid markerId - test aborted.";
failExit();
}
m_dtc->waitForHistoricalDataMarker();
MarkerManagement::Marker data = m_dtc->marker(m_markerId);
if (data.id() <= 0)
{
ERROR_LOG(m_logger) << "Error receiving data for markerId " << m_markerId << " returnVal:" << data.id();
failExit();
}
else
{
INFO_LOG(m_logger) << "Mrk(" << data.id() << ") :"
<< " note:" << data.note()
<< " operatorId:" << data.operatorId()
<< " timeStamp:" << data.timeStamp()
<< " timeStampOffset:" << data.timeStampOffset()
;
}
if (m_testId == 0)
{
if (m_eTestStep == eCreate)
{
if (! onCompareCreatedData(data))
{
ERROR_LOG(m_logger) << "Compare created data failed!";
failExit();
}
else
{
QTimer::singleShot(0, this, &MrkTests::tryModify);
return;
}
}
else if (m_eTestStep == eModify)
{
if (! onCompareModifiedData(data))
{
ERROR_LOG(m_logger) << "Compare modified data failed!";
failExit();
}
else
{
QTimer::singleShot(0, this, &MrkTests::tryRemove);
return;
}
}
}
else
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of tryGetMarker()
//-----------------------------------------------------------------------------
void MrkTests::tryCreateSnapshot()
{
m_eTestStep = eCreate;
Snapshot data;
data.id(0); // create
data.name("Snapshot 1");
data.description("Dies ist ein Test");
data.mapSettings("78000 92000 xxxx");
data.operatorId(100);
data.timeStamp(QDateTime::currentMSecsSinceEpoch());
data.planOverlay("Plan Overlay");
INFO_LOG(m_logger) << "trying to send SnapshotCreateRequest";
if (!m_ftc->snapshotModifyRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
} // end of tryCreateSnapshot()
//-----------------------------------------------------------------------------
void MrkTests::tryModifySnapshot()
{
m_eTestStep = eModify;
Snapshot data;
data.id(m_snapshotId);
data.name("Snapshot modify");
data.description("Dies ist ein Test modify");
data.planOverlay("Plan Overlay updated");
INFO_LOG(m_logger) << "trying to send SnapshotModifyRequest for snapshotId:" << data.id();
if (!m_ftc->snapshotModifyRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting modify data for snapshotId:" << data.id();
failExit();
}
} // end of tryModifySnapshot()
//-----------------------------------------------------------------------------
void MrkTests::tryRemoveSnapshot()
{
m_eTestStep = eRemove;
SnapshotRemoveRequest data;
data.id(m_snapshotId);
INFO_LOG(m_logger) << "trying to send remove request for snapshotId:" << data.id();
if (!m_ftc->snapshotRemoveRequest(data, this))
{
ERROR_LOG(m_logger) << "Error requesting remove data for snapshotId:" << data.id();
failExit();
}
} // end of tryRemoveSnapshot()
//-----------------------------------------------------------------------------
void MrkTests::onMarkerCreateReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
m_markerId = replyObject.id();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
return;
}
else
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
// QTimer::singleShot(0, this, &MrkTests::tryModify()));
QTimer::singleShot(0, this, &MrkTests::tryGetMarker);
else
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of onMarkerCreateReply()
//-----------------------------------------------------------------------------
void MrkTests::onMarkerModifyReply(const Core::FunctionReplyObject &replyObject)
{
if (m_eTestStep == TestStep::eCreate)
return onMarkerCreateReply(replyObject);
INFO_LOG(m_logger) << "Got modifyRequest with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting modify data for id:" << replyObject.id();
failExit();
return;
}
else
DEBUG_LOG(m_logger) << "Requesting modify data for id:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
// QTimer::singleShot(0, this, &MrkTests::tryDelete()));
QTimer::singleShot(0, this, &MrkTests::tryGetMarker);
else
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of onMarkerModifyReply()
//-----------------------------------------------------------------------------
void MrkTests::onMarkerRemoveReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting remove data for markerId:" << replyObject.id();
failExit();
return;
}
else
DEBUG_LOG(m_logger) << "Requesting remove data for markerId:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
{
QTimer::singleShot(0, this, &MrkTests::tryCreateSnapshot);
// ansonsten verheriger Ausstieg mit Errorlog.
}
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of onMarkerRemoveReply()
//-----------------------------------------------------------------------------
void MrkTests::onSnapshotCreateReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
m_snapshotId = replyObject.id();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
return;
}
else
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
QTimer::singleShot(0, this, &MrkTests::tryModifySnapshot);
else
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of onSnapshotCreateReply()
//-----------------------------------------------------------------------------
void MrkTests::onSnapshotModifyReply(const Core::FunctionReplyObject &replyObject)
{
if (m_eTestStep == TestStep::eCreate)
return onSnapshotCreateReply(replyObject);
INFO_LOG(m_logger) << "Got modifyRequest with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting modify data for id:" << replyObject.id();
failExit();
return;
}
else
DEBUG_LOG(m_logger) << "Requesting modify data for id:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
QTimer::singleShot(0, this, &MrkTests::tryRemoveSnapshot);
else
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of onSnapshotModifyReply()
//-----------------------------------------------------------------------------
void MrkTests::onSnapshotRemoveReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
<< " and errorString " << replyObject.translated();
if (replyObject.error())
{
ERROR_LOG(m_logger) << "Error requesting remove data for markerId:" << replyObject.id();
failExit();
return;
}
else
DEBUG_LOG(m_logger) << "Requesting remove data for markerId:" << replyObject.id() << " ... ok.";
if (m_testId == 0)
{
INFO_LOG(m_logger) << "***** FTC/TDC test successfully finished. (used snapshotId:" << replyObject.id() << ") *****";
// ansonsten verheriger Ausstieg mit Errorlog.
}
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
} // end of onSnapshotRemoveReply()
//-----------------------------------------------------------------------------
void MrkTests::onReceiveMarkerChanged(const Marker &data, DataModification modType)
{
// INFO_LOG(m_logger) << "onReceiveMarkerChanged() markerId:" << data.id()
// << " modificationType: = " << (int)modType<< " received";
switch (modType)
{
case DataModification::eAdded:
INFO_LOG(m_logger) << "*** Marker added received. markerId:" << data.id();
break;
case DataModification::eModified:
INFO_LOG(m_logger) << "*** Marker modified received. markerId:" << data.id();
break;
case DataModification::eRemoved:
INFO_LOG(m_logger) << "*** Marker removed received. markerId:" << data.id();
break;
}
} // end of onReceiveMarkerChanged()
//-----------------------------------------------------------------------------
void MrkTests::getMarkerCreateRequestData(MarkerModifyRequest &data)
{
time_t currentTime = time(nullptr);
if (m_testId == 0)
currentTime = currentTime / 10;
data.note("TestMarkerCreate");
data.operatorId(100);
data.timeStamp(currentTime);
data.timeStampOffset(33000);
getMarkerDescriptionCreateRequestData(data);
} // end of getMarkerCreateRequestData()
//-----------------------------------------------------------------------------
void MrkTests::getMarkerDescriptionCreateRequestData(MarkerModifyRequest &data)
{
// Info: FK fuer markerId wird in object_marker gesetzt.
data.descriptions().resize(3);
data.descriptions()[0].markerType(MarkerManagement::MarkerType::Audio);
data.descriptions()[0].content("Audio07, Audio08*, Audio09");
data.descriptions()[1].markerType(MarkerManagement::MarkerType::Video);
data.descriptions()[1].content("cam07, cam08, cam09*");
data.descriptions()[2].markerType(MarkerManagement::MarkerType::Video);
data.descriptions()[2].content("cam06, cam07, cam08, cam09*");
} // end of getMarkerDescriptionCreateRequestData()
//-----------------------------------------------------------------------------
void MrkTests::getMarkerModifyRequestData(MarkerModifyRequest &data)
{
time_t currentTime = time(nullptr);
if (m_testId == 0)
currentTime = currentTime / 10;
data.id(m_markerId);
data.note("TestMarkerModify");
data.operatorId(100);
data.timeStamp(currentTime * 1000);
data.timeStampOffset(77 * 1000);
getMarkerDescriptionCreateRequestData(data);
for (auto &desc : data.descriptions())
desc.content(std::string("+++MOD+++") + desc.content());
} // end of getMarkerModifyRequestData()
//-----------------------------------------------------------------------------
bool MrkTests::onCompareCreatedData(Marker &data)
{
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
// Vergleicht die zurueckgelesen Datan mit den statischen create Daten
MarkerModifyRequest createData;
getMarkerCreateRequestData(createData);
if (createData.note() != data.note())
return false;
if (createData.operatorId() != data.operatorId())
return false;
if (createData.timeStamp() != data.timeStamp())
return false;
if (createData.timeStampOffset() != data.timeStampOffset())
return false;
// Descriptions vergleichen
if (createData.descriptions().size() != data.descriptions().size())
{
ERROR_LOG(m_logger) << "Error onCompareCreatedData() different number of description data.";
failExit();
return false;
}
int foundCount = 0;
for (const auto &expected : createData.descriptions())
{
for (const auto &got : data.descriptions())
{
// we've got one description per type
if (got.markerType() != expected.markerType())
continue;
++foundCount;
if (got.content() != expected.content())
{
ERROR_LOG(m_logger) << "Content for description does not match: "
<< got.content() << " - "
<< expected.content();
failExit();
return false;
}
}
}
if (foundCount != 3)
{
ERROR_LOG(m_logger) << "Did not found all three expected descriptions";
failExit();
return false;
}
DEBUG_LOG(m_logger) << "successfull finished onCompareCreatedData() for id :" << data.id();
return true;
} // end of onCompareCreatedData()
//-----------------------------------------------------------------------------
bool MrkTests::onCompareModifiedData(Marker &data)
{
DEBUG_LOG(m_logger) << "start onCompareModifiedData() for id :" << data.id();
MarkerModifyRequest modifyData;
getMarkerModifyRequestData(modifyData);
if (modifyData.id() != data.id())
return false;
if (modifyData.note() != data.note())
return false;
if (modifyData.operatorId() != data.operatorId())
return false;
if (modifyData.timeStamp() != data.timeStamp())
return false;
if (modifyData.timeStampOffset() != data.timeStampOffset())
return false;
// Alle Descriptions zu dieser MarkerId holen ...
int foundCount = 0;
for (const auto &expected : modifyData.descriptions())
{
for (const auto &got : data.descriptions())
{
// we've got one description per type
if (got.markerType() != expected.markerType())
continue;
++foundCount;
if (got.content() != expected.content())
{
ERROR_LOG(m_logger) << "Content for description does not match: "
<< got.content() << " - "
<< expected.content();
failExit();
return false;
}
}
}
if (foundCount != 3)
{
ERROR_LOG(m_logger) << "Did not found all three expected descriptions";
failExit();
return false;
}
DEBUG_LOG(m_logger) << "successfull finished onCompareModifiedData() for id :" << data.id();
return true;
} // end of onCompareModifiedData()
//-----------------------------------------------------------------------------
void MrkTests::failExit()
{
m_bTestsSuccessful = false;
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
//-----------------------------------------------------------------------------
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
{
public:
CmdLineParser()
: LtsCommandLineParser()
{
addOption({ QStringList() << QLatin1String("t") << QLatin1String("testId")
, QLatin1String("TestId.")
, QLatin1String("Default: 0 (all FTC/DTC tests), 1 create, 2 modify, 3 remove, 10 getAllMarker and Descriptions, 11 getMarker")
, QLatin1String("0")
});
addOption({ QStringList() << QLatin1String("m") << QLatin1String("markerId")
, QLatin1String("MarkerId.")
, QLatin1String("Used for tests 2, 3 & 11 only to select the marker")
, QLatin1String("0")
});
addOption({ QStringList() << QLatin1String("s") << QLatin1String("snapshotId")
, QLatin1String("SnapshotId.")
, QLatin1String("Used for tests 4, 5 & 6 only to select the snapshotId")
, QLatin1String("0")
});
}
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; }
int markerId() const { return isSet(QLatin1String("m")) ? value(QLatin1String("m")).toInt() : -1; }
int snapshotId() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
};
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
NGLCoreApplication app(argc, argv);
app.createLogger("mrk", "log4cxx_mrk_module_tests.props");
int iRet = -1;
CmdLineParser options;
if (!options.init())
return iRet;
std::unique_ptr<MarkerManagement::MrkTests> MrkTests(new MarkerManagement::MrkTests);
if (!MrkTests->init(options.domainId(), options.exerciseId(), options.testId(), options.markerId(), options.snapshotId()))
return iRet;
QTimer::singleShot(2000, MrkTests.get(), &MarkerManagement::MrkTests::startTest);
STARTUP_LOG(app.baseLogger());
app.exec();
iRet = MrkTests->testsSuccessful() ? 0 : 1;
fprintf(stderr, "%d\n", iRet);
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
SHUTDOWN_LOG(app.baseLogger());
return iRet;
}
//-----------------------------------------------------------------------------
+112
View File
@@ -0,0 +1,112 @@
/**
* @RDE_HEADER@
*
* EXM Function Topic test executable
*
* ModuleTests for create/modify/remove marker
* ---------------------------------------------------
* Client FTC is implemented
*
* => (!) Preconditon:
* - Service svcMarkerManagent running
*
* -------------------------------------------------
*
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-04-18
*/
#pragma once
#include <MarkerManagement/mrk_ftc.h>
#include <MarkerManagement/mrk_ftc_types.h>
#include <MarkerManagement/mrk_dtc.h>
#include <MarkerManagement/mrk_dtc_types.h>
#include <MarkerManagement/logger.h>
#include <DDS/DDSConnector/dds_connector.h>
namespace MarkerManagement
{
class MrkTests : public QObject
, protected MarkerManagement::Interface::Ftc::MarkerModifyReplyHandler
, protected MarkerManagement::Interface::Ftc::MarkerRemoveReplyHandler
, protected MarkerManagement::Interface::Ftc::SnapshotModifyReplyHandler
, protected MarkerManagement::Interface::Ftc::SnapshotRemoveReplyHandler
{
Q_OBJECT
public:
explicit MrkTests(QObject *parent = nullptr);
~MrkTests();
bool init(int domainId, int exerciseId, int testId, int markerId, int snapshotId);
bool testsSuccessful() const { return m_bTestsSuccessful; }
public Q_SLOTS:
void startTest();
protected Q_SLOTS:
// used to check FTC
void tryCreate();
void tryModify();
void tryRemove();
void tryCreateSnapshot();
void tryModifySnapshot();
void tryRemoveSnapshot();
// used to check DTC
void tryGetAllMarkers();
void tryGetMarker();
// used to check DTC signal/slot connection
void onReceiveMarkerChanged(const Marker &data, DataModification modType);
protected:
// Callbackfunctions for FTC
void onMarkerCreateReply(const Core::FunctionReplyObject &replyObject);
void onMarkerModifyReply(const Core::FunctionReplyObject &replyObject) override final;
void onMarkerRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
void onSnapshotCreateReply(const Core::FunctionReplyObject &replyObject);
void onSnapshotModifyReply(const Core::FunctionReplyObject &replyObject) override final;
void onSnapshotRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
private Q_SLOTS:
bool onCompareCreatedData(Marker &data);
bool onCompareModifiedData(Marker &data);
private:
void getMarkerCreateRequestData(MarkerModifyRequest &data);
void getMarkerModifyRequestData(MarkerModifyRequest &data);
void getMarkerDescriptionCreateRequestData(MarkerModifyRequest &data);
void failExit();
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<MarkerManagement::Interface::Ftc> m_ftc;
std::shared_ptr<MarkerManagement::Interface::Dtc> m_dtc;
qint32 m_exerciseId;
int m_testId;
int m_markerId;
int m_snapshotId;
enum TestStep
{
eUnknown,
eCreate,
eModify,
eRemove,
eGetAllMarkers,
eGetMarker
} m_eTestStep;
bool m_bTestsSuccessful;
NGL::INGLLogger &m_logger;
};
} // namespace MarkerManagement