1 package org.opendaylight.controller.cluster.datastore.messages;
4 * This test case is present to ensure that if others have
5 * used proper version of protocol buffer.
7 * If a different version of protocol buffer is used then it would
8 * generate different java sources and would result in
9 * breaking of this test case.
16 import org.junit.Assert;
17 import org.junit.Test;
18 import org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages;
21 import java.io.FileInputStream;
22 import java.io.FileOutputStream;
24 public class ShardManagerMessagesTest {
27 public void verifySerialization()throws Exception{
28 ShardManagerMessages.FindPrimary.Builder builder = ShardManagerMessages.FindPrimary.newBuilder();
29 builder.setShardName("Inventory");
30 File testFile = new File("./test");
31 FileOutputStream output = new FileOutputStream(testFile);
32 builder.build().writeTo(output);
35 //Here we will read the same and check we got back what we had saved
36 ShardManagerMessages.FindPrimary findPrimary
37 = ShardManagerMessages.FindPrimary.parseFrom(new FileInputStream(testFile));
38 Assert.assertEquals("Inventory", findPrimary.getShardName());