2 * Copyright (c) 2013 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
8 package org.opendaylight.protocol.bgp.rib.mock;
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.List;
15 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
16 import org.opendaylight.protocol.bgp.parser.BGPError;
17 import org.opendaylight.protocol.bgp.parser.BGPMessage;
18 import org.opendaylight.protocol.bgp.parser.BGPSession;
19 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
23 * Mock implementation of {@link BGPListener} for testing purposes.
25 final class BGPListenerMock extends BGPSessionListener {
26 private final List<BGPMessage> buffer = Collections.synchronizedList(new ArrayList<BGPMessage>());
27 private boolean connected = false;
29 protected List<BGPMessage> getBuffer() {
33 protected boolean isConnected() {
34 return this.connected;
38 public void onMessage(final BGPMessage message) {
39 this.buffer.add(message);
43 public void onSessionUp(final Set<BGPTableType> remoteParams) {
44 this.connected = true;
48 public void onSessionDown(final BGPSession session, final Exception e) {
49 this.connected = false;
53 public void onSessionTerminated(final BGPError cause) {
54 this.connected = false;