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.pcep.impl;
10 import java.util.ArrayList;
11 import java.util.List;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 import org.opendaylight.protocol.framework.TerminationReason;
17 import org.opendaylight.protocol.pcep.PCEPErrors;
18 import org.opendaylight.protocol.pcep.PCEPMessage;
19 import org.opendaylight.protocol.pcep.PCEPSession;
20 import org.opendaylight.protocol.pcep.PCEPSessionListener;
21 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
22 import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
23 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
24 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
29 public class MockPCE extends PCEPSessionListener {
31 private final List<PCEPMessage> listMsg = new ArrayList<PCEPMessage>();
33 private PCEPSessionImpl session = null;
35 public boolean up = false;
37 private static final Logger logger = LoggerFactory.getLogger(MockPCE.class);
39 public boolean down = false;
44 public void sendMessage(PCEPMessage msg) {
45 this.session.handleMessage(msg);
48 public void sendErrorMessage(PCEPErrors value,
49 PCEPOpenObject open) {
50 final PCEPErrorObject error = new PCEPErrorObject(value);
51 final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
53 this.sendMessage(new PCEPErrorMessage(open, errors, null));
56 public List<PCEPMessage> getListMsg() {
60 public void addSession(PCEPSessionImpl l) {
65 public void onMessage(PCEPSession session, PCEPMessage message) {
66 this.listMsg.add(message);
67 logger.debug("Message received:" + message);
71 public void onSessionUp(PCEPSession session, PCEPOpenObject local,
72 PCEPOpenObject remote) {
73 logger.debug("Session Up");
79 public void onSessionDown(PCEPSession session, PCEPCloseObject reason, Exception e) {
80 logger.debug("Session Down");
86 public void onSessionTerminated(PCEPSession session,
87 TerminationReason cause) {
88 logger.debug("Session terminated. Cause : " + cause.toString());