1 #include <gtest/gtest.h>
2 #include <experimental/filesystem>
3 #include <sdbusplus/bus.hpp>
4 #include "config.h"
5 #include "phosphor-rsyslog-config/server-conf.hpp"
6 #include "gmock/gmock.h"
7 
8 namespace phosphor
9 {
10 namespace logging
11 {
12 namespace test
13 {
14 
15 namespace fs = std::experimental::filesystem;
16 
17 char tmplt[] = "/tmp/logging_test.XXXXXX";
18 auto bus = sdbusplus::bus::new_default();
19 fs::path dir(fs::path(mkdtemp(tmplt)));
20 
21 class MockServer : public phosphor::rsyslog_config::Server
22 {
23     public:
24         MockServer(sdbusplus::bus::bus& bus,
25                const std::string& path,
26                const char* filePath) :
27             phosphor::rsyslog_config::Server(bus, path, filePath)
28         {
29         }
30 
31         MOCK_METHOD0(restart, void());
32 };
33 
34 class TestRemoteLogging : public testing::Test
35 {
36     public:
37         TestRemoteLogging()
38         {
39             configFilePath = std::string(dir.c_str()) + "/server.conf";
40             config =
41                 new MockServer(bus,
42                                BUSPATH_REMOTE_LOGGING_CONFIG,
43                                configFilePath.c_str());
44         }
45 
46         ~TestRemoteLogging()
47         {
48             delete config;
49         }
50 
51         static void TearDownTestCase()
52         {
53             fs::remove_all(dir);
54         }
55 
56         MockServer* config;
57         std::string configFilePath;
58 };
59 
60 } // namespace test
61 } // namespace logging
62 } // namespace phosphor
63 
64 
65