1 // Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
8 #include <agent/ca_response_creator.h>
9 #include <agent/ca_response_creator_factory.h>
10 #include <boost/pointer_cast.hpp>
11 #include <gtest/gtest.h>
12 
13 using namespace isc::agent;
14 
15 namespace {
16 
17 // This test verifies that create() method always returns the same
18 // instance of the CtrlAgentResponseCreator object.
TEST(CtrlAgentResponseCreatorFactory,create)19 TEST(CtrlAgentResponseCreatorFactory, create) {
20     CtrlAgentResponseCreatorFactory factory;
21 
22     // Invoke twice.
23     CtrlAgentResponseCreatorPtr response1;
24     CtrlAgentResponseCreatorPtr response2;
25     ASSERT_NO_THROW(response1 = boost::dynamic_pointer_cast<
26                     CtrlAgentResponseCreator>(factory.create()));
27     ASSERT_NO_THROW(response2 = boost::dynamic_pointer_cast<
28                     CtrlAgentResponseCreator>(factory.create()));
29 
30     // It must always return non-null object.
31     ASSERT_TRUE(response1);
32     ASSERT_TRUE(response2);
33 
34     // And it must always return the same object.
35     EXPECT_TRUE(response1 == response2);
36 
37 }
38 
39 }
40