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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <tests/common/storagelinktest.h>
#include <iostream>
#include <string>
#include <vespa/storageapi/message/stat.h>
namespace storage {
CPPUNIT_TEST_SUITE_REGISTRATION(StorageLinkTest);
StorageLinkTest::StorageLinkTest()
: _threadPool(1024),
_feeder(),
_middle(0),
_replier(0) {}
void StorageLinkTest::setUp() {
_feeder.reset(new DummyStorageLink());
_middle = new DummyStorageLink();
_replier = new DummyStorageLink();
_feeder->push_back(StorageLink::UP(_middle));
_feeder->push_back(StorageLink::UP(_replier));
_replier->setAutoreply(true);
}
void StorageLinkTest::testPrinting() {
std::ostringstream actual;
actual << *_feeder;
std::string expected =
"StorageChain(3)\n"
" DummyStorageLink(autoreply = off, dispatch = off, 0 commands, 0 replies)\n"
" DummyStorageLink(autoreply = off, dispatch = off, 0 commands, 0 replies)\n"
" DummyStorageLink(autoreply = on, dispatch = off, 0 commands, 0 replies)";
CPPUNIT_ASSERT_EQUAL(expected, actual.str());
}
void StorageLinkTest::testNotImplemented() {
_feeder->open();
// Test that a message that nobody handles fails with NOT_IMPLEMENTED
_replier->setIgnore(true);
_feeder->sendDown(api::StorageCommand::SP(
new api::StatBucketCommand(document::BucketId(0), "")));
_feeder->close();
_feeder->flush();
CPPUNIT_ASSERT_EQUAL((size_t) 1, _feeder->getNumReplies());
CPPUNIT_ASSERT_EQUAL(
dynamic_cast<api::StatBucketReply&>(
*_feeder->getReply(0)).getResult(),
api::ReturnCode(api::ReturnCode::NOT_IMPLEMENTED, "Statbucket"));
_feeder->reset();
_replier->setIgnore(false);
}
} // storage
|