diff options
Diffstat (limited to 'documentapi/src/tests/messages/testbase.h')
-rw-r--r-- | documentapi/src/tests/messages/testbase.h | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/documentapi/src/tests/messages/testbase.h b/documentapi/src/tests/messages/testbase.h deleted file mode 100644 index ad371bcc3bc..00000000000 --- a/documentapi/src/tests/messages/testbase.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <vespa/documentapi/messagebus/documentprotocol.h> -#include <vespa/messagebus/routable.h> -#include <vespa/vespalib/component/version.h> -#include <vespa/vespalib/testkit/testapp.h> -#include <map> - -using namespace documentapi; - -/** - * Declare the signature of the test method. - */ -class TestBase; -typedef bool (TestBase::*TEST_METHOD_PT)(); -#define TEST_METHOD(pt) ((TEST_METHOD_PT)&pt) - -/** - * This is the test base itself. It offers a set of utility functions that reflect on the version returned by - * the pure virtual getVersion() function. You need to inherit this and assign a version and a set of message - * tests to it. - */ -class TestBase : public vespalib::TestApp { - std::shared_ptr<const document::DocumentTypeRepo> _repo; -protected: - const string _dataPath; - DocumentProtocol _protocol; - std::map<uint32_t, TEST_METHOD_PT> _tests; - - // Declares what languages share serialization. - enum { - LANG_CPP = 0, - LANG_JAVA, - NUM_LANGUAGES - }; - - TestBase(); - ~TestBase() override; - virtual vespalib::Version getVersion() const = 0; - virtual bool shouldTestCoverage() const = 0; - TestBase &putTest(uint32_t type, TEST_METHOD_PT test); - int Main() override; - -public: - using Tamper = std::function<mbus::Blob(mbus::Blob)>; - static mbus::Blob truncate(mbus::Blob data, size_t bytes); - static mbus::Blob pad(mbus::Blob data, size_t bytes); - - const document::DocumentTypeRepo &getTypeRepo() { return *_repo; } - std::shared_ptr<const document::DocumentTypeRepo> &getTypeRepoSp() { return _repo; } - - bool testCoverage(const std::vector<uint32_t> &expected, const std::vector<uint32_t> &actual, bool report = false) const; - bool writeFile(const string &filename, const mbus::Blob& blob) const; - mbus::Blob readFile(const string &filename) const; - uint32_t serialize(const string &filename, const mbus::Routable &routable, Tamper tamper); - uint32_t serialize(const string &filename, const mbus::Routable &routable) { - return serialize(filename, routable, [](auto x)noexcept{ return x; }); - } - mbus::Routable::UP deserialize(const string &filename, uint32_t classId, uint32_t lang); - void dump(const mbus::Blob &blob) const; - - string getPath(const string &filename) const { return _dataPath + "/" + filename; } - mbus::Blob encode(const mbus::Routable &obj) const { return _protocol.encode(getVersion(), obj); } - mbus::Routable::UP decode(mbus::BlobRef data) const { return _protocol.decode(getVersion(), data); } -private: - bool file_content_is_unchanged(const string& filename, const mbus::Blob& data_to_write) const; -}; - |