2 * Copyright (c) 2014 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.utils;
11 import akka.actor.UntypedActor;
13 import java.util.ArrayList;
14 import java.util.List;
17 * MessageCollectorActor collects messages as it receives them. It can send
18 * those collected messages to any sender which sends it the "messages" message
20 * This class would be useful as a mock to test whether messages were sent
21 * to a remote actor or not.
24 public class MessageCollectorActor extends UntypedActor {
25 private List<Object> messages = new ArrayList<>();
27 @Override public void onReceive(Object message) throws Exception {
28 if(message instanceof String){
29 if("messages".equals(message)){
30 getSender().tell(messages, getSelf());
33 messages.add(message);