Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / messages / AppendEntriesReplyTest.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.raft.messages;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.apache.commons.lang3.SerializationUtils;
13 import org.junit.Test;
14 import org.opendaylight.controller.cluster.raft.RaftVersions;
15
16 /**
17  * Unit tests for AppendEntriesReply.
18  *
19  * @author Thomas Pantelis
20  */
21 public class AppendEntriesReplyTest {
22     @Test
23     public void testSerialization() {
24         final var expected = new AppendEntriesReply("follower", 5, true, 100, 4, (short)6, true, true,
25             RaftVersions.CURRENT_VERSION);
26
27         final var bytes = SerializationUtils.serialize(expected);
28         assertEquals(98, bytes.length);
29         final var cloned = (AppendEntriesReply) SerializationUtils.deserialize(bytes);
30
31         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
32         assertEquals("getFollowerId", expected.getFollowerId(), cloned.getFollowerId());
33         assertEquals("getLogLastTerm", expected.getLogLastTerm(), cloned.getLogLastTerm());
34         assertEquals("getLogLastIndex", expected.getLogLastIndex(), cloned.getLogLastIndex());
35         assertEquals("getPayloadVersion", expected.getPayloadVersion(), cloned.getPayloadVersion());
36         assertEquals("getRaftVersion", expected.getRaftVersion(), cloned.getRaftVersion());
37         assertEquals("isForceInstallSnapshot", expected.isForceInstallSnapshot(), cloned.isForceInstallSnapshot());
38         assertEquals("isNeedsLeaderAddress", expected.isNeedsLeaderAddress(), cloned.isNeedsLeaderAddress());
39     }
40 }