src: Remove Scheduler instance from Nlsr class
refs: #1981
Change-Id: Iecbe9f975c2740ce04df8593ccde03486d4b7be8
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
new file mode 100644
index 0000000..cbb83d9
--- /dev/null
+++ b/tests/test-common.hpp
@@ -0,0 +1,48 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 University of Memphis,
+ * Regents of the University of California
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ **/
+
+#ifndef NLSR_TEST_COMMON_HPP
+#define NLSR_TEST_COMMON_HPP
+
+#include <boost/asio.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
+
+namespace nlsr {
+namespace test {
+
+class BaseFixture
+{
+public:
+ BaseFixture()
+ : g_scheduler(g_ioService)
+ {
+ }
+
+protected:
+ boost::asio::io_service g_ioService;
+ ndn::Scheduler g_scheduler;
+};
+
+} // namespace test
+} // namespace nlsr
+
+#endif
\ No newline at end of file
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 7025914..44987de 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -20,20 +20,22 @@
* \author Ashlesh Gawande <agawande@memphis.edu>
*
**/
+
+#include "test-common.hpp"
+
#include <fstream>
#include "conf-file-processor.hpp"
#include "nlsr.hpp"
#include <boost/test/unit_test.hpp>
namespace nlsr {
-
namespace test {
-BOOST_AUTO_TEST_SUITE(TestConfFileProcessor)
+BOOST_FIXTURE_TEST_SUITE(TestConfFileProcessor, BaseFixture)
BOOST_AUTO_TEST_CASE(ConfFileProcessorSample)
{
- Nlsr nlsr1;
+ Nlsr nlsr1(g_ioService, g_scheduler);
const std::string CONFIG =
"general\n"
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 430458d..84493d2 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -20,6 +20,9 @@
* \author Ashlesh Gawande <agawande@memphis.edu>
*
**/
+
+#include "test-common.hpp"
+
#include "lsdb.hpp"
#include "nlsr.hpp"
#include "lsa.hpp"
@@ -31,13 +34,13 @@
namespace test {
-BOOST_AUTO_TEST_SUITE(TestLsdb)
+BOOST_FIXTURE_TEST_SUITE(TestLsdb, BaseFixture)
BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
{
INIT_LOGGERS("/tmp", "DEBUG");
- Nlsr nlsr1;
+ Nlsr nlsr1(g_ioService, g_scheduler);
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
NamePrefixList npl1;
@@ -53,7 +56,7 @@
//1800 is the default life time.
NameLsa nlsa1(ndn::Name("/router1/1"), std::string("name"), 12, testTimePoint, npl1);
- Lsdb lsdb1(nlsr1);
+ Lsdb lsdb1(nlsr1, g_scheduler);
lsdb1.installNameLsa(nlsa1);
lsdb1.writeNameLsdbLog();
diff --git a/tests/test-routing-table.cpp b/tests/test-routing-table.cpp
index 2e2edca..fa0c371 100644
--- a/tests/test-routing-table.cpp
+++ b/tests/test-routing-table.cpp
@@ -20,20 +20,21 @@
* \author Ashlesh Gawande <agawande@memphis.edu>
*
**/
+
+#include "test-common.hpp"
#include "route/routing-table.hpp"
#include "route/routing-table-entry.hpp"
#include "route/nexthop.hpp"
#include <boost/test/unit_test.hpp>
namespace nlsr {
-
namespace test {
-BOOST_AUTO_TEST_SUITE(TestRoutingTable)
+BOOST_FIXTURE_TEST_SUITE(TestRoutingTable, BaseFixture)
BOOST_AUTO_TEST_CASE(RoutingTableAddNextHop)
{
- RoutingTable rt1;
+ RoutingTable rt1(g_scheduler);
NextHop nh1;