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.opendaylight.protocol.framework.TerminationReason;
14 import org.opendaylight.protocol.pcep.PCEPErrors;
15 import org.opendaylight.protocol.pcep.PCEPMessage;
16 import org.opendaylight.protocol.pcep.PCEPSession;
17 import org.opendaylight.protocol.pcep.PCEPSessionListener;
18 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
19 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
20 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
27 public class MockPCE extends PCEPSessionListener {
29 private final List<PCEPMessage> listMsg = new ArrayList<PCEPMessage>();
31 private PCEPSessionImpl session = null;
33 public boolean up = false;
35 private static final Logger logger = LoggerFactory.getLogger(MockPCE.class);
37 public boolean down = false;
42 public void sendMessage(final PCEPMessage msg) {
43 this.session.handleMessage(msg);
46 public void sendErrorMessage(final PCEPErrors value, final PCEPOpenObject open) {
47 final PCEPErrorObject error = new PCEPErrorObject(value);
48 final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
50 this.sendMessage(new PCEPErrorMessage(open, errors, null));
53 public List<PCEPMessage> getListMsg() {
57 public void addSession(final PCEPSessionImpl l) {
62 public void onMessage(final PCEPSession session, final PCEPMessage message) {
63 this.listMsg.add(message);
64 logger.debug("Message received: {}", message);
68 public void onSessionUp(final PCEPSession session, final PCEPOpenObject local, final PCEPOpenObject remote) {
69 logger.debug("Session Up");
75 public void onSessionDown(final PCEPSession session, final TerminationReason reason, final Exception e) {
76 logger.debug("Session Down. Cause {} or {}.", reason, e);
82 public void onSessionTerminated(final PCEPSession session, final TerminationReason cause) {
83 logger.debug("Session terminated. Cause : {}", cause);