Commit 7ffc29a5 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2973] cleanup: ZoneTable::addZone now doesn't need RRclass so it's removed.

parent a1692329
......@@ -83,7 +83,7 @@ ZoneTable::destroy(util::MemorySegment& mem_sgmt, ZoneTable* ztable, int)
}
ZoneTable::AddResult
ZoneTable::addZone(util::MemorySegment& mem_sgmt, RRClass,
ZoneTable::addZone(util::MemorySegment& mem_sgmt,
const Name& zone_name, ZoneData* content)
{
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEMORY_MEM_ADD_ZONE).
......
......@@ -191,8 +191,6 @@ public:
/// created. It must be the same segment that was used to create
/// the zone table at the time of create().
/// \param zone_name The name of the zone to be added.
/// \param zone_class The RR class of the zone. It must be the RR class
/// that is supposed to be associated to the zone table.
/// \param content This one should hold the zone content (the ZoneData).
/// The ownership is passed onto the zone table. Must not be null or
/// empty. Must correspond to the name and class and must be allocated
......@@ -204,7 +202,6 @@ public:
/// inside the result unless it's empty; if the zone was previously
/// added by \c addEmptyZone(), the data returned is NULL.
AddResult addZone(util::MemorySegment& mem_sgmt,
dns::RRClass zone_class,
const dns::Name& zone_name,
ZoneData* content);
......
......@@ -148,8 +148,7 @@ ZoneWriter::install() {
const ZoneTable::AddResult result(
impl_->data_holder_->get() ?
table->addZone(impl_->segment_.getMemorySegment(),
impl_->rrclass_, impl_->origin_,
impl_->data_holder_->get()) :
impl_->origin_, impl_->data_holder_->get()) :
table->addEmptyZone(impl_->segment_.getMemorySegment(),
impl_->origin_));
impl_->data_holder_->set(result.zone_data);
......
......@@ -74,7 +74,7 @@ TEST_F(ZoneTableTest, addZone) {
EXPECT_EQ(0, zone_table->getZoneCount());
// It doesn't accept NULL as zone data
EXPECT_THROW(zone_table->addZone(mem_sgmt_, zclass_, zname1, NULL),
EXPECT_THROW(zone_table->addZone(mem_sgmt_, zname1, NULL),
isc::InvalidParameter);
EXPECT_EQ(0, zone_table->getZoneCount()); // count is still 0
......@@ -82,8 +82,7 @@ TEST_F(ZoneTableTest, addZone) {
SegmentObjectHolder<ZoneData, RRClass> holder_empty(
mem_sgmt_, zclass_);
holder_empty.set(ZoneData::create(mem_sgmt_));
EXPECT_THROW(zone_table->addZone(mem_sgmt_, zclass_, zname1,
holder_empty.get()),
EXPECT_THROW(zone_table->addZone(mem_sgmt_, zname1, holder_empty.get()),
isc::InvalidParameter);
SegmentObjectHolder<ZoneData, RRClass> holder1(
......@@ -91,8 +90,7 @@ TEST_F(ZoneTableTest, addZone) {
holder1.set(ZoneData::create(mem_sgmt_, zname1));
const ZoneData* data1(holder1.get());
// Normal successful case.
const ZoneTable::AddResult result1(zone_table->addZone(mem_sgmt_, zclass_,
zname1,
const ZoneTable::AddResult result1(zone_table->addZone(mem_sgmt_, zname1,
holder1.release()));
EXPECT_EQ(result::SUCCESS, result1.code);
EXPECT_EQ(static_cast<const ZoneData*>(NULL), result1.zone_data);
......@@ -103,8 +101,7 @@ TEST_F(ZoneTableTest, addZone) {
// Duplicate add replaces the existing data wit the newly added one.
SegmentObjectHolder<ZoneData, RRClass> holder2(mem_sgmt_, zclass_);
holder2.set(ZoneData::create(mem_sgmt_, zname1));
const ZoneTable::AddResult result2(zone_table->addZone(mem_sgmt_, zclass_,
zname1,
const ZoneTable::AddResult result2(zone_table->addZone(mem_sgmt_, zname1,
holder2.release()));
EXPECT_EQ(result::EXIST, result2.code);
// The old one gets out
......@@ -119,7 +116,7 @@ TEST_F(ZoneTableTest, addZone) {
mem_sgmt_, zclass_);
holder3.set(ZoneData::create(mem_sgmt_, Name("EXAMPLE.COM")));
// names are compared in a case insensitive manner.
const ZoneTable::AddResult result3(zone_table->addZone(mem_sgmt_, zclass_,
const ZoneTable::AddResult result3(zone_table->addZone(mem_sgmt_,
Name("EXAMPLE.COM"),
holder3.release()));
EXPECT_EQ(result::EXIST, result3.code);
......@@ -129,15 +126,13 @@ TEST_F(ZoneTableTest, addZone) {
mem_sgmt_, zclass_);
holder4.set(ZoneData::create(mem_sgmt_, zname2));
EXPECT_EQ(result::SUCCESS,
zone_table->addZone(mem_sgmt_, zclass_, zname2,
holder4.release()).code);
zone_table->addZone(mem_sgmt_, zname2, holder4.release()).code);
EXPECT_EQ(2, zone_table->getZoneCount());
SegmentObjectHolder<ZoneData, RRClass> holder5(
mem_sgmt_, zclass_);
holder5.set(ZoneData::create(mem_sgmt_, zname3));
EXPECT_EQ(result::SUCCESS,
zone_table->addZone(mem_sgmt_, zclass_, zname3,
holder5.release()).code);
zone_table->addZone(mem_sgmt_, zname3, holder5.release()).code);
EXPECT_EQ(3, zone_table->getZoneCount());
// Have the memory segment throw an exception in extending the internal
......@@ -146,7 +141,7 @@ TEST_F(ZoneTableTest, addZone) {
mem_sgmt_, zclass_);
holder6.set(ZoneData::create(mem_sgmt_, Name("example.org")));
mem_sgmt_.setThrowCount(1);
EXPECT_THROW(zone_table->addZone(mem_sgmt_, zclass_, Name("example.org"),
EXPECT_THROW(zone_table->addZone(mem_sgmt_, Name("example.org"),
holder6.get()),
std::bad_alloc);
}
......@@ -174,8 +169,7 @@ TEST_F(ZoneTableTest, addEmptyZone) {
// internal to the ZoneTable implementation.
SegmentObjectHolder<ZoneData, RRClass> holder2(mem_sgmt_, zclass_);
holder2.set(ZoneData::create(mem_sgmt_, zname1));
const ZoneTable::AddResult result2(zone_table->addZone(mem_sgmt_, zclass_,
zname1,
const ZoneTable::AddResult result2(zone_table->addZone(mem_sgmt_, zname1,
holder2.release()));
EXPECT_EQ(result::EXIST, result2.code);
EXPECT_EQ(static_cast<const ZoneData*>(NULL), result2.zone_data);
......@@ -196,20 +190,18 @@ TEST_F(ZoneTableTest, findZone) {
mem_sgmt_, zclass_);
holder1.set(ZoneData::create(mem_sgmt_, zname1));
ZoneData* zone_data = holder1.get();
EXPECT_EQ(result::SUCCESS, zone_table->addZone(mem_sgmt_, zclass_, zname1,
EXPECT_EQ(result::SUCCESS, zone_table->addZone(mem_sgmt_, zname1,
holder1.release()).code);
SegmentObjectHolder<ZoneData, RRClass> holder2(
mem_sgmt_, zclass_);
holder2.set(ZoneData::create(mem_sgmt_, zname2));
EXPECT_EQ(result::SUCCESS,
zone_table->addZone(mem_sgmt_, zclass_, zname2,
holder2.release()).code);
zone_table->addZone(mem_sgmt_, zname2, holder2.release()).code);
SegmentObjectHolder<ZoneData, RRClass> holder3(
mem_sgmt_, zclass_);
holder3.set(ZoneData::create(mem_sgmt_, zname3));
EXPECT_EQ(result::SUCCESS,
zone_table->addZone(mem_sgmt_, zclass_, zname3,
holder3.release()).code);
zone_table->addZone(mem_sgmt_, zname3, holder3.release()).code);
const ZoneTable::FindResult find_result1 =
zone_table->findZone(Name("example.com"));
......@@ -233,8 +225,7 @@ TEST_F(ZoneTableTest, findZone) {
SegmentObjectHolder<ZoneData, RRClass> holder4(
mem_sgmt_, zclass_);
holder4.set(ZoneData::create(mem_sgmt_, Name("com")));
EXPECT_EQ(result::SUCCESS, zone_table->addZone(mem_sgmt_, zclass_,
Name("com"),
EXPECT_EQ(result::SUCCESS, zone_table->addZone(mem_sgmt_, Name("com"),
holder4.release()).code);
EXPECT_EQ(zone_data,
zone_table->findZone(Name("www.example.com")).zone_data);
......
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