From: Michal 'vorner' Vaner Date: Mon, 4 Jun 2012 15:17:50 +0000 (+0200) Subject: [1975] The test data source now returns X-Git-Tag: trac2351_base~97^2~9^2~4^2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1af1f3ba715af99d1fbade8eea193deabb405a5;p=thirdparty%2Fkea.git [1975] The test data source now returns --- diff --git a/src/lib/datasrc/tests/container_unittest.cc b/src/lib/datasrc/tests/container_unittest.cc index 5131f14da3..0d6bb0c959 100644 --- a/src/lib/datasrc/tests/container_unittest.cc +++ b/src/lib/datasrc/tests/container_unittest.cc @@ -15,6 +15,8 @@ #include #include +#include + #include #include @@ -41,13 +43,57 @@ public: // A test data source. It pretends it has some zones. class TestDS : public DataSourceClient { public: + class Finder : public ZoneFinder { + public: + Finder(const Name& origin) : + origin_(origin) + { } + Name getOrigin() const { return (origin_); } + // The rest is not to be called, so just have them + RRClass getClass() const { + isc_throw(isc::NotImplemented, "Not implemented"); + } + shared_ptr find(const Name&, const RRType&, + const FindOptions) + { + isc_throw(isc::NotImplemented, "Not implemented"); + } + shared_ptr findAll(const Name&, + vector&, + const FindOptions) + { + isc_throw(isc::NotImplemented, "Not implemented"); + } + FindNSEC3Result findNSEC3(const Name&, bool) { + isc_throw(isc::NotImplemented, "Not implemented"); + } + Name findPreviousName(const Name&) const { + isc_throw(isc::NotImplemented, "Not implemented"); + } + private: + Name origin_; + }; TestDS(const char* zone_names[]) { for (const char** zone(zone_names); *zone; ++ zone) { zones.insert(Name(*zone)); } } - virtual FindResult findZone(const Name& ) const { - isc_throw(isc::NotImplemented, "Not implemented"); + virtual FindResult findZone(const Name& name) const { + set::const_iterator it(zones.lower_bound(name)); + if (it == zones.end()) { + return (FindResult(result::NOTFOUND, ZoneFinderPtr())); + } else { + NameComparisonResult compar(it->compare(name)); + const ZoneFinderPtr finder(new Finder(*it)); + switch (compar.getRelation()) { + case NameComparisonResult::EQUAL: + return (FindResult(result::SUCCESS, finder)); + case NameComparisonResult::SUPERDOMAIN: + return (FindResult(result::PARTIALMATCH, finder)); + default: + return (FindResult(result::NOTFOUND, ZoneFinderPtr())); + } + } } // These methods are not used. They just need to be there to have // complete vtable.