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 io.netty.util.HashedWheelTimer;
11 import io.netty.util.concurrent.GlobalEventExecutor;
13 import java.net.InetSocketAddress;
14 import java.util.List;
16 import org.opendaylight.protocol.framework.DispatcherImpl;
17 import org.opendaylight.protocol.framework.NeverReconnectStrategy;
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.PCEPTerminationReason;
22 import org.opendaylight.protocol.pcep.PCEPTlv;
23 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
24 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
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 Exception {
33 final List<PCEPTlv> tlvs = Lists.newArrayList();
34 tlvs.add(new NodeIdentifierTlv(new byte[] { (byte) 127, (byte) 2, (byte) 3, (byte) 7 }));
36 final DispatcherImpl di = new DispatcherImpl();
37 final PCEPDispatcherImpl d = new PCEPDispatcherImpl(di,
38 new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new PCEPOpenObject(30, 120, 0, tlvs), 0));
41 d.createClient(new InetSocketAddress("127.0.0.3", 12345),
42 new PCEPSessionListener() {
45 public void onMessage(final PCEPSession session, final PCEPMessage message) {
46 // TODO Auto-generated method stub
51 public void onSessionUp(final PCEPSession session) {
52 // TODO Auto-generated method stub
57 public void onSessionDown(final PCEPSession session, final Exception e) {
58 // TODO Auto-generated method stub
63 public void onSessionTerminated(final PCEPSession session,
64 final PCEPTerminationReason cause) {
65 // TODO Auto-generated method stub
68 }, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000)).get();
70 // Thread.sleep(5000);
71 // final List<CompositeRequestObject> cro = new ArrayList<CompositeRequestObject>();
72 // cro.add(new CompositeRequestObject(new PCEPRequestParameterObject(false, true, true, true, true, (short)
73 // 4, 123, false, false),
74 // new PCEPEndPointsObject<IPv4Address>(new IPv4Address(InetAddress.getByName("10.0.0.3")), new
75 // IPv4Address(InetAddress.getByName("10.0.0.5")))));
76 // for (int i = 0; i < 3; i++) {
77 // Thread.sleep(1000);
78 // session.sendMessage(new PCEPRequestMessage(cro));
80 // Thread.sleep(5000);
81 // Thread.sleep(1000);