3 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
11 package org.opendaylight.controller.protobuff.messages.transaction;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest;
16 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
17 import org.opendaylight.yangtools.yang.common.QName;
20 * This test case is present to ensure that if others have used proper version of protocol buffer
21 * for the ShardTransactionChain.proto messages
23 * If a different version of protocol buffer and there is change in serializaiton format
24 * this test would break as we are comparing with protocol buffer 2.5 generated
32 public class ShardTransactionChainMessagesTest extends AbstractMessagesTest {
36 public void verifySerialization() throws Exception {
37 String testTransactionChainPath =
40 ShardTransactionChainMessages.CreateTransactionChainReply.Builder builder =
41 ShardTransactionChainMessages.CreateTransactionChainReply.newBuilder();
42 builder.setTransactionChainPath(testTransactionChainPath);
44 writeToFile((com.google.protobuf.GeneratedMessage.Builder<?>) builder);
46 // Here we will read the same and check we got back what we had saved
47 ShardTransactionChainMessages.CreateTransactionChainReply replyNew =
48 (ShardTransactionChainMessages.CreateTransactionChainReply) readFromFile(ShardTransactionChainMessages.CreateTransactionChainReply.PARSER);
50 Assert.assertEquals(replyNew.getTransactionChainPath(),testTransactionChainPath);
52 // the following will compare with the version we had shipped
53 ShardTransactionChainMessages.CreateTransactionChainReply replyOriginal =
54 (ShardTransactionChainMessages.CreateTransactionChainReply) readFromTestDataFile(ShardTransactionChainMessages.CreateTransactionChainReply.PARSER);
57 Assert.assertEquals(replyOriginal.getTransactionChainPath(),
58 replyNew.getTransactionChainPath());
63 public String getTestFileName() {
64 return ShardTransactionChainMessagesTest.class.getSimpleName();