]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testCacheManager.cc
Author: Francesco Chemolli <kinkie@squid-cache.org>
[thirdparty/squid.git] / src / tests / testCacheManager.cc
1 #include "squid.h"
2 #include <cppunit/TestAssert.h>
3
4 #include "Mem.h"
5 #include "testCacheManager.h"
6 #include "CacheManager.h"
7 #include "Store.h"
8
9
10 CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager );
11
12 /* stub functions to link successfully */
13 void
14 shut_down(int)
15 {}
16
17 void
18 reconfigure(int)
19 {}
20
21 /* end stubs */
22
23 /* init memory pools */
24
25 void testCacheManager::setUp()
26 {
27 Mem::Init();
28 }
29
30 /*
31 * Test creating a CacheManager
32 */
33 void
34 testCacheManager::testCreate()
35 {
36 CacheManager::GetInstance(); //it's a singleton..
37 }
38
39 /* an action to register */
40 static void
41 dummy_action(StoreEntry * sentry)
42 {
43 sentry->flags=1;
44 }
45
46 /*
47 * registering an action makes it findable.
48 */
49 void
50 testCacheManager::testRegister()
51 {
52 CacheManager *manager=CacheManager::GetInstance();
53
54 manager->registerAction("sample", "my sample", &dummy_action, false, false);
55 CacheManagerAction *anAction = manager->findAction("sample");
56
57 CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.pw_req);
58 CPPUNIT_ASSERT_EQUAL(0, (int)anAction->flags.atomic);
59 CPPUNIT_ASSERT_EQUAL(String("sample"), String(anAction->action));
60
61 StoreEntry *sentry=new StoreEntry();
62 sentry->flags=0x25; //arbitrary test value
63 anAction->run(sentry);
64 CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags);
65 }