Browse Source

[1605] RBNodeRRset tests now pass

Stephen Morris 13 years ago
parent
commit
f161f37c16
2 changed files with 31 additions and 14 deletions
  1. 31 7
      src/lib/datasrc/rbnode_rrset.h
  2. 0 7
      src/lib/datasrc/tests/rbnode_rrset_unittest.cc

+ 31 - 7
src/lib/datasrc/rbnode_rrset.h

@@ -60,6 +60,8 @@ class RBNodeRRset : public isc::dns::AbstractRRset {
 private:
 private:
     // Note: The copy constructor and the assignment operator are intentionally
     // Note: The copy constructor and the assignment operator are intentionally
     // defined as private as we would normally not duplicate a RBNodeRRset.
     // defined as private as we would normally not duplicate a RBNodeRRset.
+    // (We use the "private" method instead of inheriting from boost::noncopyable
+    // so as to avoid multiple inheritance.)
     RBNodeRRset(const RBNodeRRset& source);
     RBNodeRRset(const RBNodeRRset& source);
     RBNodeRRset& operator=(const RBNodeRRset& source);
     RBNodeRRset& operator=(const RBNodeRRset& source);
 
 
@@ -67,6 +69,8 @@ public:
     /// \brief Usual Constructor
     /// \brief Usual Constructor
     ///
     ///
     /// Creates an RBNodeRRset from the pointer to the RRset passed to it.
     /// Creates an RBNodeRRset from the pointer to the RRset passed to it.
+    ///
+    /// \param rrset Pointer to underlying RRset encapsulated by this object.
     RBNodeRRset(const isc::dns::ConstRRsetPtr& rrset) : rrset_(rrset) {}
     RBNodeRRset(const isc::dns::ConstRRsetPtr& rrset) : rrset_(rrset) {}
 
 
     /// \brief Destructor
     /// \brief Destructor
@@ -132,30 +136,50 @@ public:
     }
     }
 
 
     virtual isc::dns::RRsetPtr getRRsig() const {
     virtual isc::dns::RRsetPtr getRRsig() const {
-        return (isc::dns::RRsetPtr());
+        return (rrset_->getRRsig());
     }
     }
 
 
-    virtual void addRRsig(const isc::dns::rdata::ConstRdataPtr& /*rdata*/) {
+    // With all the RRsig methods, we have the problem that we store the
+    // underlying RRset using a ConstRRsetPtr - a pointer to a "const" RRset -
+    // but we need to modify it by adding or removing an RRSIG.  We overcome
+    // this by temporarily violating the "const" nature of the RRset to add the
+    // data.
+
+    virtual void addRRsig(const isc::dns::rdata::ConstRdataPtr& rdata) {
+        AbstractRRset* p = const_cast<AbstractRRset*>(rrset_.get());
+        p->addRRsig(rdata);
     }
     }
 
 
-    virtual void addRRsig(const isc::dns::rdata::RdataPtr& /*rdata*/) {
+    virtual void addRRsig(const isc::dns::rdata::RdataPtr& rdata) {
+        AbstractRRset* p = const_cast<AbstractRRset*>(rrset_.get());
+        p->addRRsig(rdata);
     }
     }
 
 
-    virtual void addRRsig(const AbstractRRset& /*sigs*/) {
+    virtual void addRRsig(const AbstractRRset& sigs) {
+        AbstractRRset* p = const_cast<AbstractRRset*>(rrset_.get());
+        p->addRRsig(sigs);
     }
     }
 
 
-    virtual void addRRsig(const isc::dns::ConstRRsetPtr& /*sigs*/) {
+    virtual void addRRsig(const isc::dns::ConstRRsetPtr& sigs) {
+        AbstractRRset* p = const_cast<AbstractRRset*>(rrset_.get());
+        p->addRRsig(sigs);
     }
     }
 
 
-    virtual void addRRsig(const isc::dns::RRsetPtr& /*sigs*/) {
+    virtual void addRRsig(const isc::dns::RRsetPtr& sigs) {
+        AbstractRRset* p = const_cast<AbstractRRset*>(rrset_.get());
+        p->addRRsig(sigs);
     }
     }
 
 
     virtual void removeRRsig() {
     virtual void removeRRsig() {
+        AbstractRRset* p = const_cast<AbstractRRset*>(rrset_.get());
+        p->removeRRsig();
     }
     }
 
 
     /// \brief Return underlying RRset pointer
     /// \brief Return underlying RRset pointer
+    ///
+    /// ... mainly for testing.
     virtual isc::dns::ConstRRsetPtr getUnderlyingRRset() const {
     virtual isc::dns::ConstRRsetPtr getUnderlyingRRset() const {
-        return rrset_;
+        return (rrset_);
     }
     }
 
 
 private:
 private:

+ 0 - 7
src/lib/datasrc/tests/rbnode_rrset_unittest.cc

@@ -203,13 +203,6 @@ TEST_F(RBNodeRRsetTest, LeftShiftOperator) {
               "test.example.com. 3600 IN A 192.0.2.2\n", oss.str());
               "test.example.com. 3600 IN A 192.0.2.2\n", oss.str());
 }
 }
 
 
-// RRSIG-related tests.
-
-
-TEST_F(RBNodeRRsetTest, addRRsigConstantRdataPointer) {
-    FAIL();
-}
-
 // General RRSIG check function.  Get the RRSIG from the RRset and check that
 // General RRSIG check function.  Get the RRSIG from the RRset and check that
 // the RDATA is what we expect.
 // the RDATA is what we expect.
 void
 void