Commit 50ca8b1b authored by JINMEI Tatuya's avatar JINMEI Tatuya

[2470] added wrapper interface to create null loader callbacks

this is especially useful for tests.
parent c3d1b180
......@@ -124,7 +124,7 @@ libb10_dns___la_SOURCES += tsigerror.h tsigerror.cc
libb10_dns___la_SOURCES += tsigkey.h tsigkey.cc
libb10_dns___la_SOURCES += tsigrecord.h tsigrecord.cc
libb10_dns___la_SOURCES += character_string.h character_string.cc
libb10_dns___la_SOURCES += master_loader_callbacks.h
libb10_dns___la_SOURCES += master_loader_callbacks.h master_loader_callbacks.cc
libb10_dns___la_SOURCES += master_loader.h
libb10_dns___la_SOURCES += rdata/generic/detail/char_string.h
libb10_dns___la_SOURCES += rdata/generic/detail/char_string.cc
......
......@@ -122,6 +122,16 @@ public:
warning_(source_name, source_line, reason);
}
/// \brief Return a callbacks instance with null callbacks
///
/// This is a convenience wrapper to generate a
/// \c MasterLoaderCallbacks object with both callbacks being nothing.
/// This will be useful for applications that only need to run
/// \c MasterLoader and get the end result.
///
/// \throw None
static MasterLoaderCallbacks getNullCallbacks();
private:
IssueCallback error_, warning_;
};
......
......@@ -53,17 +53,11 @@ const uint8_t wiredata_txt_like[] = {
const uint8_t wiredata_nulltxt[] = { 0 };
// For lexer-based constructor
void
dummyCallback(const string&, size_t, const string&) {
}
template<class TXT_LIKE>
class Rdata_TXT_LIKE_Test : public RdataTest {
protected:
Rdata_TXT_LIKE_Test() :
callback(boost::bind(&dummyCallback, _1, _2, _3)),
loader_cb(callback, callback),
loader_cb(MasterLoaderCallbacks::getNullCallbacks()),
wiredata_longesttxt(256, 'a'),
rdata_txt_like("Test-String"),
rdata_txt_like_empty("\"\""),
......@@ -72,9 +66,6 @@ protected:
wiredata_longesttxt[0] = 255; // adjust length
}
private:
const MasterLoaderCallbacks::IssueCallback callback;
protected:
MasterLoaderCallbacks loader_cb;
vector<uint8_t> wiredata_longesttxt;
......
......@@ -60,10 +60,6 @@ RdataTest::rdataFactoryFromFile(const RRType& rrtype, const RRClass& rrclass,
namespace test {
void
dummyCallback(const string&, size_t, const string&) {
}
RdataPtr
createRdataUsingLexer(const RRType& rrtype, const RRClass& rrclass,
const std::string& str)
......@@ -72,9 +68,8 @@ createRdataUsingLexer(const RRType& rrtype, const RRClass& rrclass,
MasterLexer lexer;
lexer.pushSource(ss);
const MasterLoaderCallbacks::IssueCallback callback
(boost::bind(&dummyCallback, _1, _2, _3));
MasterLoaderCallbacks callbacks(callback, callback);
MasterLoaderCallbacks callbacks =
MasterLoaderCallbacks::getNullCallbacks();
const Name origin("example.org.");
return (createRdata(rrtype, rrclass, lexer, &origin,
......
......@@ -157,10 +157,6 @@ TEST_F(RRParamRegistryTest, addRemoveFactory) {
RRType(test_type_code)));
}
void
dummyCallback(const string&, size_t, const string&) {
}
RdataPtr
createRdataHelper(const std::string& str) {
boost::scoped_ptr<AbstractRdataFactory> rdf(new TestRdataFactory);
......@@ -169,9 +165,7 @@ createRdataHelper(const std::string& str) {
MasterLexer lexer;
lexer.pushSource(ss);
const MasterLoaderCallbacks::IssueCallback callback
(boost::bind(&dummyCallback, _1, _2, _3));
MasterLoaderCallbacks callbacks(callback, callback);
MasterLoaderCallbacks callbacks(MasterLoaderCallbacks::getNullCallbacks());
const Name origin("example.org.");
return (rdf->create(lexer, &origin,
......
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