#include <dns/master_loader_callbacks.h>
#include <dns/master_loader.h>
+#include <exceptions/exceptions.h>
+
#include <boost/bind.hpp>
+using namespace isc;
+
namespace isc {
namespace dns {
RRsetCollection::addRRset(RRsetPtr rrset) {
const CollectionKey key(rrset->getClass(), rrset->getType(),
rrset->getName());
+ CollectionMap::const_iterator it = rrsets_.find(key);
+ if (it != rrsets_.end()) {
+ isc_throw(InvalidParameter,
+ "RRset for " << rrset->getName() << "/" << rrset->getClass()
+ << " with type " << rrset->getType() << " already exists");
+ }
+
rrsets_.insert(std::pair<CollectionKey, RRsetPtr>(key, rrset));
}
/// \brief Add an RRset to the collection.
///
/// Does not do any validation whether \c rrset belongs to a
- /// particular zone or not.
+ /// particular zone or not. It throws an \c isc::InvalidParameter
+ /// exception if an rrset with the same class, type and name already
+ /// exists.
void addRRset(isc::dns::RRsetPtr rrset);
/// \brief Remove an RRset from the collection.
// The collection must not be empty.
EXPECT_NE(collection.end(), collection.begin());
+ // Adding a duplicate RRset must throw.
+ EXPECT_THROW({
+ collection.addRRset(rrset);
+ }, isc::InvalidParameter);
+
// Remove foo.example.org/A
collection.removeRRset(Name("foo.example.org"), rrclass, RRType::A());