]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testCacheManager.cc
1 #define SQUID_UNIT_TEST 1
4 #include "CacheManager.h"
6 #include "mgr/Action.h"
8 #include "testCacheManager.h"
10 #include <cppunit/TestAssert.h>
12 CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager
);
14 /* init memory pools */
16 void testCacheManager::setUp()
22 * Test creating a CacheManager
25 testCacheManager::testCreate()
27 CacheManager::GetInstance(); //it's a singleton..
30 /* an action to register */
32 dummy_action(StoreEntry
* sentry
)
38 * registering an action makes it findable.
41 testCacheManager::testRegister()
43 CacheManager
*manager
=CacheManager::GetInstance();
44 CPPUNIT_ASSERT(manager
!= NULL
);
46 manager
->registerProfile("sample", "my sample", &dummy_action
, false, false);
47 Mgr::Action::Pointer action
= manager
->createNamedAction("sample");
48 CPPUNIT_ASSERT(action
!= NULL
);
50 const Mgr::ActionProfile::Pointer profile
= action
->command().profile
;
51 CPPUNIT_ASSERT(profile
!= NULL
);
52 CPPUNIT_ASSERT(profile
->creator
!= NULL
);
53 CPPUNIT_ASSERT_EQUAL(false, profile
->isPwReq
);
54 CPPUNIT_ASSERT_EQUAL(false, profile
->isAtomic
);
55 CPPUNIT_ASSERT_EQUAL(String("sample"), String(action
->name()));
57 StoreEntry
*sentry
=new StoreEntry();
58 sentry
->flags
=0x25; //arbitrary test value
59 action
->run(sentry
, false);
60 CPPUNIT_ASSERT_EQUAL(1,(int)sentry
->flags
);