]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStore.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / tests / testStore.h
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 #ifndef SQUID_SRC_TEST_STORE_H
10 #define SQUID_SRC_TEST_STORE_H
11
12 #include "Store.h"
13 #include "store/Controlled.h"
14
15 #include <cppunit/extensions/HelperMacros.h>
16
17 /*
18 * test the store framework
19 */
20
21 class testStore : public CPPUNIT_NS::TestFixture
22 {
23 CPPUNIT_TEST_SUITE( testStore );
24 CPPUNIT_TEST( testSetRoot );
25 CPPUNIT_TEST( testUnsetRoot );
26 CPPUNIT_TEST( testStats );
27 CPPUNIT_TEST( testMaxSize );
28 CPPUNIT_TEST_SUITE_END();
29
30 public:
31
32 protected:
33 void testSetRoot();
34 void testUnsetRoot();
35 void testStats();
36 void testMaxSize();
37 };
38
39 /// allows testing of methods without having all the other components live
40 class TestStore : public Store::Controller
41 {
42
43 public:
44 TestStore() : statsCalled (false) {}
45
46 bool statsCalled;
47
48 virtual int callback();
49
50 virtual StoreEntry* get(const cache_key*);
51
52 virtual void get(String, void (*)(StoreEntry*, void*), void*);
53
54 virtual void init();
55
56 virtual void maintain() {};
57
58 virtual uint64_t maxSize() const;
59
60 virtual uint64_t minSize() const;
61
62 virtual uint64_t currentSize() const;
63
64 virtual uint64_t currentCount() const;
65
66 virtual int64_t maxObjectSize() const;
67
68 virtual void getStats(StoreInfoStats &) const;
69
70 virtual void stat(StoreEntry &) const; /* output stats to the provided store entry */
71
72 virtual void reference(StoreEntry &) {} /* Reference this object */
73
74 virtual bool dereference(StoreEntry &) { return true; }
75
76 virtual StoreSearch *search();
77 };
78
79 typedef RefCount<TestStore> TestStorePointer;
80
81 #endif
82