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.cohort3pc;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest;
18 * This test case is present to ensure that if others have used proper version of protocol buffer
19 * for the cohort.proto messages
21 * If a different version of protocol buffer and there is change in serializaiton format
22 * this test would break as we are comparing with protocol buffer 2.5 generated
30 public class ThreePhaseCommitCohortMessagesTest extends AbstractMessagesTest {
34 public void verifySerialization() throws Exception {
38 ThreePhaseCommitCohortMessages.CanCommitTransactionReply.Builder builder =
39 ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder();
40 builder.setCanCommit(true);
42 writeToFile((com.google.protobuf.GeneratedMessage.Builder<?>) builder);
44 // Here we will read from the just serialized data
46 ThreePhaseCommitCohortMessages.CanCommitTransactionReply newCanCommitTransactionReply =
47 (ThreePhaseCommitCohortMessages.CanCommitTransactionReply) readFromFile(ThreePhaseCommitCohortMessages.CanCommitTransactionReply.PARSER);
49 Assert.assertTrue(newCanCommitTransactionReply.getCanCommit());
52 // Here we will read the same from our test-data file and check we got back what we had saved
54 ThreePhaseCommitCohortMessages.CanCommitTransactionReply originalCanCommitTransactionReply =
55 (ThreePhaseCommitCohortMessages.CanCommitTransactionReply) readFromTestDataFile(ThreePhaseCommitCohortMessages.CanCommitTransactionReply.PARSER);
57 Assert.assertEquals(newCanCommitTransactionReply.getCanCommit(),
58 originalCanCommitTransactionReply.getCanCommit());
63 public String getTestFileName() {
64 return ThreePhaseCommitCohortMessagesTest.class.getSimpleName();