2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.messages;
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;
23 public class RegisterChangeListenerReplyTest extends AbstractActorTest {
25 private TestActorFactory factory;
30 factory = new TestActorFactory(getSystem());
34 public void shutDown(){
39 public void testToSerializable(){
40 TestActorRef<Actor> testActor = factory.createTestActor(MessageCollectorActor.props());
42 RegisterChangeListenerReply registerChangeListenerReply = new RegisterChangeListenerReply(testActor);
44 ListenerRegistrationMessages.RegisterChangeListenerReply serialized
45 = registerChangeListenerReply.toSerializable();
47 assertEquals(Serialization.serializedActorPath(testActor), serialized.getListenerRegistrationPath());
51 public void testFromSerializable(){
52 TestActorRef<Actor> testActor = factory.createTestActor(MessageCollectorActor.props());
54 RegisterChangeListenerReply registerChangeListenerReply = new RegisterChangeListenerReply(testActor);
56 ListenerRegistrationMessages.RegisterChangeListenerReply serialized
57 = registerChangeListenerReply.toSerializable();
60 RegisterChangeListenerReply fromSerialized
61 = RegisterChangeListenerReply.fromSerializable(getSystem(), serialized);
63 assertEquals(testActor.path().toString(), fromSerialized.getListenerRegistrationPath().toString());