]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/tests/testCacheManager.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / tests / testCacheManager.cc
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#include "squid.h"
10#include "CacheManager.h"
11#include "mgr/Action.h"
12#include "Store.h"
13#include "testCacheManager.h"
14#include "unitTestMain.h"
15
16#include <cppunit/TestAssert.h>
17
18CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager );
19
20/* init memory pools */
21
22void testCacheManager::setUp()
23{
24 Mem::Init();
25}
26
27/*
28 * Test creating a CacheManager
29 */
30void
31testCacheManager::testCreate()
32{
33 CacheManager::GetInstance(); //it's a singleton..
34}
35
36/* an action to register */
37static void
38dummy_action(StoreEntry * sentry)
39{
40 sentry->flags=1;
41}
42
43/*
44 * registering an action makes it findable.
45 */
46void
47testCacheManager::testRegister()
48{
49 CacheManager *manager=CacheManager::GetInstance();
50 CPPUNIT_ASSERT(manager != NULL);
51
52 manager->registerProfile("sample", "my sample", &dummy_action, false, false);
53 Mgr::Action::Pointer action = manager->createNamedAction("sample");
54 CPPUNIT_ASSERT(action != NULL);
55
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()));
62
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);
67}
68