{
reconfigure(config);
}
+ static Server* server_;
+ static isc::config::ModuleCCSession* session_;
public:
/// \brief Initializes the class.
///
/// \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.
///
/// 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,
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\"
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)
#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());
+}
+
}
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
--- /dev/null
+{
+ "module_spec": {
+ "module_name": "test"
+ }
+}
+