BGPCEP-706: Fix BGP Flowspec NumbericOphrand
[bgpcep.git] / bmp / bmp-impl / src / test / java / org / opendaylight / protocol / bmp / impl / session / BmpTestSessionListener.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.protocol.bmp.impl.session;
10
11 import com.google.common.collect.Lists;
12 import java.util.List;
13 import org.opendaylight.protocol.bmp.api.BmpSession;
14 import org.opendaylight.protocol.bmp.api.BmpSessionListener;
15 import org.opendaylight.yangtools.yang.binding.Notification;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class BmpTestSessionListener implements BmpSessionListener {
20
21     private static final Logger LOG = LoggerFactory.getLogger(BmpTestSessionListener.class);
22     private final List<Notification> messages = Lists.newArrayList();
23     private boolean up = false;
24
25     public boolean isUp () {
26         return this.up;
27     }
28
29     public List<Notification> getListMsg() {
30         return this.messages;
31     }
32
33     @Override
34     public void onMessage(final Notification message) {
35         LOG.debug("Received message: {} {}", message.getClass(), message);
36         this.messages.add(message);
37     }
38
39     @Override
40     public synchronized void onSessionUp(final BmpSession session) {
41         LOG.debug("Session up.");
42         this.up = true;
43     }
44
45     @Override
46     public void onSessionDown(final Exception e) {
47         LOG.debug("Session down.", e);
48         this.up = false;
49     }
50 }
51
52