Commit cc0fc600 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

Merge branch 'trac1397'

Conflicts:
	src/lib/dns/tests/rrset_unittest.cc

The merge conflict resolution was reviewed by Shane on Jabber.
parents 2f88f1b4 30c527ee
......@@ -270,6 +270,11 @@ TreeNodeRRset::addRdata(const rdata::Rdata&) {
isc_throw(Unexpected, "unexpected method called on TreeNodeRRset");
}
void
TreeNodeRRset::addRdata(const std::string&) {
isc_throw(Unexpected, "unexpected method called on TreeNodeRRset");
}
namespace {
// In this namespace we define a set of helper stuff to implement the
// RdataIterator for the TreeNodeRRset. We should eventually optimize
......
......@@ -206,6 +206,11 @@ public:
/// It throws \c isc::Unexpected unconditionally.
virtual void addRdata(const dns::rdata::Rdata& rdata);
/// \brief Specialized version of \c addRdata() for \c TreeNodeRRset.
///
/// It throws \c isc::Unexpected unconditionally.
virtual void addRdata(const std::string& rdata_str);
virtual dns::RdataIteratorPtr getRdataIterator() const;
/// \brief Specialized version of \c getRRsig() for \c TreeNodeRRset.
......
......@@ -694,6 +694,7 @@ TEST_F(TreeNodeRRsetTest, unexpectedMethods) {
EXPECT_THROW(rrset.setTTL(RRTTL(0)), isc::Unexpected);
EXPECT_THROW(rrset.addRdata(createRdata(RRType::A(), rrclass_, "0.0.0.0")),
isc::Unexpected);
EXPECT_THROW(rrset.addRdata("0.0.0.0"), isc::Unexpected);
RdataPtr sig_rdata = createRdata(
RRType::RRSIG(), rrclass_,
"A 5 2 3600 20120814220826 20120715220826 5300 example.com. FAKE");
......
......@@ -254,6 +254,11 @@ BasicRRset::addRdata(const Rdata& rdata) {
AbstractRRset::addRdata(rdata);
}
void
BasicRRset::addRdata(const std::string& rdata_str) {
addRdata(createRdata(getType(), getClass(), rdata_str));
}
unsigned int
BasicRRset::getRdataCount() const {
return (impl_->rdatalist_.size());
......
......@@ -401,6 +401,16 @@ public:
/// object, a copy of which is to be added to the \c RRset.
virtual void addRdata(const rdata::Rdata& rdata) = 0;
/// \brief Add an RDATA to the RRset (string version).
///
/// This method constructs an Rdata object from the the given
/// \c rdata_str in presentation format and adds it to the \c RRset.
///
/// \param rdata_str RDATA string in presentation format.
/// \throw InvalidRdataText if the \c rdata_str is invalid for this
/// \c RRset.
virtual void addRdata(const std::string& rdata_str) = 0;
/// \brief Return an iterator to go through all RDATA stored in the
/// \c RRset.
///
......@@ -755,6 +765,13 @@ public:
/// See \c AbstractRRset::addRdata(const rdata::Rdata&).
virtual void addRdata(const rdata::Rdata& rdata);
/// \brief Add an RDATA to the RRset (string version).
///
/// \param rdata_str RDATA string in presentation format.
/// \throw InvalidRdataText if the \c rdata_str is invalid for this
/// \c RRset.
virtual void addRdata(const std::string& rdata_str);
/// \brief Return an iterator to go through all RDATA stored in the
/// \c BasicRRset.
///
......
......@@ -130,7 +130,7 @@ TEST_F(RRsetTest, isSameKind) {
void
addRdataTestCommon(const RRset& rrset) {
EXPECT_EQ(2, rrset.getRdataCount());
ASSERT_EQ(2, rrset.getRdataCount());
RdataIteratorPtr it = rrset.getRdataIterator(); // cursor is set to the 1st
EXPECT_FALSE(it->isLast());
......@@ -157,7 +157,7 @@ TEST_F(RRsetTest, addRdataPtr) {
rrset_a_empty.addRdata(createRdata(rrset_a_empty.getType(),
rrset_a_empty.getClass(),
"192.0.2.2"));
addRdataTestCommon(rrset_a);
addRdataTestCommon(rrset_a_empty);
}
TEST_F(RRsetTest, addRdataPtrMismatched) {
......@@ -175,6 +175,18 @@ TEST_F(RRsetTest, addRdataPtrMismatched) {
EXPECT_EQ(1, rrset_ch_txt.getRdataCount());
}
TEST_F(RRsetTest, addRdataString) {
rrset_a_empty.addRdata("192.0.2.1");
rrset_a_empty.addRdata("192.0.2.2");
addRdataTestCommon(rrset_a_empty);
// String version of addRdata() will throw for bad RDATA for
// RRType::A().
EXPECT_THROW(rrset_a_empty.addRdata("ns.example.com."), InvalidRdataText);
addRdataTestCommon(rrset_a_empty);
}
TEST_F(RRsetTest, iterator) {
// Iterator for an empty RRset.
RdataIteratorPtr it = rrset_a_empty.getRdataIterator();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment