Merge "Remove remoterpc dead code."
[controller.git] / opendaylight / md-sal / sal-protocolbuffer-encoding / src / test / java / org / opendaylight / controller / cluster / datastore / messages / ShardManagerMessagesTest.java
1 package org.opendaylight.controller.cluster.datastore.messages;
2
3 /**
4  * This test case is present to ensure that if others have
5  * used proper version of protocol buffer.
6  *
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.
10  *
11  * @author: syedbahm
12  * Date: 6/20/14
13  *
14  */
15
16 import org.junit.Assert;
17 import org.junit.Test;
18 import org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages;
19
20 import java.io.File;
21 import java.io.FileInputStream;
22 import java.io.FileOutputStream;
23
24 public class ShardManagerMessagesTest {
25
26   @Test
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);
33    output.close();
34
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());
39
40     testFile.delete();
41
42   }
43 }