blob: b61784499183dbeef3b45de5ddc7bb1d4f5c6968 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/messagebus/protocolrepository.h>
#include <vespa/vespalib/testkit/testapp.h>
using namespace mbus;
TEST_SETUP(Test);
class TestProtocol : public IProtocol {
private:
const string _name;
public:
TestProtocol(const string &name)
: _name(name)
{
// empty
}
const string &
getName() const override
{
return _name;
}
IRoutingPolicy::UP
createPolicy(const string &name, const string ¶m) const override
{
(void)name;
(void)param;
throw std::exception();
}
Blob
encode(const vespalib::Version &version, const Routable &routable) const override
{
(void)version;
(void)routable;
throw std::exception();
}
Routable::UP
decode(const vespalib::Version &version, BlobRef data) const override
{
(void)version;
(void)data;
throw std::exception();
}
bool requireSequencing() const override { return false; }
};
int
Test::Main()
{
TEST_INIT("protocolrepository_test");
ProtocolRepository repo;
IProtocol::SP prev;
prev = repo.putProtocol(IProtocol::SP(new TestProtocol("foo")));
ASSERT_TRUE(prev.get() == NULL);
IRoutingPolicy::SP policy = repo.getRoutingPolicy("foo", "bar", "baz");
prev = repo.putProtocol(IProtocol::SP(new TestProtocol("foo")));
ASSERT_TRUE(prev.get() != NULL);
ASSERT_NOT_EQUAL(prev.get(), repo.getProtocol("foo"));
policy = repo.getRoutingPolicy("foo", "bar", "baz");
ASSERT_TRUE(policy.get() == NULL);
TEST_DONE();
}
|