]>
Commit | Line | Data |
---|---|---|
4e0938ef AJ |
1 | /* |
2 | * Copyright (C) 1996-2014 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 | ||
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" |
62ee09ca | 14 | |
3d41e53a | 15 | #include <cppunit/TestAssert.h> |
62ee09ca | 16 | |
17 | CPPUNIT_TEST_SUITE_REGISTRATION( testCacheManager ); | |
18 | ||
62ee09ca | 19 | /* init memory pools */ |
20 | ||
16555581 | 21 | void testCacheManager::setUp() |
62ee09ca | 22 | { |
16555581 | 23 | Mem::Init(); |
24 | } | |
62ee09ca | 25 | |
26 | /* | |
27 | * Test creating a CacheManager | |
28 | */ | |
29 | void | |
30 | testCacheManager::testCreate() | |
31 | { | |
b707cdeb | 32 | CacheManager::GetInstance(); //it's a singleton.. |
62ee09ca | 33 | } |
34 | ||
35 | /* an action to register */ | |
36 | static void | |
37 | dummy_action(StoreEntry * sentry) | |
b707cdeb FC |
38 | { |
39 | sentry->flags=1; | |
40 | } | |
62ee09ca | 41 | |
42 | /* | |
43 | * registering an action makes it findable. | |
44 | */ | |
45 | void | |
46 | testCacheManager::testRegister() | |
47 | { | |
b707cdeb | 48 | CacheManager *manager=CacheManager::GetInstance(); |
8822ebee | 49 | CPPUNIT_ASSERT(manager != NULL); |
b707cdeb | 50 | |
8822ebee AR |
51 | manager->registerProfile("sample", "my sample", &dummy_action, false, false); |
52 | Mgr::Action::Pointer action = manager->createNamedAction("sample"); | |
53 | CPPUNIT_ASSERT(action != NULL); | |
b707cdeb | 54 | |
8822ebee AR |
55 | const Mgr::ActionProfile::Pointer profile = action->command().profile; |
56 | CPPUNIT_ASSERT(profile != NULL); | |
57 | CPPUNIT_ASSERT(profile->creator != NULL); | |
58 | CPPUNIT_ASSERT_EQUAL(false, profile->isPwReq); | |
59 | CPPUNIT_ASSERT_EQUAL(false, profile->isAtomic); | |
60 | CPPUNIT_ASSERT_EQUAL(String("sample"), String(action->name())); | |
b707cdeb FC |
61 | |
62 | StoreEntry *sentry=new StoreEntry(); | |
63 | sentry->flags=0x25; //arbitrary test value | |
8822ebee | 64 | action->run(sentry, false); |
b707cdeb | 65 | CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags); |
62ee09ca | 66 | } |
f53969cc | 67 |