|
19 | 19 | class TestComponent {
|
20 | 20 | public:
|
21 | 21 |
|
22 |
| - TestDatabaseComponent databaseComponent; |
23 |
| - |
24 |
| - /** |
25 |
| - * Create oatpp virtual network interface for test networking |
26 |
| - */ |
27 |
| - OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::virtual_::Interface>, virtualInterface)([] { |
28 |
| - return oatpp::network::virtual_::Interface::obtainShared("virtualhost"); |
29 |
| - }()); |
30 |
| - |
31 |
| - /** |
32 |
| - * Create server ConnectionProvider of oatpp virtual connections for test |
33 |
| - */ |
34 |
| - OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] { |
35 |
| - OATPP_COMPONENT(std::shared_ptr<oatpp::network::virtual_::Interface>, interface); |
36 |
| - return oatpp::network::virtual_::server::ConnectionProvider::createShared(interface); |
37 |
| - }()); |
38 |
| - |
39 |
| - /** |
40 |
| - * Create client ConnectionProvider of oatpp virtual connections for test |
41 |
| - */ |
42 |
| - OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([] { |
43 |
| - OATPP_COMPONENT(std::shared_ptr<oatpp::network::virtual_::Interface>, interface); |
44 |
| - return oatpp::network::virtual_::client::ConnectionProvider::createShared(interface); |
45 |
| - }()); |
46 |
| - |
47 |
| - /** |
48 |
| - * Create Router component |
49 |
| - */ |
50 |
| - OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, httpRouter)([] { |
51 |
| - return oatpp::web::server::HttpRouter::createShared(); |
52 |
| - }()); |
53 |
| - |
54 |
| - /** |
55 |
| - * Create ConnectionHandler component which uses Router component to route requests |
56 |
| - */ |
57 |
| - OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, serverConnectionHandler)([] { |
58 |
| - OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router); // get Router component |
59 |
| - return oatpp::web::server::HttpConnectionHandler::createShared(router); |
60 |
| - }()); |
61 |
| - |
62 |
| - /** |
63 |
| - * Create ObjectMapper component to serialize/deserialize DTOs in Contoller's API |
64 |
| - */ |
65 |
| - OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] { |
66 |
| - return oatpp::parser::json::mapping::ObjectMapper::createShared(); |
67 |
| - }()); |
| 22 | + TestDatabaseComponent databaseComponent; |
| 23 | + |
| 24 | + /** |
| 25 | + * Create oatpp virtual network interface for test networking |
| 26 | + */ |
| 27 | + OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::virtual_::Interface>, virtualInterface)([] { |
| 28 | + return oatpp::network::virtual_::Interface::obtainShared("virtualhost"); |
| 29 | + }()); |
| 30 | + |
| 31 | + /** |
| 32 | + * Create server ConnectionProvider of oatpp virtual connections for test |
| 33 | + */ |
| 34 | + OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] { |
| 35 | + OATPP_COMPONENT(std::shared_ptr<oatpp::network::virtual_::Interface>, interface); |
| 36 | + return oatpp::network::virtual_::server::ConnectionProvider::createShared(interface); |
| 37 | + }()); |
| 38 | + |
| 39 | + /** |
| 40 | + * Create client ConnectionProvider of oatpp virtual connections for test |
| 41 | + */ |
| 42 | + OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ClientConnectionProvider>, clientConnectionProvider)([] { |
| 43 | + OATPP_COMPONENT(std::shared_ptr<oatpp::network::virtual_::Interface>, interface); |
| 44 | + return oatpp::network::virtual_::client::ConnectionProvider::createShared(interface); |
| 45 | + }()); |
| 46 | + |
| 47 | + /** |
| 48 | + * Create Router component |
| 49 | + */ |
| 50 | + OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, httpRouter)([] { |
| 51 | + return oatpp::web::server::HttpRouter::createShared(); |
| 52 | + }()); |
| 53 | + |
| 54 | + /** |
| 55 | + * Create ConnectionHandler component which uses Router component to route requests |
| 56 | + */ |
| 57 | + OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, serverConnectionHandler)([] { |
| 58 | + OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router); // get Router component |
| 59 | + return oatpp::web::server::HttpConnectionHandler::createShared(router); |
| 60 | + }()); |
| 61 | + |
| 62 | + /** |
| 63 | + * Create ObjectMapper component to serialize/deserialize DTOs in Contoller's API |
| 64 | + */ |
| 65 | + OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] { |
| 66 | + return oatpp::parser::json::mapping::ObjectMapper::createShared(); |
| 67 | + }()); |
68 | 68 |
|
69 | 69 | };
|
70 | 70 |
|
|
0 commit comments