ADTF  3.18.2
cTestSystem

This class enables you to setup an ADTF system where you can test your filters and services. More...

Inheritance diagram for cTestSystem:
[legend]

Public Member Functions

 cTestSystem (const std::string &strUrl="", const std::vector< std::string > &oPlugins={}, bool bCreateSessionManager=false, const std::string &strAdtfDirectory=ADTF_TESTING_ADTF_DIR, const std::string &strPluginDirectories=ADTF_TESTING_PLUGIN_DIRECTORIES)
 Constructs a test system. More...
 
 cTestSystem (const std::string &strUrl, const std::vector< std::string > &oPlugins, bool bCreateSessionManager, bool bCreateLoggingService, const std::string &strAdtfDirectory=ADTF_TESTING_ADTF_DIR, const std::string &strPluginDirectories=ADTF_TESTING_PLUGIN_DIRECTORIES)
 Constructs a test system. More...
 
 ~cTestSystem ()
 Destructor.
 
void SetRunLevel (base::ant::tADTFRunLevel eRunlevel)
 Helper function that changes the runlevel and throws errors via an exception. More...
 
base::ant::tADTFRunLevel GetRunLevel () const
 Helper function that returns the current runlevel. More...
 
void LoadPlugin (const std::string &strPluginFileName, bool bCreateServices=true, base::ant::tADTFRunLevel nServicesRunlevel=base::tADTFRunLevel::RL_System)
 Load a plugin and optionally create instances of all found ADTF Service classes. More...
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel=base::tADTFRunLevel::RL_System)
 Create a service instance. More...
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strPluginFileName, const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel=base::tADTFRunLevel::RL_System)
 Loads a plugin and creates a service instance. More...
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel, const std::map< std::string, std::string > &oProperties)
 Create a service instance with properties. More...
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strPluginFileName, const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel, const std::map< std::string, std::string > &oProperties)
 Load a plugin and create a service instance with properties. More...
 

Static Public Member Functions

static void SetCurDirectory (const std::string &strRelativePath, const std::string &strTestSourceDirectory=ADTF_TESTING_SOURCE_DIR)
 Helper function to change the current working directory relative to the source directory. More...
 
static void SetMacro (const std::string &strName, const std::string &strValue)
 Set a macro value. More...
 

Protected Attributes

std::unique_ptr< cImplementation > m_pImplementation
 

Detailed Description

This class enables you to setup an ADTF system where you can test your filters and services.

This can be used in your test fixtures by subclassing and seting up the system in the constructor. Please have a look at the example tests that are provided:

Example Usage

class cMyTestSystem: public adtf::system::testing::cTestSystem
{
public:
cMyTestSystem()
{
LoadPlugin("adtf_clock.adtfplugin");
LoadPlugin("adtf_kernel.adtfplugin");
LoadPlugin("my_filter.adtfplugin");
SetRunLevel(adtf::base::tADTFRunLevel::RL_System);
}
};
This class enables you to setup an ADTF system where you can test your filters and services.
Definition: test_system.h:67
void LoadPlugin(const std::string &strPluginFileName, bool bCreateServices=true, base::ant::tADTFRunLevel nServicesRunlevel=base::tADTFRunLevel::RL_System)
Load a plugin and optionally create instances of all found ADTF Service classes.
void SetRunLevel(base::ant::tADTFRunLevel eRunlevel)
Helper function that changes the runlevel and throws errors via an exception.
Copyright © Audi Electronics Venture GmbH.
Note
Our adtf_add_catch_test() macro from ADTF Testing SDK will define the ADTF_TESTING_ADTF_DIR and ADTF_TESTING_ADTF_DIR macros. If you use another testing framework make sure you either pass values directly to the constructor or add these definitions as well.

Definition at line 66 of file test_system.h.

Constructor & Destructor Documentation

◆ cTestSystem() [1/2]

cTestSystem ( const std::string &  strUrl = "",
const std::vector< std::string > &  oPlugins = {},
bool  bCreateSessionManager = false,
const std::string &  strAdtfDirectory = ADTF_TESTING_ADTF_DIR,
const std::string &  strPluginDirectories = ADTF_TESTING_PLUGIN_DIRECTORIES 
)

Constructs a test system.

Parameters
[in]strUrlIf set the RPC object registry will be created and listen at the given URL.
[in]oPluginsA list of plugins that should be loaded. LoadPlugin() will be called for each.
[in]bCreateSessionManagerWhether or not to create a session manager.
[in]strAdtfDirectoryThe ADTF root directory. The default is a macro that can be set by the test environment.
[in]strPluginDirectoriesA ';' seperated list of plugin directories. The default is a macro that can be set by the test environment.

◆ cTestSystem() [2/2]

cTestSystem ( const std::string &  strUrl,
const std::vector< std::string > &  oPlugins,
bool  bCreateSessionManager,
bool  bCreateLoggingService,
const std::string &  strAdtfDirectory = ADTF_TESTING_ADTF_DIR,
const std::string &  strPluginDirectories = ADTF_TESTING_PLUGIN_DIRECTORIES 
)

