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.pcep.PCEPSession;
14 import org.opendaylight.protocol.pcep.PCEPSessionListener;
15 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
16 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class MockPCE implements PCEPSessionListener {
24 private final List<Message> listMsg = new ArrayList<Message>();
26 private PCEPSessionImpl session = null;
28 public boolean up = false;
30 private static final Logger LOG = LoggerFactory.getLogger(MockPCE.class);
32 public boolean down = false;
37 public void sendMessage(final Message msg) {
38 this.session.handleMessage(msg);
41 public void sendErrorMessage(final PCEPErrors value, final Open open) {
42 this.sendMessage(Util.createErrorMessage(value, open));
45 public List<Message> getListMsg() {
49 public void addSession(final PCEPSessionImpl l) {
54 public void onMessage(final PCEPSession session, final Message message) {
55 this.listMsg.add(message);
56 LOG.debug("Message received: {}", message);
60 public void onSessionUp(final PCEPSession session) {
61 LOG.debug("Session Up");
67 public void onSessionDown(final PCEPSession session, final Exception e) {
68 LOG.debug("Session Down.", e);
74 public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
75 LOG.debug("Session terminated. Cause : {}", cause);