/// zone from a file before.
const std::string getFileName(const isc::dns::Name& zone_name) const;
- /// \brief Inserts an rrset into the zone.
- ///
- /// It puts another RRset into the zone.
- /// \brief RRset is NULL exception.
-- ///
- /// In the current implementation, this method doesn't allow an existing
- /// RRset to be updated or overridden. So the caller must make sure that
- /// all RRs of the same type and name must be given in the form of a
- /// single RRset. The current implementation will also require that
- /// when an RRSIG is added, the RRset to be covered has already been
- /// added. These restrictions are probably too strict when this data
- /// source accepts various forms of input, so they should be revisited
- /// later.
- /// This is thrown if the provided RRset parameter is NULL.
- struct NullRRset : public InvalidParameter {
- NullRRset(const char* file, size_t line, const char* what) :
- InvalidParameter(file, line, what)
- { }
- };
-
- /// \brief Zone is empty exception.
-- ///
- /// Except for NullRRset and OutOfZone, this method does not guarantee
- /// strong exception safety (it is currently not needed, if it is needed
- /// in future, it should be implemented).
- /// This is thrown if we have an empty zone created as a result of
- /// load().
- struct EmptyZone : public InvalidParameter {
- EmptyZone(const char* file, size_t line, const char* what) :
- InvalidParameter(file, line, what)
- { }
- };
-
- /// \brief General failure exception for \c add().
-- ///
- /// \throw NullRRset \c rrset is a NULL pointer.
- /// \throw OutOfZone The owner name of \c rrset is outside of the
- /// origin of the zone.
- /// \throw AddError Other general errors.
- /// \throw Others This method might throw standard allocation exceptions.
- /// This is thrown against general error cases in adding an RRset
- /// to the zone.
-- ///
- /// \param rrset The set to add.
- /// \return SUCCESS or EXIST (if an rrset for given name and type already
- /// exists).
- result::Result add(const isc::dns::Name& zone_name,
- const isc::dns::ConstRRsetPtr& rrset);
- /// Note: this exception would cover cases for \c OutOfZone or
- /// \c NullRRset. We'll need to clarify and unify the granularity
- /// of exceptions eventually. For now, exceptions are added as
- /// developers see the need for it.
- struct AddError : public InvalidParameter {
- AddError(const char* file, size_t line, const char* what) :
- InvalidParameter(file, line, what)
- { }
- };
--
/// Returns a \c ZoneFinder result that best matches the given name.
///
/// This derived version of the method never throws an exception.
EXPECT_EQ(1, client_->getZoneCount());
}
++#if 0 // FIXME
++
+TEST_F(MemoryClientTest, loadRRSIGsRdataMixedCoveredTypes) {
+ client_->load(Name("example.org"),
+ TEST_DATA_DIR "/example.org-rrsigs.zone");
+
+ RRsetPtr rrset(new RRset(Name("example.org"),
+ RRClass::IN(), RRType::A(), RRTTL(3600)));
+ rrset->addRdata(in::A("192.0.2.1"));
+ rrset->addRdata(in::A("192.0.2.2"));
+
+ RRsetPtr rrsig(new RRset(Name("example.org"), zclass_,
+ RRType::RRSIG(), RRTTL(300)));
+ rrsig->addRdata(generic::RRSIG("A 5 3 3600 20000101000000 20000201000000 "
+ "12345 example.org. FAKEFAKEFAKE"));
+ rrsig->addRdata(generic::RRSIG("NS 5 3 3600 20000101000000 20000201000000 "
+ "54321 example.org. FAKEFAKEFAKEFAKE"));
+ rrset->addRRsig(rrsig);
+
+ EXPECT_THROW(client_->add(Name("example.org"), rrset),
+ ZoneDataUpdater::AddError);
+
+ // Teardown checks for memory segment leaks
+}
+
++#endif
++
TEST_F(MemoryClientTest, getZoneCount) {
EXPECT_EQ(0, client_->getZoneCount());
client_->load(Name("example.org"), TEST_DATA_DIR "/example.org-empty.zone");
EXPECT_THROW(iterator->getSOA(), isc::NotImplemented);
}
++#if 0 // FIXME
++
+TEST_F(MemoryClientTest, addRRsetToNonExistentZoneThrows) {
+ // The zone "example.org" doesn't exist, so we can't add an RRset to
+ // it.
+ RRsetPtr rrset_a(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
+ RRTTL(300)));
+ rrset_a->addRdata(rdata::in::A("192.0.2.1"));
+ EXPECT_THROW(client_->add(Name("example.org"), rrset_a), DataSourceError);
+}
+
+TEST_F(MemoryClientTest, addOutOfZoneThrows) {
+ // Out of zone names should throw.
+ client_->load(Name("example.org"),
+ TEST_DATA_DIR "/example.org-empty.zone");
+
+ RRsetPtr rrset_a(new RRset(Name("a.example.com"),
+ RRClass::IN(), RRType::A(), RRTTL(300)));
+ rrset_a->addRdata(rdata::in::A("192.0.2.1"));
+
+ EXPECT_THROW(client_->add(Name("example.org"), rrset_a),
+ OutOfZone);
+ // Teardown checks for memory segment leaks
+}
+
+TEST_F(MemoryClientTest, addNullRRsetThrows) {
+ client_->load(Name("example.org"),
+ TEST_DATA_DIR "/example.org-rrsigs.zone");
+
+ EXPECT_THROW(client_->add(Name("example.org"), ConstRRsetPtr()),
+ ZoneDataUpdater::NullRRset);
+
+ // Teardown checks for memory segment leaks
+}
+
+TEST_F(MemoryClientTest, addEmptyRRsetThrows) {
+ client_->load(Name("example.org"),
+ TEST_DATA_DIR "/example.org-rrsigs.zone");
+
+ RRsetPtr rrset_a(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
+ RRTTL(300)));
+ EXPECT_THROW(client_->add(Name("example.org"), rrset_a),
+ ZoneDataUpdater::AddError);
+
+ // Teardown checks for memory segment leaks
+}
+
+TEST_F(MemoryClientTest, add) {
+ client_->load(Name("example.org"), TEST_DATA_DIR "/example.org-empty.zone");
+
+ // Add another RRset
+ RRsetPtr rrset_a(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
+ RRTTL(300)));
+ rrset_a->addRdata(rdata::in::A("192.0.2.1"));
+ client_->add(Name("example.org"), rrset_a);
+
+ ZoneIteratorPtr iterator(client_->getIterator(Name("example.org")));
+
+ // First we have the SOA
+ ConstRRsetPtr rrset(iterator->getNextRRset());
+ EXPECT_TRUE(rrset);
+ EXPECT_EQ(RRType::A(), rrset->getType());
+
+ rrset = iterator->getNextRRset();
+ EXPECT_TRUE(rrset);
+ EXPECT_EQ(RRType::SOA(), rrset->getType());
+
+ // There's nothing else in this zone
+ EXPECT_EQ(ConstRRsetPtr(), iterator->getNextRRset());
+}
+
++#endif
++
TEST_F(MemoryClientTest, findZoneData) {
client_->load(Name("example.org"),
TEST_DATA_DIR "/example.org-rrsigs.zone");
EXPECT_THROW(client_->getJournalReader(Name("."), 0, 0),
isc::NotImplemented);
}
-// TODO (upon merge of #2268): Re-add (and modify not to need
-// InMemoryClient::add) the tests removed in
-// 7a628baa1a158b5837d6f383e10b30542d2ac59b. Maybe some of them
-// are really not needed.
-//
-// * MemoryClientTest::loadRRSIGsRdataMixedCoveredTypes
-// * MemoryClientTest::addRRsetToNonExistentZoneThrows
-// * MemoryClientTest::addOutOfZoneThrows
-// * MemoryClientTest::addNullRRsetThrows
-// * MemoryClientTest::addEmptyRRsetThrows
-// * MemoryClientTest::add
+
}