Code Clean Up
[bgpcep.git] / bgp / 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 /**
20  * Created by cgasparini on 21.5.2015.
21  */
22 public class BmpTestSessionListener implements BmpSessionListener {
23
24     private static final Logger LOG = LoggerFactory.getLogger(BmpTestSessionListener.class);
25     private List<Notification> messages = Lists.newArrayList();
26     private boolean up = false;
27
28     public boolean isUp () {
29         return this.up;
30     }
31
32     public List<Notification> getListMsg() {
33         return this.messages;
34     }
35
36     @Override
37     public void onMessage(final Notification message) {
38         LOG.debug("Received message: {} {}", message.getClass(), message);
39         this.messages.add(message);
40     }
41
42     @Override
43     public synchronized void onSessionUp(final BmpSession session) {
44         LOG.debug("Session up.");
45         this.up = true;
46     }
47
48     @Override
49     public void onSessionDown(final Exception e) {
50         LOG.debug("Session down.", e);
51         this.up = false;
52     }
53 }
54
55