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.registration;
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 ListenerRegistration.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 ListenerRegistrationMessagesTest extends AbstractMessagesTest {
33 public void verifySerialization() throws Exception {
34 String testListenerRegistrationPath =
35 "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test?revision=2014-04-15)family";
36 ListenerRegistrationMessages.RegisterChangeListenerReply.Builder builder =
37 ListenerRegistrationMessages.RegisterChangeListenerReply.newBuilder();
38 builder.setListenerRegistrationPath(testListenerRegistrationPath);
40 writeToFile((com.google.protobuf.GeneratedMessage.Builder<?>) builder);
42 ListenerRegistrationMessages.RegisterChangeListenerReply rclrNew =
43 (ListenerRegistrationMessages.RegisterChangeListenerReply) readFromFile(ListenerRegistrationMessages.RegisterChangeListenerReply.PARSER);
44 Assert.assertEquals(testListenerRegistrationPath,
45 rclrNew.getListenerRegistrationPath());
47 ListenerRegistrationMessages.RegisterChangeListenerReply rclrOriginal =
48 (ListenerRegistrationMessages.RegisterChangeListenerReply) readFromTestDataFile(ListenerRegistrationMessages.RegisterChangeListenerReply.PARSER);
49 Assert.assertEquals(rclrOriginal.getListenerRegistrationPath(),
50 rclrNew.getListenerRegistrationPath());
55 public String getTestFileName() {
56 return ListenerRegistrationMessages.class.getSimpleName();