// PERFORMANCE OF THIS SOFTWARE.
#include <datasrc/rrset_collection.h>
+#include <datasrc/zone_loader.h>
#include <exceptions/exceptions.h>
using namespace isc;
// searched name is out of zone, we return nothing instead of
// propagating the exception.
return (ConstRRsetPtr());
+ } catch (const DataSourceError& e) {
+ isc_throw(FindError, "ZoneFinder threw a DataSourceError: " <<
+ e.getMessage().c_str());
}
}
/// given \c name, \c rrclass and \c rrtype. If no matching RRset
/// is found, \c NULL is returned.
///
+ /// \throw FindError if find() results in some underlying datasrc error.
/// \param name The name of the RRset to search for.
/// \param rrclass The class of the RRset to search for.
/// \param rrtype The type of the RRset to search for.
EXPECT_THROW(this->collection.end(), isc::NotImplemented);
}
+class MockRRsetCollectionTest : public DatabaseClientTest<MockAccessor> {
+public:
+ MockRRsetCollectionTest() :
+ DatabaseClientTest<MockAccessor>(),
+ collection(this->client_->getUpdater(this->zname_, false),
+ this->qclass_)
+ {}
+
+ RRsetCollection collection;
+};
+
+TEST_F(MockRRsetCollectionTest, findError) {
+ // A test using the MockAccessor for checking that FindError is
+ // thrown properly if a find attempt using ZoneFinder results in a
+ // DataSourceError.
+ //
+ // The "dsexception.example.org." name is rigged by the MockAccessor
+ // to throw a DataSourceError.
+ EXPECT_THROW({
+ this->collection.find(Name("dsexception.example.org"), this->qclass_,
+ RRType::A());
+ }, RRsetCollectionBase::FindError);
+}
+
}
/// STL container. libdatasrc will have another implementation.
class RRsetCollectionBase {
public:
+ /// \brief Error during find operation
+ ///
+ /// This exception is thrown when an calling implementation of
+ /// \c find() results in an error which is not due to unmatched
+ /// data, but because of some other underlying error condition.
+ class FindError : public Exception {
+ public:
+ FindError(const char* file, size_t line, const char* what) :
+ Exception(file, line, what)
+ {}
+ };
+
/// \brief Find a matching RRset in the collection.
///
/// Returns the RRset in the collection that exactly matches the
/// given \c name, \c rrclass and \c rrtype. If no matching RRset
/// is found, \c NULL is returned.
///
+ /// \throw FindError if find() results in some
+ /// implementation-specific error.
/// \param name The name of the RRset to search for.
/// \param rrtype The type of the RRset to search for.
/// \param rrclass The class of the RRset to search for.