]>
Commit | Line | Data |
---|---|---|
4e0938ef | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 The Squid Software Foundation and contributors |
4e0938ef AJ |
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 | ||
582c2af2 | 9 | #include "squid.h" |
62ee09ca | 10 | #include "CacheManager.h" |
602d9612 | 11 | #include "mgr/Action.h" |
b707cdeb | 12 | #include "Store.h" |
602d9612 | 13 | #include "testCacheManager.h" |
7f861c77 | 14 | #include "unitTestMain.h" |
62ee09ca | 15 | |
3d41e53a | 16 | #include <cppunit/TestAssert.h> |
62ee09ca | 17 | |
18 | CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager ); | |
19 | ||
62ee09ca | 20 | /* init memory pools */ |
21 | ||
16555581 | 22 | void testCacheManager::setUp() |
62ee09ca | 23 | { |
16555581 | 24 | Mem::Init(); |
25 | } | |
62ee09ca | 26 | |
27 | /* | |
28 | * Test creating a CacheManager | |
29 | */ | |
30 | void | |
31 | testCacheManager::testCreate() | |
32 | { | |
b707cdeb | 33 | CacheManager::GetInstance(); //it's a singleton.. |
62ee09ca | 34 | } |
35 | ||
36 | /* an action to register */ | |
37 | static void | |
38 | dummy_action(StoreEntry * sentry) | |
b707cdeb FC |
39 | { |
40 | sentry->flags=1; | |
41 | } | |
62ee09ca | 42 | |
43 | /* | |
44 | * registering an action makes it findable. | |
45 | */ | |
46 | void | |
47 | testCacheManager::testRegister() | |
48 | { | |
b707cdeb | 49 | CacheManager *manager=CacheManager::GetInstance(); |
8822ebee | 50 | CPPUNIT_ASSERT(manager != NULL); |
b707cdeb | 51 | |
8822ebee AR |
52 | manager->registerProfile("sample", "my sample", &dummy_action, false, false); |
53 | Mgr::Action::Pointer action = manager->createNamedAction("sample"); | |
54 | CPPUNIT_ASSERT(action != NULL); | |
b707cdeb | 55 | |
8822ebee AR |
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())); | |
b707cdeb FC |
62 | |
63 | StoreEntry *sentry=new StoreEntry(); | |
64 | sentry->flags=0x25; //arbitrary test value | |
8822ebee | 65 | action->run(sentry, false); |
b707cdeb | 66 | CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags); |
62ee09ca | 67 | } |
f53969cc | 68 |