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.testtool;
10 import java.io.IOException;
11 import java.net.InetSocketAddress;
12 import java.util.List;
14 import org.opendaylight.protocol.framework.DispatcherImpl;
15 import org.opendaylight.protocol.framework.SessionPreferences;
16 import org.opendaylight.protocol.pcep.PCEPConnection;
17 import org.opendaylight.protocol.pcep.PCEPSessionListener;
18 import org.opendaylight.protocol.pcep.PCEPSessionPreferences;
19 import org.opendaylight.protocol.pcep.PCEPSessionProposal;
20 import org.opendaylight.protocol.pcep.PCEPSessionProposalChecker;
21 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
22 import org.opendaylight.protocol.pcep.PCEPTlv;
23 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
24 import org.opendaylight.protocol.pcep.impl.PCEPMessageFactory;
25 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
26 import org.opendaylight.protocol.pcep.tlv.NodeIdentifierTlv;
28 import com.google.common.collect.Lists;
30 public class PCCMock {
32 public static void main(final String[] args) throws IOException, InterruptedException {
33 final List<PCEPTlv> tlvs = Lists.newArrayList();
34 tlvs.add(new NodeIdentifierTlv(new byte[] { (byte) 127, (byte) 2, (byte) 3, (byte) 7 }));
35 final PCEPSessionPreferences prop = new PCEPSessionPreferences(new PCEPOpenObject(30, 120, 0, tlvs));
36 final DispatcherImpl di = new DispatcherImpl(new PCEPMessageFactory());
37 final PCEPDispatcherImpl d = new PCEPDispatcherImpl(di, new PCEPSessionProposalFactory() {
40 public PCEPSessionProposal getSessionProposal(final InetSocketAddress address, final int sessionId) {
41 return new PCEPSessionProposal() {
44 public PCEPSessionPreferences getProposal() {
53 final PCEPSessionProposalChecker check = new PCEPSessionProposalChecker() {
55 public Boolean checkSessionCharacteristics(final SessionPreferences openObj) {
60 public PCEPSessionPreferences getNewProposal(final SessionPreferences open) {
61 return new PCEPSessionPreferences(new PCEPOpenObject(30, 120, 0, null));
65 d.createClient(new PCEPConnection() {
67 public InetSocketAddress getPeerAddress() {
68 return new InetSocketAddress("127.0.0.3", 12345);
72 public PCEPSessionProposalChecker getProposalChecker() {
77 public PCEPSessionPreferences getProposal() {
82 public PCEPSessionListener getListener() {
83 return new SimpleSessionListener();
86 // Thread.sleep(5000);
87 // final List<CompositeRequestObject> cro = new ArrayList<CompositeRequestObject>();
88 // cro.add(new CompositeRequestObject(new PCEPRequestParameterObject(false, true, true, true, true, (short)
89 // 4, 123, false, false),
90 // new PCEPEndPointsObject<IPv4Address>(new IPv4Address(InetAddress.getByName("10.0.0.3")), new
91 // IPv4Address(InetAddress.getByName("10.0.0.5")))));
92 // for (int i = 0; i < 3; i++) {
93 // Thread.sleep(1000);
94 // session.sendMessage(new PCEPRequestMessage(cro));
96 // Thread.sleep(5000);
97 // Thread.sleep(1000);