]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testCacheManager.cc
5a8d109b396b78dc451d623a929e405d0cecb7bb
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "CacheManager.h"
11 #include "mgr/Action.h"
13 #include "testCacheManager.h"
14 #include "unitTestMain.h"
16 #include <cppunit/TestAssert.h>
18 CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager
);
20 /* init memory pools */
22 void testCacheManager::setUp()
28 * Test creating a CacheManager
31 testCacheManager::testCreate()
33 CacheManager::GetInstance(); //it's a singleton..
36 /* an action to register */
38 dummy_action(StoreEntry
* sentry
)
44 * registering an action makes it findable.
47 testCacheManager::testRegister()
49 CacheManager
*manager
=CacheManager::GetInstance();
50 CPPUNIT_ASSERT(manager
!= NULL
);
52 manager
->registerProfile("sample", "my sample", &dummy_action
, false, false);
53 Mgr::Action::Pointer action
= manager
->createNamedAction("sample");
54 CPPUNIT_ASSERT(action
!= NULL
);
56 const Mgr::ActionProfile::Pointer profile
= action
->command().profile
;
57 CPPUNIT_ASSERT(profile
!= NULL
);
58 CPPUNIT_ASSERT(profile
->creator
!= NULL
);
59 CPPUNIT_ASSERT_EQUAL(false, profile
->isPwReq
);
60 CPPUNIT_ASSERT_EQUAL(false, profile
->isAtomic
);
61 CPPUNIT_ASSERT_EQUAL(String("sample"), String(action
->name()));
63 StoreEntry
*sentry
=new StoreEntry();
64 sentry
->flags
=0x25; //arbitrary test value
65 action
->run(sentry
, false);
66 CPPUNIT_ASSERT_EQUAL(1,(int)sentry
->flags
);