From: Michal 'vorner' Vaner Date: Thu, 29 Nov 2012 14:25:49 +0000 (+0100) Subject: [2378] It would throw at load(), not constructor X-Git-Tag: bind10-1.0.0-beta-release~28^2~2^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=807b5a13c25760f09f10bb8ea9242277b8928fdb;p=thirdparty%2Fkea.git [2378] It would throw at load(), not constructor There's no way to know the master file would be broken in the constructor. So update the documentation to say it'd throw from the load() and loadIncremental(). --- diff --git a/src/lib/datasrc/tests/zone_loader_unittest.cc b/src/lib/datasrc/tests/zone_loader_unittest.cc index 8f03bfc55c..ccc5b9d28d 100644 --- a/src/lib/datasrc/tests/zone_loader_unittest.cc +++ b/src/lib/datasrc/tests/zone_loader_unittest.cc @@ -32,8 +32,11 @@ using isc::dns::RRClass; using isc::dns::Name; +using isc::dns::RRType; +using isc::dns::ConstRRsetPtr; using std::string; using std::vector; +using boost::shared_ptr; using namespace isc::datasrc; namespace { @@ -168,7 +171,7 @@ private: // FIXME: We should be destroying it by ZoneTableSegment::destroy. // But the shared pointer won't let us, will it? - boost::shared_ptr ztable_segment_; + shared_ptr ztable_segment_; protected: memory::InMemoryClient source_client_; // This one is mocked. It will help us see what is happening inside. @@ -380,12 +383,13 @@ TEST_F(ZoneLoaderTest, loadNoSuchFile) { // And it also throws when there's a syntax error in the master file TEST_F(ZoneLoaderTest, loadSyntaxError) { - EXPECT_THROW(ZoneLoader(destination_client_, Name::ROOT_NAME(), - // This is not a master file for sure - // (misusing a file that happens to be there - // already). - TEST_DATA_DIR "/example.org.sqlite3"), - MasterFileError); + ZoneLoader loader(destination_client_, Name::ROOT_NAME(), + // This is not a master file for sure + // (misusing a file that happens to be there + // already). + TEST_DATA_DIR "/example.org.sqlite3"); + EXPECT_THROW(loader.load(), MasterFileError); + EXPECT_FALSE(destination_client_.commit_called_); } } diff --git a/src/lib/datasrc/zone_loader.h b/src/lib/datasrc/zone_loader.h index c0f241032d..17eb57e083 100644 --- a/src/lib/datasrc/zone_loader.h +++ b/src/lib/datasrc/zone_loader.h @@ -69,8 +69,6 @@ public: /// beforehead. /// \throw DataSourceError in case of other (possibly low-level) errors, /// such as read-only data source or database error. - /// \throw MasterFileError when the master_file is badly formatted or some - /// similar problem is found when loading the master file. ZoneLoader(DataSourceClient& destination, const isc::dns::Name& zone_name, const char* master_file); @@ -104,6 +102,8 @@ public: /// \throw InvalidOperation in case the loading was already completed /// before this call. /// \throw DataSourceError in case some error (possibly low-level) happens. + /// \throw MasterFileError when the master_file is badly formatted or some + /// similar problem is found when loading the master file. void load() { while (!loadIncremental(1000)) { // 1000 is arbitrary largish number // Body intentionally left blank. @@ -128,6 +128,8 @@ public: /// before this call (by load() or by a loadIncremental that returned /// true). /// \throw DataSourceError in case some error (possibly low-level) happens. + /// \throw MasterFileError when the master_file is badly formatted or some + /// similar problem is found when loading the master file. bool loadIncremental(size_t limit); private: /// \brief The iterator used as source of data in case of the copy mode.