blob: 4073469c253632a1b87e05cc34f0771386664baa (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/messagebus/errorcode.h>
#include <vespa/messagebus/routing/retrytransienterrorspolicy.h>
#include <vespa/messagebus/testlib/receptor.h>
#include <vespa/messagebus/testlib/simplemessage.h>
#include <vespa/messagebus/testlib/simpleprotocol.h>
#include <vespa/messagebus/testlib/simplereply.h>
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/vespalib/testkit/testapp.h>
using namespace mbus;
TEST_SETUP(Test);
class MyMessage : public SimpleMessage {
public:
MyMessage() : SimpleMessage("foo") { }
bool hasBucketSequence() override { return true; }
};
int
Test::Main()
{
TEST_INIT("bucketsequence_test");
Slobrok slobrok;
TestServer server(MessageBusParams()
.addProtocol(IProtocol::SP(new SimpleProtocol()))
.setRetryPolicy(IRetryPolicy::SP(new RetryTransientErrorsPolicy())),
RPCNetworkParams()
.setSlobrokConfig(slobrok.config()));
Receptor receptor;
SourceSession::UP session = server.mb.createSourceSession(
SourceSessionParams()
.setReplyHandler(receptor));
Message::UP msg(new MyMessage());
msg->setRoute(Route::parse("foo"));
ASSERT_TRUE(session->send(std::move(msg)).isAccepted());
Reply::UP reply = receptor.getReply();
ASSERT_TRUE(reply.get() != NULL);
EXPECT_EQUAL(1u, reply->getNumErrors());
EXPECT_EQUAL((uint32_t)ErrorCode::SEQUENCE_ERROR, reply->getError(0).getCode());
TEST_DONE();
}
|