throws Exception {
new JavaTestKit(getSystem()) {{
- MockRaftActorContext context = (MockRaftActorContext)
- createActorContext();
+ MockRaftActorContext context = createActorContext();
// First set the receivers term to a high number (1000)
context.getTermInformation().update(1000, "test");
final Boolean out = new ExpectMsg<Boolean>(duration("1 seconds"),
"AppendEntriesReply") {
// do not put code outside this method, will run afterwards
+ @Override
protected Boolean match(Object in) {
if (in instanceof AppendEntriesReply) {
AppendEntriesReply reply = (AppendEntriesReply) in;
new JavaTestKit(getSystem()) {
{
- MockRaftActorContext context = (MockRaftActorContext)
- createActorContext();
+ MockRaftActorContext context = createActorContext();
// First set the receivers term to lower number
context.getTermInformation().update(2, "test");
new JavaTestKit(getSystem()) {{
new Within(duration("1 seconds")) {
+ @Override
protected void run() {
RaftActorBehavior behavior = createBehavior(
new ExpectMsg<Boolean>(duration("1 seconds"),
"RequestVoteReply") {
// do not put code outside this method, will run afterwards
+ @Override
protected Boolean match(Object in) {
if (in instanceof RequestVoteReply) {
RequestVoteReply reply =
new JavaTestKit(getSystem()) {{
new Within(duration("1 seconds")) {
+ @Override
protected void run() {
RaftActorContext actorContext =
new ExpectMsg<Boolean>(duration("1 seconds"),
"RequestVoteReply") {
// do not put code outside this method, will run afterwards
+ @Override
protected Boolean match(Object in) {
if (in instanceof RequestVoteReply) {
RequestVoteReply reply =
new JavaTestKit(getSystem()) {{
new Within(duration("1 seconds")) {
+ @Override
protected void run() {
RaftActorContext context =
new ExpectMsg<Boolean>(duration("1 seconds"),
"RequestVoteReply") {
// do not put code outside this method, will run afterwards
+ @Override
protected Boolean match(Object in) {
if (in instanceof RequestVoteReply) {
RequestVoteReply reply =
return createBehavior(createActorContext());
}
- protected RaftActorContext createActorContext() {
+ protected MockRaftActorContext createActorContext() {
return new MockRaftActorContext();
}
- protected RaftActorContext createActorContext(ActorRef actor) {
+ protected MockRaftActorContext createActorContext(ActorRef actor) {
return new MockRaftActorContext("test", getSystem(), actor);
}