f08a295dffcb2313bda29a7e665b36c59ba771a3
[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 java.util.List;
11
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 import com.google.common.collect.Lists;
20
21 public class TestingSessionListener implements PCEPSessionListener {
22
23         public List<Message> messages = Lists.newArrayList();
24
25         public boolean up = false;
26
27         private static final Logger logger = LoggerFactory.getLogger(TestingSessionListener.class);
28
29         public TestingSessionListener() {
30         }
31
32         @Override
33         public void onMessage(final PCEPSession session, final Message message) {
34                 logger.debug("Received message: {}", message);
35                 this.messages.add(message);
36         }
37
38         @Override
39         public void onSessionUp(final PCEPSession session) {
40                 logger.debug("Session up.");
41                 this.up = true;
42         }
43
44         @Override
45         public void onSessionDown(final PCEPSession session, final Exception e) {
46                 logger.debug("Session down. Cause : {} or {}", e);
47                 this.up = false;
48         }
49
50         @Override
51         public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
52                 logger.debug("Session terminated. Cause : {}", cause);
53         }
54 }