testCacheManager.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 
19 
20 /* init memory pools */
21 
23 {
24  Mem::Init();
25 }
26 
27 /*
28  * Test creating a CacheManager
29  */
30 void
32 {
33  CacheManager::GetInstance(); //it's a singleton..
34 }
35 
36 /* an action to register */
37 static void
39 {
40  sentry->flags=1;
41 }
42 
43 /*
44  * registering an action makes it findable.
45  */
46 void
48 {
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 
CPPUNIT_TEST_SUITE_REGISTRATION(testCacheManager)
static CacheManager * GetInstance()
void Init()
Definition: old_api.cc:437
uint16_t flags
Definition: Store.h:210
static void dummy_action(StoreEntry *sentry)
Mgr::Action::Pointer createNamedAction(const char *actionName)
bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
Definition: purge.cc:311
void registerProfile(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors