Merge "Bug 1308 - Unable to publish NodeUpdated message via NotificationService"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / protobuff / messages / transaction / ShardTransactionChainMessagesTest.java
1 /*
2  *
3  *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  *
9  */
10
11 package org.opendaylight.controller.protobuff.messages.transaction;
12
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;
18
19 /**
20  * This test case is present to ensure that if others have used proper version of protocol buffer
21  * for the ShardTransactionChain.proto messages
22  *
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
25  * serialized data.
26  *
27  * @author: syedbahm
28  *
29  */
30
31
32 public class ShardTransactionChainMessagesTest extends AbstractMessagesTest {
33
34   @Override
35   @Test
36   public void verifySerialization() throws Exception {
37     String testTransactionChainPath =
38         "/actor/path";
39
40     ShardTransactionChainMessages.CreateTransactionChainReply.Builder builder =
41         ShardTransactionChainMessages.CreateTransactionChainReply.newBuilder();
42     builder.setTransactionChainPath(testTransactionChainPath);
43
44     writeToFile((com.google.protobuf.GeneratedMessage.Builder<?>) builder);
45
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);
49
50     Assert.assertEquals(replyNew.getTransactionChainPath(),testTransactionChainPath);
51
52     // the following will compare with the version we had shipped
53     ShardTransactionChainMessages.CreateTransactionChainReply replyOriginal =
54         (ShardTransactionChainMessages.CreateTransactionChainReply) readFromTestDataFile(ShardTransactionChainMessages.CreateTransactionChainReply.PARSER);
55
56
57     Assert.assertEquals(replyOriginal.getTransactionChainPath(),
58         replyNew.getTransactionChainPath());
59
60   }
61
62   @Override
63   public String getTestFileName() {
64     return ShardTransactionChainMessagesTest.class.getSimpleName();
65   }
66
67
68
69 }