package org.opendaylight.protocol.bgp.rib.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.opendaylight.protocol.bgp.rib.impl.AbstractAddPathTest.AS_NUMBER;
import static org.opendaylight.protocol.bgp.rib.impl.AbstractAddPathTest.BGP_ID;
import static org.opendaylight.protocol.util.CheckUtil.readDataOperational;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.dom.adapter.CurrentAdapterSerializer;
import org.opendaylight.protocol.bgp.inet.RIBActivator;
import org.opendaylight.protocol.bgp.mode.impl.base.BasePathSelectionModeFactory;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser;
import org.opendaylight.protocol.concepts.KeyMapping;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private static final TablesKey TABLE_KEY
= new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
private static final InstanceIdentifier<BgpRib> BGP_IID = InstanceIdentifier.create(BgpRib.class);
- private final IpAddress localAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
+ private final IpAddressNoZone localAddress = new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"));
private BGPMock mock;
- private AbstractRIBExtensionProviderActivator baseact, lsact;
- private RIBExtensionProviderContext ext1, ext2;
+ private AbstractRIBExtensionProviderActivator baseact;
+ private AbstractRIBExtensionProviderActivator lsact;
+ private RIBExtensionProviderContext ext1;
+ private RIBExtensionProviderContext ext2;
@Mock
private BGPDispatcher dispatcher;
- private CodecsRegistryImpl codecsRegistry;
+ private ConstantCodecsRegistry codecsRegistry;
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
this.baseact = new RIBActivator();
this.lsact = new org.opendaylight.protocol.bgp.linkstate.impl.RIBActivator();
- this.baseact.startRIBExtensionProvider(this.ext1, this.mappingService);
- this.lsact.startRIBExtensionProvider(this.ext2, this.mappingService);
- this.codecsRegistry = CodecsRegistryImpl.create(this.bindingCodecTreeFactory,
- GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
+ final CurrentAdapterSerializer serializer = mappingService.currentSerializer();
+ this.baseact.startRIBExtensionProvider(this.ext1, serializer);
+ this.lsact.startRIBExtensionProvider(this.ext2, serializer);
+ this.codecsRegistry = new ConstantCodecsRegistry(serializer);
}
+ @Override
@After
public void tearDown() {
this.lsact.close();
}
@Test
- public void testWithLinkstate() throws ReadFailedException {
+ public void testWithLinkstate() throws InterruptedException, ExecutionException {
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class));
.createBestPathSelectionStrategy()));
rib.instantiateServiceInstance();
assertTablesExists(tables);
- rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
- final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4Address(),
- rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
+ final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry,
+ this.localAddress.getIpv4AddressNoZone(), rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
peer.instantiateServiceInstance();
final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
reg.close();
}
@Test
- public void testWithoutLinkstate() throws ReadFailedException {
+ public void testWithoutLinkstate() throws InterruptedException, ExecutionException {
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
UnicastSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1,
tables, Collections.singletonMap(TABLE_KEY,
BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
rib.instantiateServiceInstance();
- rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
assertTablesExists(tables);
- final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4Address(),
- rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
+ final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry,
+ this.localAddress.getIpv4AddressNoZone(), rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
peer.instantiateServiceInstance();
final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
reg.close();
});
}
- private void assertTablesExists(final List<BgpTableType> expectedTables) throws ReadFailedException {
+ private void assertTablesExists(final List<BgpTableType> expectedTables) throws InterruptedException,
+ ExecutionException {
readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
- final List<Tables> tables = bgpRib.getRib().get(0).getLocRib().getTables();
- assertFalse(tables.isEmpty());
+ final var tables = bgpRib.getRib().values().iterator().next().getLocRib().getTables();
+ assertNotNull(tables);
for (final BgpTableType tableType : expectedTables) {
boolean found = false;
- for (final Tables table : tables) {
+ for (final Tables table : tables.values()) {
if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
found = true;
assertEquals(Boolean.TRUE, table.getAttributes().isUptodate());