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.common;
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 common.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
29 public class NormalizedNodeMessagesTest extends AbstractMessagesTest {
33 public void verifySerialization() throws Exception {
34 NormalizedNodeMessages.Attribute.Builder builder =
35 NormalizedNodeMessages.Attribute.newBuilder();
36 builder.setName("test");
37 builder.setType("fake");
38 builder.setValue("testValue");
39 writeToFile((com.google.protobuf.GeneratedMessage.Builder<?>) builder);
41 NormalizedNodeMessages.Attribute attributeNew =
42 (NormalizedNodeMessages.Attribute) readFromFile(NormalizedNodeMessages.Attribute.PARSER);
43 Assert.assertEquals("test", attributeNew.getName());
44 Assert.assertEquals("fake", attributeNew.getType());
45 Assert.assertEquals("testValue", attributeNew.getValue());
47 NormalizedNodeMessages.Attribute attributeOriginal =
48 (NormalizedNodeMessages.Attribute) readFromTestDataFile(NormalizedNodeMessages.Attribute.PARSER);
49 Assert.assertEquals(attributeNew.getName(), attributeOriginal.getName());
53 public String getTestFileName() {
54 return NormalizedNodeMessagesTest.class.getSimpleName();