namespace datasrc {
void
-ConfigurableContainer::configure(const ConstElementPtr& config, bool) {
+ConfigurableContainer::configure(const Element& config, bool) {
// TODO: Implement the cache
// TODO: Implement recyclation from the old configuration.
size_t i(0); // Outside of the try to be able to access it in the catch
try {
vector<DataSourceInfo> new_data_sources;
- for (; i < config->size(); ++i) {
+ for (; i < config.size(); ++i) {
// Extract the parameters
- const ConstElementPtr dconf(config->get(i));
+ const ConstElementPtr dconf(config.get(i));
const ConstElementPtr typeElem(dconf->get("type"));
if (typeElem == ConstElementPtr()) {
isc_throw(ConfigurationError, "Missing the type option in "
// Check the configuration is empty when the list is empty
TEST_F(ContainerTest, configureEmpty) {
ConstElementPtr elem(new ListElement);
- container_->configure(elem, true);
+ container_->configure(*elem, true);
EXPECT_TRUE(container_->dataSources().empty());
}
" \"params\": {}"
"}]"
));
- container_->configure(elem, true);
+ container_->configure(*elem, true);
EXPECT_EQ(2, container_->dataSources().size());
checkDS(0, "type1", "{}");
checkDS(1, "type2", "{}");
" \"cache\": \"off\","
" \"params\": ") + *param +
"}]"));
- container_->configure(elem, true);
+ container_->configure(*elem, true);
EXPECT_EQ(1, container_->dataSources().size());
checkDS(0, "t", *param);
}
NULL
};
// Put something inside to see it survives the exception
- container_->configure(config_elem_, true);
+ container_->configure(*config_elem_, true);
checkDS(0, "test_type", "{}");
for (const char** config(configs); *config; ++config) {
SCOPED_TRACE(*config);
ConstElementPtr elem(Element::fromJSON(*config));
- EXPECT_THROW(container_->configure(elem, true),
+ EXPECT_THROW(container_->configure(*elem, true),
ConfigurableContainer::ConfigurationError);
// Still untouched
checkDS(0, "test_type", "{}");
"{"
" \"type\": \"type1\""
"}]"));
- container_->configure(elem, true);
+ container_->configure(*elem, true);
EXPECT_EQ(1, container_->dataSources().size());
checkDS(0, "type1", "null");
}
// Check we can call the configure multiple times, to change the configuration
TEST_F(ContainerTest, reconfigure) {
ConstElementPtr empty(new ListElement);
- container_->configure(config_elem_, true);
+ container_->configure(*config_elem_, true);
checkDS(0, "test_type", "{}");
- container_->configure(empty, true);
+ container_->configure(*empty, true);
EXPECT_TRUE(container_->dataSources().empty());
- container_->configure(config_elem_, true);
+ container_->configure(*config_elem_, true);
checkDS(0, "test_type", "{}");
}
"{"
" \"type\": \"error\""
"}]"));
- container_->configure(config_elem_, true);
+ container_->configure(*config_elem_, true);
checkDS(0, "test_type", "{}");
- EXPECT_THROW(container_->configure(elem, true), DataSourceError);
+ EXPECT_THROW(container_->configure(*elem, true), DataSourceError);
checkDS(0, "test_type", "{}");
}