-// Copyright (C) 2009-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2009-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
BOOST_FOREACH(const std::string& s, sv) {
// Test two types of fromJSON(): with string and istream.
- for (int i = 0; i < 2; ++i) {
+ for (unsigned i = 0; i < 2; ++i) {
// test << operator, which uses Element::str()
if (i == 0) {
el = Element::fromJSON(s);
EXPECT_NO_THROW(Element::fromJSON("\"\\\"\\\"\""));
// A whitespace test
EXPECT_NO_THROW(Element::fromJSON("\" \n \r \t \f \n \n \t\""));
+ // Escape for forward slash is optional
+ ASSERT_NO_THROW(Element::fromJSON("\"foo\\/bar\""));
+ EXPECT_EQ("foo/bar", Element::fromJSON("\"foo\\/bar\"")->stringValue());
+ // Control characters
+ StringElement bell("foo\abar");
+ EXPECT_EQ("\"foo\\u0007bar\"", bell.str());
}
// This test verifies that a backslash can be used in element content
el->set(long_maptag, Element::create("bar"));
EXPECT_EQ("bar", el->find(long_maptag)->stringValue());
+ // Null pointer value
+ el.reset(new MapElement());
+ ConstElementPtr null_ptr;
+ el->set("value", null_ptr);
+ EXPECT_FALSE(el->get("value"));
+ EXPECT_EQ("{ \"value\": None }", el->str());
}
TEST(Element, to_and_from_wire) {
c = Element::fromJSON("{ \"a\": 1 }");
EXPECT_EQ(*removeIdentical(a, b), *c);
- EXPECT_THROW(removeIdentical(Element::create(1), Element::create(2)),
- TypeError);
+ // removeIdentical() is overloaded so force the first argument to const
+ ConstElementPtr bad = Element::create(1);
+ EXPECT_THROW(removeIdentical(bad, Element::create(2)), TypeError);
}
TEST(Element, merge) {
EXPECT_THROW(Element::fromJSON(dbl_head_comment), JSONError);
EXPECT_THROW(Element::fromJSON(dbl_mid_comment), JSONError);
EXPECT_THROW(Element::fromJSON(dbl_tail_comment), JSONError);
+
+ // For coverage
+ std::istringstream iss(no_comment);
+ EXPECT_TRUE(exp->equals(*Element::fromJSON(iss, true)));
}
TEST(Element, getPosition) {
-// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
testGet6ByPrefix(*getCfgHosts(), *getCfgHosts());
}
+// This test verifies that without a host data source an exception is thrown.
+TEST_F(HostMgrTest, addNoDataSource) {
+ // Remove all configuration.
+ CfgMgr::instance().clear();
+ // Recreate HostMgr instance.
+ HostMgr::create();
+
+ HostPtr host(new Host(hwaddrs_[0]->toText(false), "hw-address",
+ SubnetID(1), SubnetID(0), IOAddress("192.0.2.5")));
+ EXPECT_THROW(HostMgr::instance().add(host), NoHostDataSourceManager);
+}
+
// The following tests require MySQL enabled.
#if defined HAVE_MYSQL
-// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
EXPECT_THROW(lease_mgr.reset(new Memfile_LeaseMgr(pmap)), isc::BadValue);
}
+// Checks if there is no lease manager NoLeaseManager is thrown.
+TEST_F(MemfileLeaseMgrTest, noLeaseManager) {
+ LeaseMgrFactory::destroy();
+ EXPECT_THROW(LeaseMgrFactory::instance(), NoLeaseManager);
+}
+
// Checks if the getType() and getName() methods both return "memfile".
TEST_F(MemfileLeaseMgrTest, getTypeAndName) {
startBackend(V4);
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
const isc::dns::Exception& exception_cast2 =
dynamic_cast<const isc::dns::Exception&>(exception);
// to avoid compiler warning
+ exception_cast.getRcode();
exception_cast.what();
exception_cast2.what();
});
const isc::dns::Exception& exception_cast2 =
dynamic_cast<const isc::dns::Exception&>(exception);
// to avoid compiler warning
+ exception_cast.getRcode();
exception_cast.what();
exception_cast2.what();
});
-// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
};
+// Check that LibraryManager constructor requires a not null manager
+
+TEST_F(LibraryManagerTest, NullManager) {
+ EXPECT_THROW(PublicLibraryManager(std::string("foo"), 0, 0),
+ NoCalloutManager);
+}
+
// Check that openLibrary() reports an error when it can't find the specified
// library.
-// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
return (true);
}
+// This test verifies that if the thread calling spawn has SIGCHLD
+// already block ProcessSpawnError is thrown (@todo the second error
+// case: fork() failling)
+TEST(ProcessSpawn, sigchldBlocked) {
+ std::vector<std::string> args;
+ ProcessSpawn process(getApp(), args);
+ sigset_t sset;
+ sigemptyset(&sset);
+ sigaddset(&sset, SIGCHLD);
+ sigset_t osset;
+ pthread_sigmask(SIG_BLOCK, &sset, &osset);
+ EXPECT_THROW(process.spawn(), ProcessSpawnError);
+ sigprocmask(SIG_SETMASK, &osset, 0);
+}
+
// This test verifies that the external application can be ran with
// arguments and that the exit code is gathered.
TEST(ProcessSpawn, spawnWithArgs) {