CqlHostDataSource::del(const SubnetID& subnet_id, const asiolink::IOAddress& address) {
HostPtr host = boost::const_pointer_cast<Host>(impl_->get4(subnet_id, address));
- return (impl_->insertOrDelete(host, false));
+ return (host ? impl_->insertOrDelete(host, false) : false);
}
bool
HostPtr host = boost::const_pointer_cast<Host>(impl_->get4(subnet_id, identifier_type,
identifier_begin, identifier_len));
- return (impl_->insertOrDelete(host, false));
+ return (host ? impl_->insertOrDelete(host, false) : false);
}
bool
HostPtr host = boost::const_pointer_cast<Host>(impl_->get6(subnet_id, identifier_type,
identifier_begin, identifier_len));
- return (impl_->insertOrDelete(host, false));
+ return (host ? impl_->insertOrDelete(host, false) : false);
}
ConstHostCollection
// ... and that it's gone after deletion.
EXPECT_FALSE(after);
+
+ // An attempt to delete it should not cause an exception. It
+ // should return false.
+ bool result = false;
+ EXPECT_NO_THROW(result = hdsptr_->del(subnet1, IOAddress("192.0.2.1")));
+ EXPECT_FALSE(result);
}
void GenericHostDataSourceTest::testDeleteById4() {
// ... and that it's gone after deletion.
EXPECT_FALSE(after);
+
+ // An attempt to delete it should not cause an exception. It
+ // should return false.
+ bool result = false;
+ EXPECT_NO_THROW(result = hdsptr_->del4(subnet1, host1->getIdentifierType(),
+ &host1->getIdentifier()[0],
+ host1->getIdentifier().size()));
+ EXPECT_FALSE(result);
}
// Test checks when a IPv4 host with options is deleted that the options are
// Check the options are indeed gone.
EXPECT_EQ(0, countDBOptions4());
+
+ // An attempt to delete it should not cause an exception. It
+ // should return false.
+ bool result = false;
+ EXPECT_NO_THROW(result = hdsptr_->del4(subnet1, host1->getIdentifierType(),
+ &host1->getIdentifier()[0],
+ host1->getIdentifier().size()));
+ EXPECT_FALSE(result);
}
void GenericHostDataSourceTest::testDeleteById6() {
// ... and that it's gone after deletion.
EXPECT_FALSE(after);
+
+ // An attempt to delete it should not cause an exception. It
+ // should return false.
+ bool result = false;
+ EXPECT_NO_THROW(result = hdsptr_->del6(subnet1, host1->getIdentifierType(),
+ &host1->getIdentifier()[0],
+ host1->getIdentifier().size()));
+ EXPECT_FALSE(result);
}
void GenericHostDataSourceTest::testDeleteById6Options() {
// Check the options are indeed gone.
EXPECT_EQ(0, countDBReservations6());
+
+ // An attempt to delete it should not cause an exception. It
+ // should return false.
+ bool result = false;
+ EXPECT_NO_THROW(result = hdsptr_->del6(subnet1, host1->getIdentifierType(),
+ &host1->getIdentifier()[0],
+ host1->getIdentifier().size()));
+ EXPECT_FALSE(result);
}
void