2 * Copyright (c) 2014 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
9 package org.opendaylight.protocol.pcep.pcc.mock;
11 import io.netty.channel.Channel;
12 import java.net.InetSocketAddress;
13 import java.util.Collections;
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.protocol.pcep.PCEPCapability;
17 import org.opendaylight.protocol.util.InetSocketAddressUtil;
19 public final class PCCMockTest extends PCCMockCommon {
20 private final String localAddress2 = "127.0.0.2";
21 private final String localIpAddress = "127.0.0.1";
22 private final String[] mainInput = new String[]{"--local-address", localIpAddress,
23 "--remote-address", InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1",
24 "--lsp", "3", "--log-level", "DEBUG", "-ka", "10", "-d", "40", "--reconnect", "-1",
25 "--redelegation-timeout", "0", "--state-timeout", "-1"};
28 public void testSessionEstablishment() throws Exception {
29 final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
30 final Channel channel = createServer(factory, this.remoteAddress);
31 Main.main(this.mainInput);
33 //3 reported LSPs + syc
34 final int numMessages = 4;
35 final TestingSessionListener sessionListener = checkSessionListener(numMessages, channel, factory,
37 checkSession(sessionListener.getSession(), 40, 10);
42 public void testMockPCCToManyPCE() throws Exception {
43 final InetSocketAddress serverAddress2 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
44 final InetSocketAddress serverAddress3 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
45 final InetSocketAddress serverAddress4 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
47 final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
48 final TestingSessionListenerFactory factory2 = new TestingSessionListenerFactory();
49 final TestingSessionListenerFactory factory3 = new TestingSessionListenerFactory();
50 final Channel channel = createServer(factory, serverAddress2);
51 final Channel channel2 = createServer(factory2, serverAddress3);
52 final Channel channel3 = createServer(factory3, serverAddress4);
54 Main.main(new String[]{"--local-address", this.localIpAddress, "--remote-address",
55 InetSocketAddressUtil.toHostAndPort(serverAddress2).toString() + ","
56 + InetSocketAddressUtil.toHostAndPort(serverAddress3).toString() + ","
57 + InetSocketAddressUtil.toHostAndPort(serverAddress4).toString(), "--pcc", "2"});
60 final int numMessages = 2;
61 checkSessionListener(numMessages, channel, factory, this.localIpAddress);
62 checkSessionListener(numMessages, channel, factory, this.localAddress2);
64 checkSessionListener(numMessages, channel2, factory2, this.localIpAddress);
65 checkSessionListener(numMessages, channel2, factory2, this.localAddress2);
67 checkSessionListener(numMessages, channel3, factory3, this.localIpAddress);
68 checkSessionListener(numMessages, channel3, factory3, this.localAddress2);
72 protected List<PCEPCapability> getCapabilities() {
73 return Collections.emptyList();