BIND 10 trac1976, updated. 2536cfbce01e0fdd5b3d891beeedf2105ec8178c [1976] Initialization
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jun 20 15:10:59 UTC 2012
The branch, trac1976 has been updated
via 2536cfbce01e0fdd5b3d891beeedf2105ec8178c (commit)
from 7ef59689d4277f0fa9fa43996c7c19ac509e741d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2536cfbce01e0fdd5b3d891beeedf2105ec8178c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Jun 20 17:10:47 2012 +0200
[1976] Initialization
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/datasrc_configurator.h | 38 ++++++++++-
src/bin/auth/tests/Makefile.am | 2 +
.../auth/tests/datasrc_configurator_unittest.cc | 67 ++++++++++++++++++++
src/bin/auth/tests/testdata/Makefile.am | 1 +
.../auth}/tests/testdata/spec.spec | 0
5 files changed, 105 insertions(+), 3 deletions(-)
copy src/{lib/server_common => bin/auth}/tests/testdata/spec.spec (100%)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/datasrc_configurator.h b/src/bin/auth/datasrc_configurator.h
index f805c6c..d5ba529 100644
--- a/src/bin/auth/datasrc_configurator.h
+++ b/src/bin/auth/datasrc_configurator.h
@@ -47,6 +47,8 @@ private:
{
reconfigure(config);
}
+ static Server* server_;
+ static isc::config::ModuleCCSession* session_;
public:
/// \brief Initializes the class.
///
@@ -61,13 +63,25 @@ public:
/// \param session The session to hook into and to access the configuration
/// through.
/// \param server It is the server to configure.
- /// \throw InvalidOperation if this is called when already initialized.
+ /// \throw isc::InvalidOperation if this is called when already initialized.
+ /// \throw isc::InvalidParameter if any of the parameters is NULL
/// \throw isc::config::ModuleCCError if the remote configuration is not
/// available for some reason.
static void init(isc::config::ModuleCCSession *session,
Server *server)
{
-
+ if (session == NULL) {
+ isc_throw(isc::InvalidParameter, "The session must not be NULL");
+ }
+ if (server == NULL) {
+ isc_throw(isc::InvalidParameter, "The server must not be NULL");
+ }
+ if (server_ != NULL) {
+ isc_throw(isc::InvalidOperation,
+ "The configurator is already initialized");
+ }
+ server_ = server;
+ session_ = session;
}
/// \brief Deinitializes the class.
///
@@ -77,13 +91,31 @@ public:
/// This can be called even if it is not initialized currently. You
/// can initialize it again after this.
static void deinit() {
-
+ session_ = NULL;
+ server_ = NULL;
}
+ /// \brief Reads new configuration and replaces the old one.
+ ///
+ /// It instructs the server to replace the lists with new ones as needed.
+ /// You don't need to call it directly (but you could, though the benefit
+ /// is unkown and it would be questionable at least). It is called
+ /// automatically on normal updates.
+ ///
+ /// \param config The configuration value to parse. It is in the form
+ /// as an update from the config manager.
+ /// \throw InvalidOperation if it is called when not initialized.
static void reconfigure(const isc::data::ConstElementPtr& config) {
}
};
+template<class Server, class List>
+isc::config::ModuleCCSession*
+DataSourceConfiguratorGeneric<Server, List>::session_(NULL);
+
+template<class Server, class List>
+Server* DataSourceConfiguratorGeneric<Server, List>::server_(NULL);
+
/// \brief Concrete version of DataSourceConfiguratorGeneric for the
/// use in authoritative server.
typedef DataSourceConfiguratorGeneric<AuthSrv,
diff --git a/src/bin/auth/tests/Makefile.am b/src/bin/auth/tests/Makefile.am
index 74d3bed..bdb5eaa 100644
--- a/src/bin/auth/tests/Makefile.am
+++ b/src/bin/auth/tests/Makefile.am
@@ -5,6 +5,7 @@ AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DAUTH_OBJ_DIR=\"$(abs_top_builddir)/src/bin/auth\"
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_top_srcdir)/src/lib/testutils/testdata\"
+AM_CPPFLAGS += -DTEST_OWN_DATA_DIR=\"$(abs_top_srcdir)/src/bin/auth/tests/testdata\"
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/testutils/testdata\"
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
@@ -73,6 +74,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
run_unittests_LDADD += $(top_builddir)/src/lib/statistics/libstatistics.la
+run_unittests_LDADD += $(top_builddir)/src/lib/config/tests/libfake_session.la
run_unittests_LDADD += $(GTEST_LDADD)
run_unittests_LDADD += $(SQLITE_LIBS)
diff --git a/src/bin/auth/tests/datasrc_configurator_unittest.cc b/src/bin/auth/tests/datasrc_configurator_unittest.cc
index 6144064..032b603 100644
--- a/src/bin/auth/tests/datasrc_configurator_unittest.cc
+++ b/src/bin/auth/tests/datasrc_configurator_unittest.cc
@@ -14,6 +14,73 @@
#include <auth/datasrc_configurator.h>
+#include <config/tests/fake_session.h>
+#include <config/ccsession.h>
+
+#include <gtest/gtest.h>
+#include <memory>
+
+using namespace isc;
+using namespace isc::cc;
+using namespace isc::config;
+using namespace isc::data;
+using namespace std;
+
namespace {
+class DatasrcConfiguratorTest;
+
+class FakeList {
+
+};
+
+// We use the test fixture as both parameters, this makes it possible
+// to easily fake all needed methods and look that they were called.
+typedef DataSourceConfiguratorGeneric<DatasrcConfiguratorTest,
+ FakeList> Configurator;
+
+class DatasrcConfiguratorTest : public ::testing::Test {
+protected:
+ DatasrcConfiguratorTest() :
+ session(ElementPtr(new ListElement), ElementPtr(new ListElement),
+ ElementPtr(new ListElement)),
+ specfile(string(TEST_OWN_DATA_DIR) + "/spec.spec")
+ {
+ initSession();
+ }
+ void initSession() {
+ session.getMessages()->add(createAnswer());
+ mccs.reset(new ModuleCCSession(specfile, session, NULL, NULL, false,
+ false));
+ }
+ void TearDown() {
+ // Make sure no matter what we did, it is cleaned up.
+ Configurator::deinit();
+ }
+ void init() {
+ Configurator::init(mccs.get(), this);
+ }
+ void SetUp() {
+ init();
+ }
+ FakeSession session;
+ auto_ptr<ModuleCCSession> mccs;
+ const string specfile;
+};
+
+// Check the initialization (and deinitialization)
+TEST_F(DatasrcConfiguratorTest, initialization) {
+ // It can't be initialized again
+ EXPECT_THROW(init(), InvalidOperation);
+ // Deinitialize to make the tests reasonable
+ Configurator::deinit();
+ // Make sure there are enough messages in it, etc.
+ initSession();
+ // If one of them is NULL, it does not work
+ EXPECT_THROW(Configurator::init(NULL, this), InvalidParameter);
+ EXPECT_THROW(Configurator::init(mccs.get(), NULL), InvalidParameter);
+ // But we can initialize it again now
+ EXPECT_NO_THROW(init());
+}
+
}
diff --git a/src/bin/auth/tests/testdata/Makefile.am b/src/bin/auth/tests/testdata/Makefile.am
index c86722f..7e42b70 100644
--- a/src/bin/auth/tests/testdata/Makefile.am
+++ b/src/bin/auth/tests/testdata/Makefile.am
@@ -18,6 +18,7 @@ EXTRA_DIST += shortquestion_fromWire
EXTRA_DIST += shortresponse_fromWire
EXTRA_DIST += simplequery_fromWire.spec
EXTRA_DIST += simpleresponse_fromWire.spec
+EXTRA_DIST += spec.spec
EXTRA_DIST += example.com
EXTRA_DIST += example.sqlite3
diff --git a/src/bin/auth/tests/testdata/spec.spec b/src/bin/auth/tests/testdata/spec.spec
new file mode 100644
index 0000000..3e0a822
--- /dev/null
+++ b/src/bin/auth/tests/testdata/spec.spec
@@ -0,0 +1,6 @@
+{
+ "module_spec": {
+ "module_name": "test"
+ }
+}
+
More information about the bind10-changes
mailing list