Parcourir la source

[4297] storage for library parameters implemented.

Tomek Mrugalski il y a 9 ans
Parent
commit
1170c73260

+ 2 - 0
src/lib/hooks/Makefile.am

@@ -43,6 +43,7 @@ libkea_hooks_la_SOURCES += callout_manager.cc callout_manager.h
 libkea_hooks_la_SOURCES += hooks.h
 libkea_hooks_la_SOURCES += hooks_log.cc hooks_log.h
 libkea_hooks_la_SOURCES += hooks_manager.cc hooks_manager.h
+libkea_hooks_la_SOURCES += libinfo.cc libinfo.h
 libkea_hooks_la_SOURCES += library_handle.cc library_handle.h
 libkea_hooks_la_SOURCES += library_manager.cc library_manager.h
 libkea_hooks_la_SOURCES += library_manager_collection.cc library_manager_collection.h
@@ -58,6 +59,7 @@ libkea_hooks_la_LIBADD  =
 libkea_hooks_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
 libkea_hooks_la_LIBADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
 libkea_hooks_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
+libkea_hooks_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la
 libkea_hooks_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
 libkea_hooks_la_LIBADD += $(LOG4CPLUS_LIBS)
 

+ 9 - 4
src/lib/hooks/hooks_manager.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -65,7 +65,7 @@ HooksManager::callCallouts(int index, CalloutHandle& handle) {
 // (if present) and load new ones.
 
 bool
-HooksManager::loadLibrariesInternal(const std::vector<std::string>& libraries) {
+HooksManager::loadLibrariesInternal(const HookLibsCollection& libraries) {
     // Unload current set of libraries (if any are loaded).
     unloadLibrariesInternal();
 
@@ -87,7 +87,7 @@ HooksManager::loadLibrariesInternal(const std::vector<std::string>& libraries) {
 }
 
 bool
-HooksManager::loadLibraries(const std::vector<std::string>& libraries) {
+HooksManager::loadLibraries(const HookLibsCollection& libraries) {
     return (getHooksManager().loadLibrariesInternal(libraries));
 }
 
@@ -136,6 +136,11 @@ HooksManager::getLibraryNames() {
     return (getHooksManager().getLibraryNamesInternal());
 }
 
+HookLibsCollection
+HooksManager::getLibraryInfo() {
+    return (getHooksManager().getLibraryInfo());
+}
+
 // Perform conditional initialization if nothing is loaded.
 
 void
@@ -143,7 +148,7 @@ HooksManager::performConditionalInitialization() {
 
     // Nothing present, so create the collection with any empty set of
     // libraries, and get the CalloutManager.
-    vector<string> libraries;
+    HookLibsCollection libraries;
     lm_collection_.reset(new LibraryManagerCollection(libraries));
     lm_collection_->loadLibraries();
 

+ 11 - 3
src/lib/hooks/hooks_manager.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,6 +8,7 @@
 #define HOOKS_MANAGER_H
 
 #include <hooks/server_hooks.h>
+#include <hooks/libinfo.h>
 
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
@@ -61,7 +62,7 @@ public:
     /// @return true if all libraries loaded without a problem, false if one or
     ///        more libraries failed to load.  In the latter case, message will
     ///        be logged that give the reason.
-    static bool loadLibraries(const std::vector<std::string>& libraries);
+    static bool loadLibraries(const HookLibsCollection& libraries);
 
     /// @brief Unload libraries
     ///
@@ -170,6 +171,13 @@ public:
     /// @return List of loaded library names.
     static std::vector<std::string> getLibraryNames();
 
+    /// @brief Return list of loaded libraries with its parameters.
+    ///
+    /// Returns the names of the loaded libraries and its parameters.
+    ///
+    /// @return List of loaded libraries (names + parameters)
+    static HookLibsCollection getLibraryInfo();
+
     /// @brief Validate library list
     ///
     /// For each library passed to it, checks that the library can be opened
@@ -224,7 +232,7 @@ private:
     /// @return true if all libraries loaded without a problem, false if one or
     ///        more libraries failed to load.  In the latter case, message will
     ///        be logged that give the reason.
-    bool loadLibrariesInternal(const std::vector<std::string>& libraries);
+    bool loadLibrariesInternal(const HookLibsCollection& libraries);
 
     /// @brief Unload libraries
     void unloadLibrariesInternal();

+ 28 - 0
src/lib/hooks/libinfo.cc

@@ -0,0 +1,28 @@
+// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <hooks/libinfo.h>
+
+namespace isc {
+namespace hooks {
+
+/// @brief Extracts names from HookLibsCollection
+///
+/// @param libraries Hook libraries collection
+/// @return vector of strings with library names
+std::vector<std::string>
+extractNames(const isc::hooks::HookLibsCollection& libraries) {
+    std::vector<std::string> names;
+
+    for (isc::hooks::HookLibsCollection::const_iterator it = libraries.begin();
+         it != libraries.end(); ++it) {
+        names.push_back(it->first);
+    }
+    return (names);
+}
+
+};
+};

+ 41 - 0
src/lib/hooks/libinfo.h

@@ -0,0 +1,41 @@
+// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef HOOKS_LIBINFO_H
+#define HOOKS_LIBINFO_H
+
+#include <cc/data.h>
+
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+#include <vector>
+
+namespace isc {
+namespace hooks {
+
+/// @brief Entity that holds information about hook libraries and their
+/// parameters.
+///
+/// The first parameter is a full filename with path to the library.
+/// The second parameter is a map of parameters that configure the
+/// library. There's always at least one parameter: "library", which
+/// contains the library name.
+typedef std::pair<std::string, data::ConstElementPtr> HookLibInfo;
+
+/// @brief A storage for information about hook libraries.
+typedef std::vector<HookLibInfo> HookLibsCollection;
+
+/// @brief Shared pointer to collection of hooks libraries.
+typedef boost::shared_ptr<HookLibsCollection> HookLibsCollectionPtr;
+
+/// @brief Extracts library names from full library information structure
+std::vector<std::string> extractNames(const HookLibsCollection& libinfo);
+
+};
+};
+
+#endif

+ 11 - 1
src/lib/hooks/library_manager_collection.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -34,6 +34,16 @@ LibraryManagerCollection::getCalloutManager() const {
     return (callout_manager_);
 }
 
+LibraryManagerCollection::LibraryManagerCollection(const HookLibsCollection& libraries)
+    :library_info_(libraries) {
+
+    // We need to split hook libs into library names and library parameters.
+    for (HookLibsCollection::const_iterator it = libraries.begin();
+         it != libraries.end(); ++it) {
+        library_names_.push_back(it->first);
+    }
+}
+
 // Load a set of libraries
 
 bool

+ 17 - 5
src/lib/hooks/library_manager_collection.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -10,6 +10,7 @@
 #include <exceptions/exceptions.h>
 
 #include <boost/shared_ptr.hpp>
+#include <hooks/libinfo.h>
 
 #include <vector>
 
@@ -71,10 +72,9 @@ public:
     /// @brief Constructor
     ///
     /// @param libraries List of libraries that this collection will manage.
-    ///        The order of the libraries is important.
-    LibraryManagerCollection(const std::vector<std::string>& libraries)
-        : library_names_(libraries)
-    {}
+    ///        The order of the libraries is important. It holds the library
+    ///        names and its configuration parameters.
+    LibraryManagerCollection(const HookLibsCollection& libraries);
 
     /// @brief Destructor
     ///
@@ -115,6 +115,14 @@ public:
         return (library_names_);
     }
 
+    /// @brief Returns library info
+    ///
+    /// Returns a collection of libraries, each entry consisting of a library
+    /// name + all its parameters.
+    HookLibsCollection getLibraryInfo() const {
+        return (library_info_);
+    }
+
     /// @brief Get number of loaded libraries
     ///
     /// Mainly for testing, this returns the number of libraries that are
@@ -151,6 +159,10 @@ private:
     /// Vector of library managers
     std::vector<boost::shared_ptr<LibraryManager> > lib_managers_;
 
+    /// Vector of library information. Each piece of information
+    /// consists of a pair of (library name, library parameters)
+    HookLibsCollection                              library_info_;
+
     /// Callout manager to be associated with the libraries
     boost::shared_ptr<CalloutManager>               callout_manager_;
 };

+ 1 - 0
src/lib/hooks/tests/Makefile.am

@@ -126,6 +126,7 @@ endif
 run_unittests_LDADD     = $(AM_LDADD)
 run_unittests_LDADD    += $(ALL_LIBS)
 run_unittests_LDADD    += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
+run_unittests_LDADD    += $(top_builddir)/src/lib/cc/libkea-cc.la
 run_unittests_LDADD    += $(GTEST_LDADD)
 # As noted in configure.ac, libtool doesn't work perfectly with Darwin: it
 # embeds the final install path in dynamic libraries and loadable modules refer

+ 40 - 25
src/lib/hooks/tests/hooks_manager_unittest.cc

@@ -110,9 +110,11 @@ private:
 TEST_F(HooksManagerTest, LoadLibraries) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Load the libraries.
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
@@ -152,10 +154,13 @@ TEST_F(HooksManagerTest, LoadLibraries) {
 TEST_F(HooksManagerTest, LoadLibrariesWithError) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(INCORRECT_VERSION_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(INCORRECT_VERSION_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Load the libraries.  We expect a failure return because one of the
     // libraries fails to load.
@@ -168,8 +173,9 @@ TEST_F(HooksManagerTest, LoadLibrariesWithError) {
 TEST_F(HooksManagerTest, CalloutHandleUnloadLibrary) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Load the libraries.
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
@@ -202,8 +208,9 @@ TEST_F(HooksManagerTest, CalloutHandleUnloadLibrary) {
 TEST_F(HooksManagerTest, CalloutHandleLoadLibrary) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Load the libraries.
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
@@ -225,8 +232,9 @@ TEST_F(HooksManagerTest, CalloutHandleLoadLibrary) {
     // Load a new library that implements the calculation
     //
     // r3 = (10 + d1) * d2 - d3
-    std::vector<std::string> new_library_names;
-    new_library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection new_library_names;
+    new_library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                          data::ConstElementPtr()));
 
     // Load the libraries.
     EXPECT_TRUE(HooksManager::loadLibraries(new_library_names));
@@ -247,9 +255,11 @@ TEST_F(HooksManagerTest, CalloutHandleLoadLibrary) {
 TEST_F(HooksManagerTest, ReloadSameLibraries) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Load the libraries.
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
@@ -273,9 +283,11 @@ TEST_F(HooksManagerTest, ReloadSameLibraries) {
 TEST_F(HooksManagerTest, ReloadLibrariesReverseOrder) {
 
     // Set up the list of libraries to be loaded and load them.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
 
     // Execute the callouts.  The first library implements the calculation.
@@ -335,8 +347,9 @@ testPostCallout(CalloutHandle& handle) {
 TEST_F(HooksManagerTest, PrePostCalloutTest) {
 
     // Load a single library.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
 
     // Load the pre- and post- callouts.
@@ -431,9 +444,11 @@ TEST_F(HooksManagerTest, RegisterHooks) {
 TEST_F(HooksManagerTest, LibraryNames) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Check the names before the libraries are loaded.
     std::vector<std::string> loaded_names = HooksManager::getLibraryNames();
@@ -442,7 +457,7 @@ TEST_F(HooksManagerTest, LibraryNames) {
     // Load the libraries and check the names again.
     EXPECT_TRUE(HooksManager::loadLibraries(library_names));
     loaded_names = HooksManager::getLibraryNames();
-    EXPECT_TRUE(library_names == loaded_names);
+    EXPECT_TRUE(extractNames(library_names) == loaded_names);
 
     // Unload the libraries and check again.
     EXPECT_NO_THROW(HooksManager::unloadLibraries());

+ 67 - 16
src/lib/hooks/tests/library_manager_collection_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,6 +8,7 @@
 #include <hooks/callout_manager.h>
 #include <hooks/library_manager.h>
 #include <hooks/library_manager_collection.h>
+#include <hooks/libinfo.h>
 
 #include <hooks/tests/common_test_class.h>
 #include <hooks/tests/test_libraries.h>
@@ -30,6 +31,7 @@ namespace {
 class LibraryManagerCollectionTest : public ::testing::Test,
                                      public HooksCommonTestClass {
 private:
+
     /// To avoid unused variable errors
     std::string dummy(int i) {
         if (i == 0) {
@@ -54,7 +56,7 @@ public:
     ///
     /// @param List of libraries that this collection will manage.  The order
     ///        of the libraries is important.
-    PublicLibraryManagerCollection(const std::vector<std::string>& libraries)
+    PublicLibraryManagerCollection(const HookLibsCollection& libraries)
         : LibraryManagerCollection(libraries)
     {}
 
@@ -69,9 +71,11 @@ public:
 TEST_F(LibraryManagerCollectionTest, LoadLibraries) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Set up the library manager collection and get the callout manager we'll
     // be using.
@@ -118,10 +122,13 @@ TEST_F(LibraryManagerCollectionTest, LoadLibraries) {
 TEST_F(LibraryManagerCollectionTest, LoadLibrariesWithError) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(INCORRECT_VERSION_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection library_names;
+    library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                       data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(INCORRECT_VERSION_LIBRARY),
+                                      data::ConstElementPtr()));
+    library_names.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                      data::ConstElementPtr()));
 
     // Set up the library manager collection and get the callout manager we'll
     // be using.
@@ -139,7 +146,7 @@ TEST_F(LibraryManagerCollectionTest, LoadLibrariesWithError) {
 
 TEST_F(LibraryManagerCollectionTest, NoLibrariesLoaded) {
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
+    HookLibsCollection library_names;
 
     // Set up the library manager collection and get the callout manager we'll
     // be using.
@@ -159,23 +166,25 @@ TEST_F(LibraryManagerCollectionTest, NoLibrariesLoaded) {
 TEST_F(LibraryManagerCollectionTest, LibraryNames) {
 
     // Set up the list of libraries to be loaded.
-    std::vector<std::string> library_names;
-    library_names.push_back(std::string(FULL_CALLOUT_LIBRARY));
-    library_names.push_back(std::string(BASIC_CALLOUT_LIBRARY));
+    HookLibsCollection libraries;
+    libraries.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+                                  data::ConstElementPtr()));
+    libraries.push_back(make_pair(std::string(BASIC_CALLOUT_LIBRARY),
+                                  data::ConstElementPtr()));
 
     // Set up the library manager collection and get the callout manager we'll
     // be using.
-    PublicLibraryManagerCollection lm_collection(library_names);
+    PublicLibraryManagerCollection lm_collection(libraries);
 
     // Check the names before the libraries are loaded.
     std::vector<std::string> collection_names = lm_collection.getLibraryNames();
-    EXPECT_TRUE(library_names == collection_names);
+    EXPECT_TRUE(extractNames(libraries) == collection_names);
 
     // Load the libraries and check the names again.
     EXPECT_TRUE(lm_collection.loadLibraries());
     EXPECT_EQ(2, lm_collection.getLoadedLibraryCount());
     collection_names = lm_collection.getLibraryNames();
-    EXPECT_TRUE(library_names == collection_names);
+    EXPECT_TRUE(extractNames(libraries) == collection_names);
 }
 
 // Test the library validation function.
@@ -251,4 +260,46 @@ TEST_F(LibraryManagerCollectionTest, validateLibraries) {
     EXPECT_TRUE(failed == expected_failures);
 }
 
+// This test verifies if getLibraryNames and getLibraryInfo are returning
+// expected values if there are no libraries configured.
+TEST_F(LibraryManagerCollectionTest, libraryGetEmpty) {
+
+    HookLibsCollection empty;
+    boost::shared_ptr<LibraryManagerCollection> mgr;
+
+    // Instantiate library manager collection with no libraries
+    EXPECT_NO_THROW(mgr.reset(new LibraryManagerCollection(empty)));
+
+    // Check that getLibraryInfo returns empty list properly.
+    HookLibsCollection returned = mgr->getLibraryInfo();
+    EXPECT_TRUE(returned.empty());
+
+    // Check that getLibraryNames return empty list, too.
+    vector<string> names(3, "rubbish"); // just put something in it.
+    EXPECT_NO_THROW(names = mgr->getLibraryNames());
+    EXPECT_TRUE(names.empty());
+}
+
+// This test verifies if getLibraryNames and getLibraryInfo are returning
+// expected values when there are libraries configured.
+TEST_F(LibraryManagerCollectionTest, libraryGet) {
+    using namespace data;
+
+    HookLibsCollection libs;
+    ElementPtr param1(Element::fromJSON("{ \"param1\": \"foo\" }"));
+    ElementPtr param2(Element::fromJSON("{ \"param2\": \"bar\" }"));
+    libs.push_back(make_pair("libone", param1));
+    libs.push_back(make_pair("libtwo", param2));
+
+    boost::shared_ptr<LibraryManagerCollection> mgr;
+    EXPECT_NO_THROW(mgr.reset(new LibraryManagerCollection(libs)));
+    EXPECT_TRUE(libs == mgr->getLibraryInfo());
+
+    vector<string> exp_names;
+    exp_names.push_back("libone");
+    exp_names.push_back("libtwo");
+
+    EXPECT_TRUE(exp_names == mgr->getLibraryNames());
+}
+
 } // Anonymous namespace