Enforce checkstyle and findbug under PCE Api
[bgpcep.git] / pcep / testtool / src / main / java / org / opendaylight / protocol / pcep / testtool / TestingSessionListener.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.protocol.pcep.testtool;
9
10 import com.google.common.collect.Lists;
11 import java.util.List;
12 import org.opendaylight.protocol.pcep.PCEPSession;
13 import org.opendaylight.protocol.pcep.PCEPSessionListener;
14 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class TestingSessionListener implements PCEPSessionListener {
20
21     private final List<Message> messages = Lists.newArrayList();
22
23     private boolean up = false;
24
25     private static final Logger LOG = LoggerFactory.getLogger(TestingSessionListener.class);
26
27     public TestingSessionListener() {
28     }
29
30     @Override
31     public void onMessage(final PCEPSession session, final Message message) {
32         LOG.debug("Received message: {}", message);
33         this.messages.add(message);
34     }
35
36     @Override
37     public void onSessionUp(final PCEPSession session) {
38         LOG.debug("Session up.");
39         this.up = true;
40     }
41
42     @Override
43     public void onSessionDown(final PCEPSession session, final Exception exception) {
44         LOG.debug("Session down. Cause : {} ", exception, exception);
45         this.up = false;
46     }
47
48     @Override
49     public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
50         LOG.debug("Session terminated. Cause : {}", cause);
51     }
52
53     public List<Message> messages() {
54         return this.messages;
55     }
56
57     public boolean isUp () {
58         return this.up;
59     }
60 }