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