unit-test: Move asio server to its own class

Other test suites will need this object so move to a utility directory
and inherit from.

Change-Id: Ia34c8149fc0df02c510717a6efd21f51086e97e6
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/src/test/associations.cpp b/src/test/associations.cpp
index d5f86f4..acfa884 100644
--- a/src/test/associations.cpp
+++ b/src/test/associations.cpp
@@ -1,36 +1,17 @@
 #include "src/associations.hpp"
 
+#include "src/test/util/asio_server_class.hpp"
+
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 
 #include <gtest/gtest.h>
 
-class TestAssociations : public testing::Test
+class TestAssociations : public AsioServerClassTest
 {
-  protected:
-    // Make this global to the whole test suite since we want to share
-    // the asio::object_server accross the test cases
-    // NOTE - latest googltest changed to SetUpTestSuite()
-    static void SetUpTestCase()
-    {
-        boost::asio::io_context io;
-        auto conn = std::make_shared<sdbusplus::asio::connection>(io);
-
-        conn->request_name("xyz.openbmc_project.ObjMgr.Test");
-        server = new sdbusplus::asio::object_server(conn);
-    }
-
-    // NOTE - latest googltest changed to TearDownTestSuite()
-    static void TearDownTestCase()
-    {
-        delete server;
-        server = nullptr;
-    }
-
-    static sdbusplus::asio::object_server* server;
 };
-
-sdbusplus::asio::object_server* TestAssociations::server = nullptr;
+sdbusplus::asio::object_server* TestAssociations::AsioServerClassTest::server =
+    nullptr;
 
 const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1";
 const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface";
diff --git a/src/test/util/asio_server_class.hpp b/src/test/util/asio_server_class.hpp
new file mode 100644
index 0000000..34b2095
--- /dev/null
+++ b/src/test/util/asio_server_class.hpp
@@ -0,0 +1,34 @@
+#include "src/associations.hpp"
+
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+
+#include <gtest/gtest.h>
+/** @class AsioServerClassTest
+ *
+ *  @brief Provide wrapper for creating asio::object_server for test suite
+ */
+class AsioServerClassTest : public testing::Test
+{
+  protected:
+    // Make this global to the whole test suite since we want to share
+    // the asio::object_server accross the test cases
+    // NOTE - latest googltest changed to SetUpTestSuite()
+    static void SetUpTestCase()
+    {
+        boost::asio::io_context io;
+        auto conn = std::make_shared<sdbusplus::asio::connection>(io);
+
+        conn->request_name("xyz.openbmc_project.ObjMgr.Test");
+        server = new sdbusplus::asio::object_server(conn);
+    }
+
+    // NOTE - latest googltest changed to TearDownTestSuite()
+    static void TearDownTestCase()
+    {
+        delete server;
+        server = nullptr;
+    }
+
+    static sdbusplus::asio::object_server* server;
+};