1 package org.opendaylight.controller.protobuff.messages;
4 * This test case is present to ensure that if others have used proper version of protocol buffer.
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.
9 * @author: syedbahm Date: 6/20/14
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages;
18 import java.io.FileInputStream;
19 import java.io.FileOutputStream;
21 public class ShardManagerMessagesTest {
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);
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());