verion which did not include the handling in RTService wth creating the
Json file
This commit is contained in:
61
vrpmdvaotserver/test/app/TestDatabaseComponent.hpp
Normal file
61
vrpmdvaotserver/test/app/TestDatabaseComponent.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
#ifndef TEST_DATABASECOMPONENT_HPP
|
||||
#define TEST_DATABASECOMPONENT_HPP
|
||||
|
||||
#include "db/UserDb.hpp"
|
||||
#include "db/MonitoringDb.hpp"
|
||||
|
||||
class TestDatabaseComponent {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create database connection provider component
|
||||
*/
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::provider::Provider<oatpp::sqlite::Connection>>, dbConnectionProvider)([] {
|
||||
|
||||
/* Create database-specific ConnectionProvider */
|
||||
auto connectionProvider = std::make_shared<oatpp::sqlite::ConnectionProvider>(TESTDATABASE_FILE);
|
||||
|
||||
/* Create database-specific ConnectionPool */
|
||||
return oatpp::sqlite::ConnectionPool::createShared(connectionProvider,
|
||||
10 /* max-connections */,
|
||||
std::chrono::seconds(5) /* connection TTL */);
|
||||
|
||||
}());
|
||||
|
||||
/**
|
||||
* Create database client
|
||||
*/
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<UserDb>, userDb)([] {
|
||||
|
||||
/* Get database ConnectionProvider component */
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::provider::Provider<oatpp::sqlite::Connection>>, connectionProvider);
|
||||
|
||||
/* Create database-specific Executor */
|
||||
auto executor = std::make_shared<oatpp::sqlite::Executor>(connectionProvider);
|
||||
|
||||
/* Create MyClient database client */
|
||||
return std::make_shared<UserDb>(executor);
|
||||
|
||||
}());
|
||||
|
||||
/**
|
||||
* Create database client
|
||||
*/
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<MonitoringDb>, monitoringDb)([] {
|
||||
|
||||
/* Get database ConnectionProvider component */
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::provider::Provider<oatpp::sqlite::Connection>>, connectionProvider);
|
||||
|
||||
/* Create database-specific Executor */
|
||||
auto executor = std::make_shared<oatpp::sqlite::Executor>(connectionProvider);
|
||||
|
||||
/* Create MyClient database client */
|
||||
return std::make_shared<MonitoringDb>(executor);
|
||||
|
||||
}());
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //TEST_DATABASECOMPONENT_HPP
|
||||
Reference in New Issue
Block a user