diff options
Diffstat (limited to 'src/bin/agent/tests/ca_response_creator_factory_unittests.cc')
-rw-r--r-- | src/bin/agent/tests/ca_response_creator_factory_unittests.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/bin/agent/tests/ca_response_creator_factory_unittests.cc b/src/bin/agent/tests/ca_response_creator_factory_unittests.cc new file mode 100644 index 0000000..8cef6fe --- /dev/null +++ b/src/bin/agent/tests/ca_response_creator_factory_unittests.cc @@ -0,0 +1,39 @@ +// Copyright (C) 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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include <config.h> +#include <agent/ca_response_creator.h> +#include <agent/ca_response_creator_factory.h> +#include <boost/pointer_cast.hpp> +#include <gtest/gtest.h> + +using namespace isc::agent; + +namespace { + +// This test verifies that create() method always returns the same +// instance of the CtrlAgentResponseCreator object. +TEST(CtrlAgentResponseCreatorFactory, create) { + CtrlAgentResponseCreatorFactory factory; + + // Invoke twice. + CtrlAgentResponseCreatorPtr response1; + CtrlAgentResponseCreatorPtr response2; + ASSERT_NO_THROW(response1 = boost::dynamic_pointer_cast< + CtrlAgentResponseCreator>(factory.create())); + ASSERT_NO_THROW(response2 = boost::dynamic_pointer_cast< + CtrlAgentResponseCreator>(factory.create())); + + // It must always return non-null object. + ASSERT_TRUE(response1); + ASSERT_TRUE(response2); + + // And it must always return the same object. + EXPECT_TRUE(response1 == response2); + +} + +} |