56574b5e7a924f501ed1151fa3686602fd92050e
[bgpcep.git] / pcep / pcc-mock / src / test / java / org / opendaylight / protocol / pcep / pcc / mock / PCCSyncAvoidanceProcedureTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.pcep.pcc.mock;
10
11 import static org.junit.Assert.assertNotNull;
12
13 import com.google.common.base.Optional;
14 import io.netty.channel.Channel;
15 import java.math.BigInteger;
16 import java.net.UnknownHostException;
17 import java.util.ArrayList;
18 import java.util.List;
19 import java.util.concurrent.ExecutionException;
20 import org.junit.Test;
21 import org.opendaylight.protocol.pcep.PCEPCapability;
22 import org.opendaylight.protocol.pcep.PCEPSession;
23 import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
24 import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCPeerProposal;
25
26 public class PCCSyncAvoidanceProcedureTest extends PCCMockCommon {
27     @Test
28     public void testSessionAvoidanceDesynchronizedEstablishment() throws UnknownHostException, InterruptedException, ExecutionException {
29         final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
30
31         final Channel channel = createServer(factory, socket, new PCCPeerProposal());
32         PCEPSession session = createPCCSession(BigInteger.TEN).get();
33         assertNotNull(session);
34         final TestingSessionListener pceSessionListener = getListener(factory);
35         assertNotNull(pceSessionListener);
36         assertNotNull(pceSessionListener.getSession());
37         checkResyncSession(Optional.<Integer>absent(), 11, null, BigInteger.valueOf(10), pceSessionListener);
38         channel.close().get();
39     }
40
41     @Override
42     protected List<PCEPCapability> getCapabilities() {
43         final List<PCEPCapability> caps = new ArrayList<>();
44         caps.add(new PCEPStatefulCapability(true, true, true, false, false, false, true));
45         return caps;
46     }
47
48     @Override
49     protected int getPort() {
50         return 4567;
51     }
52 }