Merge "Bug 1328: Improved argument checks in generated RPC Router"
[controller.git] / opendaylight / md-sal / sal-protocolbuffer-encoding / src / test / java / org / opendaylight / controller / protobuff / messages / ShardManagerMessagesTest.java
1 package org.opendaylight.controller.protobuff.messages;
2
3 /**
4  * This test case is present to ensure that if others have used proper version of protocol buffer.
5  *
6  * If a different version of protocol buffer is used then it would generate different java sources
7  * and would result in breaking of this test case.
8  *
9  * @author: syedbahm Date: 6/20/14
10  *
11  */
12
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages;
16
17 import java.io.File;
18 import java.io.FileInputStream;
19 import java.io.FileOutputStream;
20
21 public class ShardManagerMessagesTest {
22
23   @Test
24   public void verifySerialization() throws Exception {
25     ShardManagerMessages.FindPrimary.Builder builder =
26         ShardManagerMessages.FindPrimary.newBuilder();
27     builder.setShardName("Inventory");
28     File testFile = new File("./test");
29     FileOutputStream output = new FileOutputStream(testFile);
30     builder.build().writeTo(output);
31     output.close();
32
33     // Here we will read the same and check we got back what we had saved
34     ShardManagerMessages.FindPrimary findPrimary =
35         ShardManagerMessages.FindPrimary
36             .parseFrom(new FileInputStream(testFile));
37     Assert.assertEquals("Inventory", findPrimary.getShardName());
38
39     testFile.delete();
40
41   }
42 }