]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testCacheManager.cc
Merge from trunk
[thirdparty/squid.git] / src / tests / testCacheManager.cc
1 #include "squid.h"
2 #include "CacheManager.h"
3 #include "Mem.h"
4 #include "mgr/Action.h"
5 #include "Store.h"
6 #include "testCacheManager.h"
7
8 #include <cppunit/TestAssert.h>
9
10 CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager );
11
12 /* init memory pools */
13
14 void testCacheManager::setUp()
15 {
16 Mem::Init();
17 }
18
19 /*
20 * Test creating a CacheManager
21 */
22 void
23 testCacheManager::testCreate()
24 {
25 CacheManager::GetInstance(); //it's a singleton..
26 }
27
28 /* an action to register */
29 static void
30 dummy_action(StoreEntry * sentry)
31 {
32 sentry->flags=1;
33 }
34
35 /*
36 * registering an action makes it findable.
37 */
38 void
39 testCacheManager::testRegister()
40 {
41 CacheManager *manager=CacheManager::GetInstance();
42 CPPUNIT_ASSERT(manager != NULL);
43
44 manager->registerProfile("sample", "my sample", &dummy_action, false, false);
45 Mgr::Action::Pointer action = manager->createNamedAction("sample");
46 CPPUNIT_ASSERT(action != NULL);
47
48 const Mgr::ActionProfile::Pointer profile = action->command().profile;
49 CPPUNIT_ASSERT(profile != NULL);
50 CPPUNIT_ASSERT(profile->creator != NULL);
51 CPPUNIT_ASSERT_EQUAL(false, profile->isPwReq);
52 CPPUNIT_ASSERT_EQUAL(false, profile->isAtomic);
53 CPPUNIT_ASSERT_EQUAL(String("sample"), String(action->name()));
54
55 StoreEntry *sentry=new StoreEntry();
56 sentry->flags=0x25; //arbitrary test value
57 action->run(sentry, false);
58 CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags);
59 }