Constructs a test system.

Parameters
[in]strUrlIf set the RPC object registry will be created and listen at the given URL.
[in]oPluginsA list of plugins that should be loaded. LoadPlugin() will be called for each.
[in]bCreateSessionManagerWhether or not to create a session manager.
[in]bCreateLoggingServiceWhether or not to create a logging service.
[in]strAdtfDirectoryThe ADTF root directory. The default is a macro that can be set by the test environment.
[in]strPluginDirectoriesA ';' seperated list of plugin directories. The default is a macro that can be set by the test environment.

Member Function Documentation

◆ CreateService() [1/4]

ucom::ant::object_ptr<ucom::ant::IService> CreateService ( const std::string &  strClassId,
const std::string &  strObjectId,
base::ant::tADTFRunLevel  nRunlevel,
const std::map< std::string, std::string > &  oProperties 
)

Create a service instance with properties.

Parameters
[in]strClassIdThe class id of the service.
[in]strObjectIdThe object name with which the instance is registered at the runtime.
[in]nRunlevelThe service will be initialized at the given runlevel.
[in]oPropertiesName value pairs that will be set at the services configuration interface.
Returns
A pointer to the service instance.
Exceptions
tResultif an error occurred.

◆ CreateService() [2/4]

ucom::ant::object_ptr<ucom::ant::IService> CreateService ( const std::string &  strClassId,
const std::string &  strObjectId,
base::ant::tADTFRunLevel  nRunlevel = base::tADTFRunLevel::RL_System 
)

Create a service instance.

Parameters
[in]strClassIdThe class id of the service.
[in]strObjectIdThe object name with which the instance is registered at the runtime.
[in]nRunlevelThe service will be initialized at the given runlevel.
Returns
A pointer to the service instance.
Exceptions
tResultif an error occurred.

◆ CreateService() [3/4]

ucom::ant::object_ptr<ucom::ant::IService> CreateService ( const std::string &  strPluginFileName,
const std::string &  strClassId,
const std::string &  strObjectId,
base::ant::tADTFRunLevel  nRunlevel,
const std::map< std::string, std::string > &  oProperties 
)

Load a plugin and create a service instance with properties.

Parameters
[in]strPluginFileNameThe plugin filename.
[in]strClassIdThe class id of the service.
[in]strObjectIdThe object name with which the instance is registered at the runtime.
[in]nRunlevelThe service will be initialized at the given runlevel.
[in]oPropertiesName value pairs that will be set at the services configuration interface.
Returns
A pointer to the service instance.
Exceptions
tResultif an error occurred.
See also
LoadPlugin().

◆ CreateService() [4/4]

ucom::ant::object_ptr<ucom::ant::IService> CreateService ( const std::string &  strPluginFileName,
const std::string &  strClassId,
const std::string &  strObjectId,
base::ant::tADTFRunLevel  nRunlevel = base::tADTFRunLevel::RL_System 
)

Loads a plugin and creates a service instance.

Parameters
[in]strPluginFileNameThe plugin filename.
[in]strClassIdThe class id of the service.
[in]strObjectIdThe object name with which the instance is registered at the runtime.
[in]nRunlevelThe service will be initialized at the given runlevel.
Returns
A pointer to the service instance.
Exceptions
tResultif an error occurred.
See also
LoadPlugin().

◆ GetRunLevel()

base::ant::tADTFRunLevel GetRunLevel ( ) const

Helper function that returns the current runlevel.

Returns
The current runlevel.

◆ LoadPlugin()

void LoadPlugin ( const std::string &  strPluginFileName,
bool  bCreateServices = true,
base::ant::tADTFRunLevel  nServicesRunlevel = base::tADTFRunLevel::RL_System 
)

Load a plugin and optionally create instances of all found ADTF Service classes.

Parameters
[in]strPluginFileNameThe file name of the plugin. Relative filenames will be resolved within the plugin directories set during construction.
[in]bCreateServicesWhether or not to create instances of services or not.
[in]nServicesRunlevelIf services are created, they will be initialized at the given runlevel.
Exceptions
tResultif an error occurred.

◆ SetCurDirectory()

static void SetCurDirectory ( const std::string &  strRelativePath,
const std::string &  strTestSourceDirectory = ADTF_TESTING_SOURCE_DIR 
)
static

Helper function to change the current working directory relative to the source directory.

Parameters
[in]strRelativePathThe relative directory
[in]strTestSourceDirectoryThe source directory. The default is a macro that can be set by the test environment.

◆ SetMacro()

static void SetMacro ( const std::string &  strName,
const std::string &  strValue 
)
static

Set a macro value.

Parameters
[in]strNameThe name of the macro.
[in]strValueThe value that the macro should resolve to.

◆ SetRunLevel()

void SetRunLevel ( base::ant::tADTFRunLevel  eRunlevel)

Helper function that changes the runlevel and throws errors via an exception.

Parameters
[in]eRunlevelThe desired runlevel.
Exceptions
tResultif an error occurred.