]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2378] It would throw at load(), not constructor
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Thu, 29 Nov 2012 14:25:49 +0000 (15:25 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Thu, 13 Dec 2012 10:33:56 +0000 (11:33 +0100)
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().

src/lib/datasrc/tests/zone_loader_unittest.cc
src/lib/datasrc/zone_loader.h

index 8f03bfc55c8dc1845f0d41bdba03178741b78756..ccc5b9d28d544bb0436e18196ca2f3dcacbd15dd 100644 (file)
 
 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<memory::ZoneTableSegment> ztable_segment_;
+    shared_ptr<memory::ZoneTableSegment> 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_);
 }
 
 }
index c0f241032d00c999d51e4bdf458fb3ca09a8a029..17eb57e08310d6eeea34ed34e535ada9b3a9b8d0 100644 (file)
@@ -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.