Commit 86c78e9e authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2376] Rename LoaderCallbacks to MasterLoaderCallbacks

And few other similar renames.
parent dc964cd2
......@@ -50,24 +50,26 @@ logWarning(const isc::dns::Name& name, const isc::dns::RRClass& rrclass,
}
isc::dns::LoaderCallbacks
createCallbacks(ZoneUpdater& updater, const isc::dns::Name& name,
const isc::dns::RRClass& rrclass, bool* ok)
isc::dns::MasterLoaderCallbacks
createMasterLoaderCallbacks(ZoneUpdater& updater, const isc::dns::Name& name,
const isc::dns::RRClass& rrclass, bool* ok)
{
return (isc::dns::LoaderCallbacks(boost::bind(&logError, name, rrclass, ok,
_1, _2, _3),
boost::bind(&logWarning, name, rrclass,
_1, _2, _3),
boost::bind(&ZoneUpdater::addRRset,
&updater,
// The callback provides a
// shared pointer, we need
// the object. This bind
// unpacks the object.
boost::bind(&isc::dns::
RRsetPtr::
operator*,
_1))));
return (isc::dns::MasterLoaderCallbacks(boost::bind(&logError, name,
rrclass, ok, _1, _2,
_3),
boost::bind(&logWarning, name,
rrclass, _1, _2, _3),
boost::bind(&ZoneUpdater::addRRset,
&updater,
// The callback provides
// a shared pointer, we
// need the object. This
// bind unpacks the
// object.
boost::bind(&isc::dns::
RRsetPtr::
operator*,
_1))));
}
}
......
......@@ -40,9 +40,9 @@ class ZoneUpdater;
/// the loading, it is set to false. Otherwise, it is untouched.
/// \return Set of callbacks to be passed to the master loader.
/// \throw std::bad_alloc when allocation fails.
isc::dns::LoaderCallbacks
createCallbacks(ZoneUpdater& updater, const isc::dns::Name& name,
const isc::dns::RRClass& rrclass, bool* ok);
isc::dns::MasterLoaderCallbacks
createMasterLoaderCallbacks(ZoneUpdater& updater, const isc::dns::Name& name,
const isc::dns::RRClass& rrclass, bool* ok);
}
}
......
......@@ -59,12 +59,13 @@ public:
std::list<isc::dns::RRsetPtr> expected_rrsets_;
};
class LoaderCallbackTest : public ::testing::Test {
class MasterLoaderCallbackTest : public ::testing::Test {
protected:
LoaderCallbackTest() :
MasterLoaderCallbackTest() :
ok_(true),
callbacks_(createCallbacks(updater_, isc::dns::Name("example.org"),
isc::dns::RRClass::IN(), &ok_))
callbacks_(createMasterLoaderCallbacks(updater_,
isc::dns::Name("example.org"),
isc::dns::RRClass::IN(), &ok_))
{}
// Generate a new RRset, put it to the updater and return it.
isc::dns::RRsetPtr generateRRset() {
......@@ -81,20 +82,20 @@ protected:
// Is the loading OK?
bool ok_;
// The tested context
isc::dns::LoaderCallbacks callbacks_;
isc::dns::MasterLoaderCallbacks callbacks_;
};
// Check it doesn't crash if we don't provide the OK
TEST_F(LoaderCallbackTest, noOkProvided) {
createCallbacks(updater_, isc::dns::Name("example.org"),
isc::dns::RRClass::IN(), NULL).error("No source", 1,
"No reason");
TEST_F(MasterLoaderCallbackTest, noOkProvided) {
createMasterLoaderCallbacks(updater_, isc::dns::Name("example.org"),
isc::dns::RRClass::IN(), NULL).
error("No source", 1, "No reason");
}
// Check the callbacks can be called, don't crash and the error one switches
// to non-OK mode. This, however, does not stop anybody from calling more
// callbacks.
TEST_F(LoaderCallbackTest, callbacks) {
TEST_F(MasterLoaderCallbackTest, callbacks) {
EXPECT_NO_THROW(callbacks_.warning("No source", 1, "Just for fun"));
// The warning does not hurt the OK mode.
EXPECT_TRUE(ok_);
......@@ -111,7 +112,7 @@ TEST_F(LoaderCallbackTest, callbacks) {
}
// Try adding some RRsets.
TEST_F(LoaderCallbackTest, addRRset) {
TEST_F(MasterLoaderCallbackTest, addRRset) {
// Put some of them in.
EXPECT_NO_THROW(callbacks_.addRRset(generateRRset()));
EXPECT_NO_THROW(callbacks_.addRRset(generateRRset()));
......
......@@ -31,7 +31,7 @@ namespace dns {
/// can report loaded RRsets, errors and other unusual conditions.
///
/// All the callbacks must be set.
class LoaderCallbacks {
class MasterLoaderCallbacks {
public:
/// \brief Type of one callback to report problems.
///
......@@ -66,8 +66,9 @@ public:
/// \param warning The warning callback to use.
/// \param add The add callback to use.
/// \throw isc::InvalidParameter if any of the callbacks is empty.
LoaderCallbacks(const IssueCallback& error, const IssueCallback& warning,
const AddCallback& add) :
MasterLoaderCallbacks(const IssueCallback& error,
const IssueCallback& warning,
const AddCallback& add) :
error_(error),
warning_(warning),
add_(add)
......
......@@ -27,18 +27,18 @@ namespace {
using std::string;
using namespace isc::dns;
class LoaderCallbacksTest : public ::testing::Test {
class MasterLoaderCallbacksTest : public ::testing::Test {
protected:
LoaderCallbacksTest() :
MasterLoaderCallbacksTest() :
issue_called_(false),
add_called_(false),
rrset_(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
RRTTL(3600))),
error_(boost::bind(&LoaderCallbacksTest::checkCallback, this, true, _1,
_2, _3)),
warning_(boost::bind(&LoaderCallbacksTest::checkCallback, this, false,
_1, _2, _3)),
add_(boost::bind(&LoaderCallbacksTest::checkAdd, this, _1)),
error_(boost::bind(&MasterLoaderCallbacksTest::checkCallback, this,
true, _1, _2, _3)),
warning_(boost::bind(&MasterLoaderCallbacksTest::checkCallback, this,
false, _1, _2, _3)),
add_(boost::bind(&MasterLoaderCallbacksTest::checkAdd, this, _1)),
callbacks_(error_, warning_, add_)
{}
......@@ -58,25 +58,26 @@ protected:
bool last_was_error_;
bool issue_called_, add_called_;
const RRsetPtr rrset_;
const LoaderCallbacks::IssueCallback error_, warning_;
const LoaderCallbacks::AddCallback add_;
LoaderCallbacks callbacks_;
const MasterLoaderCallbacks::IssueCallback error_, warning_;
const MasterLoaderCallbacks::AddCallback add_;
MasterLoaderCallbacks callbacks_;
};
// Check the constructor rejects empty callbacks, but accepts non-empty ones
TEST_F(LoaderCallbacksTest, constructor) {
EXPECT_THROW(LoaderCallbacks(LoaderCallbacks::IssueCallback(), warning_,
add_), isc::InvalidParameter);
EXPECT_THROW(LoaderCallbacks(error_, LoaderCallbacks::IssueCallback(),
add_), isc::InvalidParameter);
EXPECT_THROW(LoaderCallbacks(error_, warning_,
LoaderCallbacks::AddCallback()),
TEST_F(MasterLoaderCallbacksTest, constructor) {
EXPECT_THROW(MasterLoaderCallbacks(MasterLoaderCallbacks::IssueCallback(),
warning_, add_), isc::InvalidParameter);
EXPECT_THROW(MasterLoaderCallbacks(error_,
MasterLoaderCallbacks::IssueCallback(),
add_), isc::InvalidParameter);
EXPECT_THROW(MasterLoaderCallbacks(error_, warning_,
MasterLoaderCallbacks::AddCallback()),
isc::InvalidParameter);
EXPECT_NO_THROW(LoaderCallbacks(error_, warning_, add_));
EXPECT_NO_THROW(MasterLoaderCallbacks(error_, warning_, add_));
}
// Call the issue callbacks
TEST_F(LoaderCallbacksTest, issueCall) {
TEST_F(MasterLoaderCallbacksTest, issueCall) {
callbacks_.error("source", 1, "reason");
EXPECT_TRUE(last_was_error_);
EXPECT_TRUE(issue_called_);
......@@ -89,7 +90,7 @@ TEST_F(LoaderCallbacksTest, issueCall) {
}
// Call the add callback
TEST_F(LoaderCallbacksTest, addCall) {
TEST_F(MasterLoaderCallbacksTest, addCall) {
EXPECT_FALSE(issue_called_);
callbacks_.addRRset(rrset_);
EXPECT_TRUE(add_called_);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment