BUG-6120: Revert Ignore test change
[bgpcep.git] / pcep / pcc-mock / src / test / java / org / opendaylight / protocol / pcep / pcc / mock / PCCTriggeredLspResyncTest.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.util.ArrayList;
17 import java.util.Collections;
18 import java.util.List;
19 import org.junit.Test;
20 import org.opendaylight.protocol.pcep.PCEPCapability;
21 import org.opendaylight.protocol.pcep.PCEPSession;
22 import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
23 import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCPeerProposal;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PcupdBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PlspId;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SrpIdNumber;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.LspBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.PcupdMessageBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.UpdatesBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.updates.PathBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
35
36 public class PCCTriggeredLspResyncTest extends PCCMockCommon {
37     private Channel channel;
38
39     @Test
40     public void testSessionTriggeredLspReSync() throws Exception {
41         final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
42         final int lspQuantity = 3;
43         final BigInteger numberOflspAndDBv = BigInteger.valueOf(lspQuantity);
44
45         this.channel = createServer(factory, socket, new PCCPeerProposal());
46         PCEPSession session = createPCCSession(numberOflspAndDBv).get();
47         assertNotNull(session);
48         final TestingSessionListener pceSessionListener = getListener(factory);
49         assertNotNull(pceSessionListener);
50         checkSynchronizedSession(lspQuantity, pceSessionListener, numberOflspAndDBv);
51         pccSessionListener.onMessage(session, createTriggerLspResync());
52         final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
53         checkResyncSession(Optional.of(lspQuantity), 2, null, numberOflspAndDBv, sessionListenerAfterReconnect);
54         channel.close().get();
55     }
56
57     private Message createTriggerLspResync() {
58         final SrpBuilder srpBuilder = new SrpBuilder();
59         srpBuilder.setOperationId(new SrpIdNumber(1L));
60         srpBuilder.setProcessingRule(Boolean.TRUE);
61
62         final Srp srp = srpBuilder.build();
63         final Lsp lsp = new LspBuilder().setPlspId(new PlspId(Long.valueOf(2))).setSync(Boolean.TRUE).build();
64         final UpdatesBuilder rb = new UpdatesBuilder();
65         rb.setSrp(srp);
66         rb.setLsp(lsp);
67         final PathBuilder pb = new PathBuilder();
68         rb.setPath(pb.build());
69         final PcupdMessageBuilder ub = new PcupdMessageBuilder();
70         ub.setUpdates(Collections.singletonList(rb.build()));
71         return new PcupdBuilder().setPcupdMessage(ub.build()).build();
72     }
73
74     @Override
75     protected List<PCEPCapability> getCapabilities() {
76         final List<PCEPCapability> caps = new ArrayList<>();
77         caps.add(new PCEPStatefulCapability(true, true, true, false, true, false, true));
78         return caps;
79     }
80
81     @Override
82     protected int getPort() {
83         return 4584;
84     }
85 }