Remove DataChangeListener protobuff messages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / messages / RegisterChangeListenerReplyTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore.messages;
10
11 import static junit.framework.TestCase.assertEquals;
12 import akka.actor.Actor;
13 import akka.serialization.Serialization;
14 import akka.testkit.TestActorRef;
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
19 import org.opendaylight.controller.cluster.raft.TestActorFactory;
20 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
21 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
22
23 public class RegisterChangeListenerReplyTest extends AbstractActorTest {
24
25     private TestActorFactory factory;
26
27
28     @Before
29     public void setUp(){
30         factory = new TestActorFactory(getSystem());
31     }
32
33     @After
34     public void shutDown(){
35         factory.close();
36     }
37
38     @Test
39     public void testToSerializable(){
40         TestActorRef<Actor> testActor = factory.createTestActor(MessageCollectorActor.props());
41
42         RegisterChangeListenerReply registerChangeListenerReply = new RegisterChangeListenerReply(testActor);
43
44         ListenerRegistrationMessages.RegisterChangeListenerReply serialized
45                 = registerChangeListenerReply.toSerializable();
46
47         assertEquals(Serialization.serializedActorPath(testActor), serialized.getListenerRegistrationPath());
48     }
49
50     @Test
51     public void testFromSerializable(){
52         TestActorRef<Actor> testActor = factory.createTestActor(MessageCollectorActor.props());
53
54         RegisterChangeListenerReply registerChangeListenerReply = new RegisterChangeListenerReply(testActor);
55
56         ListenerRegistrationMessages.RegisterChangeListenerReply serialized
57                 = registerChangeListenerReply.toSerializable();
58
59
60         RegisterChangeListenerReply fromSerialized
61                 = RegisterChangeListenerReply.fromSerializable(getSystem(), serialized);
62
63         assertEquals(testActor.path().toString(), fromSerialized.getListenerRegistrationPath().toString());
64     }
65
66 }